Вы находитесь на странице: 1из 51

AutoTrader 4.0.

Copyright © 2018 by stocksdeveloper.com All Rights Reserved.


AutoTrader 4.0.2

Table of contents

Introduction ...................................................................................................... 3
Features ........................................................................................................ 4
Releases ........................................................................................................ 4
Design .......................................................................................................... 5
Installation ........................................................................................................ 6
Amibroker ..................................................................................................... 7
MetaTrader .................................................................................................... 7
Cloud ........................................................................................................... 7
Uninstall ....................................................................................................... 7
Realtime Data (RTD) .......................................................................................... 8
Installation .................................................................................................... 9
Configure Instruments .................................................................................. 13
Backfill ........................................................................................................ 14
Start/Stop RTD ............................................................................................ 15
Getting Started ................................................................................................. 16
Start/Stop Application ................................................................................... 16
Registration ................................................................................................. 17
Automated Trading ...................................................................................... 18
Test ............................................................................................................ 20
Bulk Upload ................................................................................................. 21
Dashboard ................................................................................................... 22
Trading Platform Snapshot ............................................................................ 23
Symbol Mapping .......................................................................................... 24
Settings ....................................................................................................... 27
Integration ...................................................................................................... 28
Amibroker ................................................................................................... 28
Workflow ................................................................................................ 30
How to place orders? ................................................................................ 31
Parameters .............................................................................................. 33
Functions ................................................................................................ 35
Logs ....................................................................................................... 35
Examples ................................................................................................ 36
Place order for stock ............................................................................. 37
Place order for future ............................................................................ 39
Place order for option ........................................................................... 42
Place a bracket order ............................................................................ 43
Place a cover order ............................................................................... 45
How to cancel an order? ....................................................................... 46
How to exit from Bracket/Cover order? ................................................... 47
Place orders with external data or different symbol? ................................. 48
Excel ........................................................................................................... 49
Other Softwares ........................................................................................... 50
Help & Support ................................................................................................ 51

2 / 51
AutoTrader 4.0.2

Introduction

This is a software for trading automatically on AliceBlue, UPSTOX, Zerodha KITE, NEST (client
& dealer), NOW (client & dealer) & ODIN terminals. This software also provides live data for
all exchanges for UPSTOX & KITE users.

It provides you a set of functions that can be used to place orders, read order & portfolio
status. To better understand AutoTrader software, kindly visit this link.

The functions are available for AmiBroker, MetaTrader & Excel. However you can also connect
to AutoTrader from any custom analysis software. For more details, please click here.

3 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Easy EPub and documentation editor

Features
· Fully & Semi Automated Execution
· Support for AliceBlue, UPSTOX, NEST, NOW, ODIN & Zerodha KITE platforms
· Email alerts on critical errors
· Real Time Price, Volume & Open Interest Data with backfill option for all exchanges (NSE,
BSE, MCX) - Only for UPSTOX & KITE users
o Max symbols = 50
o Max Backfill = 1 month (expanding limit)
· No need to buy API from brokers (No additional expenses for you)
· Bulk Order Utility for Brokers & Portfolio Managers (Place order for multiple clients)
· More support for AliceBlue, KITE & UPSTOX, we have provided more functions in
algotrader-util.afl for the following:
o Bracket & Cover order support added
o Order cancellation support added
o Fetch order details (status, pending & filled quantity, status message etc.)
o Fetch position details (net quantity, buy & sell quantity, M2M, PnL, buy value, sell
value, net value etc.)
o Fetch portfolio details
o Fetch funds/margin details
· Sound alerts on order placement
· Support for all market segments
o Cash segment
o Currency, Index & Stock derivatives
o Commodity (This has not been tested, contact support if you face any issues)
· Easy integration with any charting or analysis software
o AutoTrader reads orders from a shared file
o To connect it with any software, the charting/analysis software simply need to
write orders to a file
o Excellent built-in support AmiBroker, MetaTrader & Excel
o To connect it to any other software, click here
· Demo strategies provided which show usage of automation functions
· Supports all order types (Limit/Market/StopLoss)
· Support for detailed order attributes as well, have a look at sample file here
· New features & changes
o If you need any new enhancements or changes in the software, we will try to
build it after analyzing your requirement
· Help
o We have put up a user guide to get you started
o You can also contact us for any queries or support

Created with the Personal Edition of HelpNDoc: Full-featured EBook editor

Releases

Please look at release notes & overview of release process.

4 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Write EPub books for the iPad

Design
All applications that need to place orders must write the orders into a file. The orders are
written in a comma separated format. These orders are picked up by AutoTrader and then
placed into trading platform.

AutoTrader reads portfolio snapshot (orders, positions etc.) from your trading platform &
saves it in files. These files can be read by strategy execution software to get live status of
the portfolio.

To better understand the workflow, please read this article.

5 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Create cross-platform Qt Help files

Installation

System Requirements

Category Minimum Recommended


Operating System Windows 7/8/10 Windows 7/8/10
CPU Intel i3 Intel i7
RAM 3GB 4GB or more

Installation Steps
· Download setup from here. You will get setup.bat file.
· The setup will automatically do a fresh installation or upgrade existing installation if
AutoTrader is already installed on your computer.
· Run setup file (Right Click -> Run as Administrator) & wait for installation to complete,
it takes some time so please be patient.
· Software will be installed in C:\autotrader folder
· You will have shortcuts created on Desktop now for starting and stopping the server.
· Go to your desktop, for both Start-AT & Stop-AT shortcuts; do following steps
· Right click on shortcut -> click on Properties
· On properties window, go to Shortcut tab & click Advanced button.
· Tick Run as Administrator -> Press OK -> Press Apply
· If the command window seems to stuck (not moving), then click on the window & press
enter.
· To look at how to integrate AutoTrader with AmiBroker & Metatrader, see next page.

Start
· To start AutoTrader, double click Start-AT shortcut on your Desktop
· If you get a Windows Defender warning, then click 'More Info' -> Run
· If windows asks whether to allow application through firewall, then please allow (both
public & private networks).
· If the command window seems to stuck (not moving), then click on the window & press
enter.
· Note: If AutoTrader fails to start, please take a look at this solution.

6 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Easy to use tool to create HTML Help files and Help web sites

Amibroker

Amibroker Integration

If you do not have Amibroker software installed then you can install Amibroker free version
from here.

· You must always start Amibroker before starting AutoTrader


· If your amibroker is installed at one of the following paths, then there is no need to
perform following steps. The setup copies the files automatically to these paths:
o C:\Program Files\AmiBroker
o C:\Program Files (x86)\AmiBroker
· If your amibroker is not installaed on above path, then copy following folders manually
o Go to folder (C:\autotrader\scripts\amibroker)
o Copy all folders inside this folder into your Amibroker installation folder (Example:
C:\Program Files\AmiBroker)
§ Select all folders & copy
§ Go to Amibroker installation folder & paste
§ If system asks "Do you want to replace?" then Click YES (Replace All)

Created with the Personal Edition of HelpNDoc: Produce online help for Qt applications

MetaTrader

MetaTrader Integration

If you do not have MetaTrader software installed then you can install MetaTrader free
version from here. We recommend using MetaTrader version 5 or above.

The process of integrating with MetaTrader is documented in this article.

Created with the Personal Edition of HelpNDoc: Easily create EBooks

Cloud
AutoTrader can be installed on any windows virtual machine. Here is a demo of how it can be
installed on Google cloud.
Created with the Personal Edition of HelpNDoc: News and information about help authoring tools and
software

Uninstall

How to remove AutoTrader from your computer?

1. Delete folder C:\autotrader


2. Delete AutoTrader shortcuts from your desktop

7 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Full-featured EBook editor

Realtime Data (RTD)

Realtime Data Video Tutorial is available here.

· Only available for KITE & UPSTOX users


· NO need to buy api from broker
· Live & backfill (price, volume & open interest) data for all exchanges
· Reliable data (we simply redirect the data that you get in your trading terminal to
Amibroker)
· You can configure instruments for realtime download from AutoTrader
· Regarding discrepancies in data, please refer here

8 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: News and information about help authoring tools and
software

Installation
Only available for KITE & UPSTOX users.

Realtime Data Video Tutorial is available here.

This section explains the installation (setup) process of realtime data. This is one time
activity.

1. Make sure you have done Amibroker setup steps given in previous page.
2. Amibroker Run as Administrator
1. Right click on your Amibroker shortcut, click Properties
2. Click Advanced
3. Tick (select) Run as Administrator.
3. Create new database
1. Start Amibroker
2. Click on menu (File -> New -> Database)
3. Select database folder by clicking Browse
1. Select folder (C:\autotrader\rtd\amibroker\autotrader)
2. Tick (select) Load this database at startup
3. Click Create
4. Apply database settings as per the screenshot 1 below
1. Enable local data storage
2. Set number of bars to 30000
3. Set Base time interval as (Tick)
5. Click on Intraday Settings and apply settings as per the screenshot 2 below
1. Tick Show Day Session Only
2. Set market timings as per the exchange you trade
1. Screenshot shows NSE market timings (9:15 to 15:30)
2. If you trade on MCX, then enter 9:00 to 23:55
3. If you trade on NSE & MCX both, then enter 9:00 to 23:55
6. Mark as default database (see screenshot 3 below)
1. Go to Tools -> Preferences
2. Go to Data tab
3. Click on Current

Important: You MUST start Amibroker first & then AutoTrader. You must also be
logged into Kite on Chrome browser.

9 / 51
AutoTrader 4.0.2

Screenshot 1

10 / 51
AutoTrader 4.0.2

Screenshot 2

11 / 51
AutoTrader 4.0.2

Screenshot 3

12 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Full-featured multi-format Help generator

Configure Instruments
· Make sure you FIRST start Amibroker (Run as Administrator)
· Then start AutoTrader
· Click on RTD link on the menu
· Select exchange, instrument & option type from the dropdown
· Enter symbol of the instrument & click search
· You will get the search results
· Select the instruments you want to add to RTD & click Add to RTD
· Table at the bottom shows all configured instruments
· You can also remove instruments from RTD by using Delete from RTD button

Note: There is NO NEED to have these instruments added to your marketwatch in


UPSTOX/KITE.

13 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Full-featured Kindle eBooks generator

Backfill
· If you are using Zerodha Kite, then you must be logged in on Firefox browser
· Make sure you FIRST start Amibroker (Run as Administrator)
· Then start AutoTrader
· Click on RTD link on the menu
· Look for the table Realtime Data Instruments
· Select the instruments you want to backfill (i.e. load historical data)
· Click on Backfill
· You will get alerts on your home screen once the backfill is complete

14 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Qt Help documentation made easy

Start/Stop RTD
· If you are using Zerodha Kite, then you must be logged in on Firefox browser
· Make sure you FIRST start Amibroker (Run as Administrator)
· Then start AutoTrader
· If you need live Volume, then tick the Volume checkbox
· To start, click Start (RTD row)
o All configured symbols' live data will be feed to amibroker
o Make sure you have selected Amibroker database as (C:
\autotrader\rtd\amibroker\autotrader)
· To stop, click Stop (RTD row)

Note: If you want to change certain settings on chart, stop live prices -> change settings -
> start (RTD).

15 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Easily create PDF Help documents

Getting Started

Once you have completed all the steps in the installation procedure, you can now get
started.
Created with the Personal Edition of HelpNDoc: Full-featured Help generator

Start/Stop Application

Start
· To start an application, double click on the Start-AT shortcut on your desktop.
· It must always be run as administrator.
· It takes around 60 seconds for the application to start
· The system will automatically open a browser & go to address localhost:8080. If it
doesn't then open a browser & enter url localhost:8080
· You will see the home screen similar to the one below
· To start automated trading, click Start (AutoTrader row)

Stop
· To stop an application, double click on the Stop-AT shortcut on your desktop.

16 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Free iPhone documentation generator

Registration
On first time login you will be taken to a registration page. You must register here (this is one
time process). You need to enter following details:

· Your email address


· Your name
· Contact number
· AliceBlue/UPSTOX/NOW/NEST/KITE/ODIN Client id (This is the client id that you use for
logging into NOW/NEST terminal. It is required for placing order. It can be changed later
through settings)
· Login Password (Required for Upstox & AliceBlue)
· Login 2fa answer (Required for Upstox & AliceBlue)
· Transaction Password (Required for AliceBlue)

By default, you will get a 15-days trial license (except for virtual machines which only get 1
day license).

17 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Free Web Help generator

Automated Trading

Run Procedure
Steps involved in starting your automated trading.

1. Login to your trading platform (KITE/NOW/NEST/ODIN)


1. UPSTOX & AliceBlue user must not login to their trading platform
2. Start your analysis application
1. Example, start Amibroker with your strategies running live (or using Bar Reply when
testing)
3. Start our service by double clicking Start-AT shortcut on desktop
4. Login to AutoTrader in your browser localhost:8080
5. Click on Start (AutoTrader) button
6. Click on Start (RTD) (if you are using realtime data from AutoTrader)
7. Run your strategies on live data in Amibroker or Excel
8. For NOW/NEST/ODIN trading terminals only. Once you have started strategies in
Amibroker, just make sure that trading platform is open in FRONT. The NEST/NOW/ODIN
window must be in foreground (in front) for orders to be placed.
9. Whenever an order is placed from strategy, you will hear an alarm.
10. AutoTrader will then immediately place on order onto your trading terminal

18 / 51
AutoTrader 4.0.2

Basic Start/Stop

Fully Automated Mode

· On the Home screen, you should see that the system is in a READY state.

· Press Start AutoTrader button to start fully automated trading. As you can see in
screen below, trading mode is set to Auto by default. Once you click start, the system
will go into RUNNING state.
o The system will now wait for orders to come. As soon as the orders come system
will place it in your trading platform.

Semi Automated Mode

· To run in semi automated mode, just select mode to Semi-Auto


o When the system is in semi-auto mode, it will still read orders but it will not place
them
· To hold/pause automated order placement, press Pause
o When the system is on hold; all the orders that are received while the system is
on hold will be placed when the system is started again

19 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Generate EPub eBooks with ease

Test
Before you start live trading, it is important to do some tests.

Good Practice
· If possible, do testing after market hours
· During testing, if possible keep zero balance in your trading account (so all orders will be
rejected)
· Otherwise use small quantity limit orders, and use price which is outside circuit limits
(Example: price = 1.5, it will make sure that all your orders are rejected)
· If you follow above rules, then there is no risk accidentally placing an order

Test Procedure
Here I am giving all the steps that you would take to get automated order placement
running.

1. Login to your trading platform (NOW/NEST/KITE)


1. For KITE, only Firefox Browser is supported
2. Start our service by double clicking shortcut on desktop
3. Login to our system, open browser and enter url localhost:8080
4. Click on Start button
5. Start your analysis application
1. Example, start AMI Broker with your strategies
2. Make sure you called placeOrder functions from your strategy's AFL
3. Use Bar Reply feature of AMI Broker
6. Once you have started strategies in AMI Broker, just make sure that NEST/NOW is
open in FRONT. The NEST/NOW window must be in foreground (in front) for orders
to be placed.
7. Whenever an order is placed from strategy, you will hear an alarm.
8. AutoTrader will then immediately place on order onto trading terminal.

20 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Full-featured Kindle eBooks generator

Bulk Upload

Bulk Order Upload


This feature is useful for brokers & portfolio managers. Using this feature you can place
orders for multiple clients in a single click.

Note: You must have a nest dealer terminal or rights to place orders on behalf of multiple
clients.

1. Please open bulk orders excel file from (C:\autotrader\scripts\excel)


1. BulkOrders-WebPlatforms : Bulk order utility for Kite, Upstox & AliceBlue users
(Allows you to place regular order, bracket order, cover order & after market order
in bulk)
2. BulkOrders-OneOrderMultiClient : Single order for multiple clients (dealer
terminal)
3. BulkOrders-MultipleOrders : Multiple bulk orders for a single client
4. BulkOrders-MultiOrderMultiClient : Multiple orders for multiple clients (dealer
terminal)
2. If you get a warning, then click "Enable Macro".
3. There are 2 sheets where you need to fill data:
1. clients: Enter your client codes here & their respective quantities
2. order: Fill your order details here
4. Click "Place Bulk Order" button.
5. The system by default will wait for 5 seconds (See column Delay on params sheet). This
will give you time to bring NEST/NOW in front. You can modify this value.
6. Bring your NEST/NOW platform to front.
7. AutoTrader will enter same order for all of your clients.

Note: To make it even more easy to enter data, you can make multiple copies of excel
files for each stock.

Please contact us if you have any custom requirement to place orders.

21 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Easily create iPhone documentation

Dashboard
· On top you have (Start/Pause/Stop) buttons.
· After that you see the current system status
· Alerts table displays alerts generated in last 10 days
· Orders tables displays all orders received in last 10 days
· Records older than current day are displayed in a different color scheme

22 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Qt Help documentation made easy

Trading Platform Snapshot

Menu (Dashboard -> Trading Snapshot)

This screen shows your trading platform snapshot as seen by AutoTrader. It is very useful to
investigate issues & understand the system. For example, this screen shows both ids of order
(one given by ammibroker/metatrader [Pub Id] & another given by your trading platform
[Id]). So you can easily map the orders generated to the actual orders executed on trading
platform.

As of now, trading platform screen works for UPSTOX, AliceBlue & Zerodha KITE trading
terminals.

23 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Easily create EBooks

Symbol Mapping
Menu (Settings -> Mapping)

Mapping feature is useful when your chart symbol does not match with exchange symbol.
Trading symbols need exchange symbols for orders to be placed successfully; but some data
providers give symbols which are not valid on the exchange. Some examples are: NIFTY-I,
SBIN-EQ etc.

AutoTrader allows you to map these custom symbols to exchange traded symbols. Once you
have done a mapping, then your code can pass custom symbols in placeOrder() functions.

There are 2 ways to create a mapping:


1. Map a single symbol, Create button
2. Map symbols in bulk using a csv, Create in Bulk button

Both examples are given on following pages...

24 / 51
AutoTrader 4.0.2

Please look at an example 1 (single mapping) below:

Here we have create a mapping for key "NIFTY-I". Now we will pass this key in place of
symbol.

Once you have a mapping in place, you can then call function like the one below in AMI
Broker:

placeOrderMappedSymbol("NIFTY-I", "SELL", "NORMAL", "LIMIT", 75, 9900.5,


defaultTriggerPrice(), defaultDisclosedQuantity());
or
placeOrderMappedSymbol(Name(), "SELL", "NORMAL", "LIMIT", 75, 9900.5, 0, 0);

Name() is a built-in function in AmiBroker which gives chart symbol. So you can directly use
symbols from your data provider.

Without the mapping you would have to call a function like this (additional fields in pink):

placeOrderFuture("NFO", "FUTIDX", "NIFTY", "SELL", "NORMAL", "LIMIT", 75, 9900.5,


defaultTriggerPrice(), "26-OCT-2017", defaultStrategyId(),
defaultComments());

25 / 51
AutoTrader 4.0.2

Let us look at example 2 (bulk mapping) below:

· You can enter data Key,Symbol format


o Key - Custom symbol from your data provider
o Symbol - Exchange symbol accepted by your trading platform
· Make sure you do not mix up symbols of different Exchange in a single list. Example
o Upload all your NFO symbols in one list
o Next upload all your NSE symbols in another list
o This is because all symbols in one request will have the values from the dropdown
(marked in red below) applied to them

26 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Full-featured Documentation generator

Settings
Menu (Settings -> AutoTrader)

Settings are divided into categories, please click appropriate category to modify settings.

27 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Create iPhone web-based documentation

Integration

Created with the Personal Edition of HelpNDoc: Easily create PDF Help documents

Amibroker

Integration with Amibroker


To see how to integrate Amibroker, please see these installation steps here.

Sample strategies
· algotrader-util.afl - This file provides various AFL functions that can be used for placing
an order. You must include this file in your strategy, so that all functions become
available to your strategy AFL.
o #include <algotrader-util.afl>
· at-ema-crossover-simple.afl - This file contains a simple Moving Average Crossover
strategy, which shows how to place orders.
· at-ema-crossover.afl - This file contains a simple Moving Average Crossover strategy,
which shows how to place orders & square-off feature.
· at-order-place-cancel-profit-stoploss.afl - This file contains a simple Moving Average
Crossover strategy, which shows how to place orders & cancel order, place profit &
stoploss orders.
· at-bracket-order.afl - This demonstrates the use of bracket orders (target & stoploss
values in %).
· at-bracket-order-absolute - This demonstrates the use of bracket orders (target &
stoploss values in absolute terms, just like zerodha order entry screen).
· at-cover-order.afl - This demonstrates the use of cover orders.
· at-buy-sell-buttons - Adds a buy sell button on the chart.
· at-ema-crossover-simple-multiclient - Demo of how to trade across multiple clients using
NEST/NOW dealer terminal

There are many other sample files, please look at their code to get a better understanding of
how they work.

28 / 51
AutoTrader 4.0.2

29 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Free help authoring tool

Workflow
Let us understand how AMIBroker works with AutoTrader.

1. You write strategy in amibroker.


1. A strategy is basically a set of instructions to tell computer when to buy
or sell
2. You use the functions we have provided to place orders
2. Start Amibroker first
3. Start AutoTrader
4. Login into your trading pltatform (UPSTOX/NOW/NEST/ODIN/KITE)
5. Perform Backfill from RTD screen in AutoTrader (For UPSTOX & KITE only)
6. Start with a new blank chart & set parameters
7. Feed live data to amibroker ("Start Live Prices" button on dashboard)
8. Amibroker runs your strategy every time a new price is received
9. As per logic in your strategy, every time a buy or sell signal is generated the
functions that you have written will be invoked to place an order

For detailed explanation see following articles:

· Workflow
· Amibroker Strategy Debugging
· AutoTrader communication files

30 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Generate EPub eBooks with ease

How to place orders?

Demo strategies are available in C:\autotrader\scripts\afl

How to place order from strategy?

1. Include autotrader-util.afl at the beginning of your fiile.


2. Use place order functions when your Buy, Sell, Cover, Short conditions are
true.

Lets look at a typical strategy:


· Code required for automation using AutoTrader is written in gray background
· Your strategy code is written in yellow background. You can replace the code in
yellow background with your own strategy code.

#include <algotrader-util.afl>

// Moving Average
SHORT_MA_PERIOD = Param("Short term moving average period", 20, 1, 200, 2);
LONG_MA_PERIOD = Param("Long term moving average period", 40, 1, 200, 2);

_SECTION_BEGIN("AutoTrader Demo 1 - Moving Average Crossover");

/* Exponential Moving averages */


EMA1 = EMA( C, SHORT_MA_PERIOD);
EMA2 = EMA( C, LONG_MA_PERIOD);

/* Buy and Sell Condition */


Buy = Cross(EMA1,EMA2);
Sell = Cross(EMA2,EMA1);

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short = Sell;
Cover = Buy;

buyPrice = ValueWhen(Buy,C);
sellPrice = ValueWhen(Sell,C);
shortPrice = ValueWhen(Short,C);
coverPrice = ValueWhen(Cover,C);

/* Plot Buy and Sell Signal Arrows */


shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );
GraphXSpace = 5;

/* Plot EMA lines and Candles */


Plot(EMA1,"EMA",colorRed);

31 / 51
AutoTrader 4.0.2

Plot(EMA2,"EMA2",colorGreen);
Plot(C,"Close",colorRed,styleCandle);

if ( LastValue(Buy) == True )
{
placeOrderUsingParams("BUY", AT_ORDER_TYPE, AT_QUANTITY, buyPrice,
defaultTriggerPrice(), 1);
}

if ( LastValue(Sell) == True )
{
placeOrderUsingParams("SELL", AT_ORDER_TYPE, AT_QUANTITY, sellPrice,
defaultTriggerPrice(), 1);
}

_SECTION_END();

Examples:

// NEST/KITE/NOW Examples

placeOrderFuture("NFO", "FUTIDX", "NIFTY", "SELL", "NORMAL", "LIMIT", 75, 9900.5,


defaultTriggerPrice(), "26-OCT-2017", defaultStrategyId(),
defaultComments());

placeOrderStock("NSE", "EQ", "SBIN", "SELL", "INTRADAY", "LIMIT", 10, price,


0, 0, 1, "Demo sell order managed by strategy 1");

// ODIN Examples

placeOrderFuture("NSE", "FUTIDX", "NIFTY", "SELL", "NORMAL", "LIMIT", 75, 12000,


defaultTriggerPrice(), "25-JAN-2018", defaultStrategyId(), defaultComments());

placeOrderStock("NSE", "EQUITIES", "SBIN", "SELL", "INTRADAY", "LIMIT", 10, price,


0, 0, 1, "Demo sell order managed by strategy 1");

32 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Generate Kindle eBooks with ease

Parameters

Variables available from algotrader-util afl

Every time you include algotrader-util.afl into your strategy code; you will automatically
get following parameters added to your chart. These parameters help you to easily configure
strategy settings.

You can use these variables in your strategy code to get the parameter values configured on
chart. Look at the sample strategies provided to understand how it is done.

/*******************************************************************
* Please read algotrader-util.afl file to understand all functions
* provided by AutoTrader. But DO NOT modify the file, if you are
* not familiar with AFL coding.
*
* NOTE: It is recommended to start with a blank chart.
********************************************************************
* Following variables are declared for strategy parameters in
* algotrader-util.afl.
********************************************************************
*
* AT_SYMBOL : Order symbol
* AT_QUANTITY : Order quantity (lot size)
* AT_EXCHANGE : Order exchange
* AT_INSTRUMENT : Order instrument
* AT_PRODUCT_TYPE: Order product type
* AT_ORDER_TYPE : Order order type
* AT_EXPIRY : Order expiry (expiry date (Example: 28-DEC-2017), pass NA if not
applicable)
* AT_OPTION_TYPE : Order option type
* AT_STRIKE_PRICE : Order strike price
* AT_SQUARE_OFF_FLAG: Intraday Auto Square-off (on|off)
* AT_SQUARE_OFF_TIME: Intraday Square-off Time
*
********************************************************************/

33 / 51
AutoTrader 4.0.2

How to enter values for these parameters?

Right click on amibroker chart & select parameters.

34 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Full-featured EBook editor

Functions

This sections explains most of the Amibroker functions/formulae provided by AutoTrader. To


better understand these functions & also to look at all available functions; users are advised
to read "algotrader-util.afl". But please do not modify the file, if you are not familier with
AFL coding.

For a complete list of functions available along with their parameters,


please visit autotrader functions.

Created with the Personal Edition of HelpNDoc: Free EBook and documentation generator

Logs

AutoTrader Logs

AutoTrader logs are available at path (C:\autotrader\logs). They are useful to


debug problems & you can send the log file to support when raising a query (if
required). AutoTrader creates one log file per day.

AmiBroker Logs

Amibroker logs will help you to see what autotrader functions are doing, it is very
useful to debug problems.

How to see strategy logs in AMIBroker?


1. Enable log window from amibroker menu (Window -> Log)
2. You will see log window at the bottom.
3. Go to "Trace" tab (all strategy logs are printed here).

To know more about How to Debug, please see this article.

35 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Create iPhone web-based documentation

Examples
There are many functions provided by AutoTrader, now let us see some examples of how to
use them.

To see a list of all chart parameters, click here.

For a complete list of functions available along with their parameters,


please visit autotrader functions.

Demo strategies should be available in your Amibroker (see screenshot below).

36 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Qt Help documentation made easy

Place order for stock


Example 1. Place buy market order with 21 quantity for SBIN stock.

// placeOrderUsingParams(tradeType, orderType, quantity, price, triggerPrice, validate)

orderId = placeOrderUsingParams("BUY", AT_ORDER_TYPE, AT_QUANTITY, 0,


defaultTriggerPrice(), 1);

Above function will place an intraday buy market order for symbol = SBIN, quantity = 21,
you can see that we are passing variables configured on chart parameters to the function.

Parameters

37 / 51
AutoTrader 4.0.2

Example 2. Place sell stoploss order with 100 quantity for RELIANCE stock, with trigger price
1100.5

Solution 1: We place orders using parameters

// placeOrderUsingParams(tradeType, orderType, quantity, price, triggerPrice, validate)

stoplossPrice = 1100.5; // You can calculate stoploss price using your own formula
sellPrice = stoplossPrice - 1; // Sell price a little less than stoploss price
placeOrderUsingParams("SELL", "STOP_LOSS", AT_QUANTITY, sellPrice, stoplossPrice, 1);

Solution 2: We place order by passing our own values calculated from code

// placeOrderStock(exchange, instrument, symbol, tradeType, productType, orderType,


// quantity, price, triggerPrice, disclosedQuantity, strategyId, comments);

stoplossPrice = 1100.5; // You can calculate stoploss price using your own formula
sellPrice = stoplossPrice - 1; // Sell price is a little less than stoploss price

orderId = placeOrderStock(AT_EXCHANGE, AT_INSTRUMENT, AT_SYMBOL, "SELL",


"INTRADAY", "STOP_LOSS",
100, sellPrice, stoplossPrice, defaultDisclosedQuantity(), defaultStrategyId(), "My
stoploss order");

38 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Free help authoring environment

Place order for future


Example 1. Place a sell order NIFTY future 1 lot (lot size = 75).

Solution 1:

// placeOrderUsingParams(tradeType, orderType, quantity, price, triggerPrice, validate)

orderId = placeOrderUsingParams("SELL", AT_ORDER_TYPE, AT_QUANTITY, 0,


defaultTriggerPrice(), 1);

Above function will place an intraday sell market order for NIFTY MAR 2018 future,
quantity = 75 (i.e. 1 lot), you can see that we are passing variables configured on chart
parameters to the function.

· Zerodha KITE Users (See picture 1 & 2)


· NOW/NEST Users (See picture 3)

Zerodha KITE Users (Picture 1 - NFO)

39 / 51
AutoTrader 4.0.2

Zerodha KITE Users (Picture 2 - MCX)

40 / 51
AutoTrader 4.0.2

NEST/NOW Users (Picture 3)

Solution 2: If you need to pass additional parameters then you can do it following way.

// placeOrderFuture(exchange, instrument, symbol, tradeType, productType, orderType,


// quantity, price, triggerPrice, expiry, strategyId, comments)

sellPrice = ValueWhen(Sell,C);

orderId = placeOrderFuture("NFO", "FUTIDX", "NIFTY", "SELL", "NORMAL", "LIMIT",


75, sellPrice, defaultTriggerPrice(), "25-JAN-2018", defaultStrategyId(), "My derivative
order");

Above function will place an intraday sell market order for NIFTY JAN 2018 future,
quantity = 75 (i.e. 1 lot), you can see that we are passing variables configured on chart
parameters to the function.

41 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Easily create Qt Help files

Place order for option


Example 1. Place a sell market order NIFTY call option at strike 10000, quantity 1 lot (lot
size = 75).

Solution 1:

// placeOrderUsingParams(tradeType, orderType, quantity, price, triggerPrice, validate)

orderId = placeOrderUsingParams("SELL", AT_ORDER_TYPE, AT_QUANTITY, 0,


defaultTriggerPrice(), 1);

Above function will place an intraday sell market order for NIFTY JAN 2018 Call option
with strike 10000, quantity = 75 (i.e. 1 lot), you can see that we are passing variables
configured on chart parameters to the function.

42 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Benefits of a Help Authoring Tool

Place a bracket order


Bracket orders are only supported on Zerodha KITE. There are 2 functions for placing bracket
order:
· placeBracketOrder - Limit bracket order
· placeStoplossBracketOrder - Stoploss bracket order

Example 1. Place buy bracket order for NIFTY FUTURE.

// placeBracketOrder(exchange, symbol, tradeType, quantity, price, target, stoploss,


trailingStoploss, validate)
// placeStoplossBracketOrder(exchange, symbol, tradeType, quantity, price, triggerPrice,
target, stoploss, trailingStoploss, validate)

// Assume NIFTY future is trading at 10000, then our target is 10050 and stoploss is 9980.
We set trailingStoploss to 2.
buyPrice = ValueWhen(Buy,C);
target = 50;
stoploss = 20;
trailingStoploss = 2;
orderId = placeBracketOrder("NFO", "NIFTY18JANFUT", "BUY", AT_QUANTITY, buyPrice,
target, stoploss, trailingStoploss, 1);

Above function will place a buy bracket order for NIFTY JAN 2018 Future, quantity = 75
(i.e. 1 lot), you can see that we are passing variables configured on chart parameters to the
function.

Parameters

43 / 51
AutoTrader 4.0.2

44 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Free help authoring tool

Place a cover order


Cover orders are only supported on Zerodha KITE.

Example 1. Place buy cover order for NIFTY FUTURE.

// placeCoverOrder(exchange, symbol, tradeType, quantity, triggerPrice, validate)

// Assume NIFTY future is trading at 10000, then we set our stoploss at 9980.
livePrice = 10000;
stoploss = livePrice - 20;
orderId = placeCoverOrder("NFO", "NIFTY18JANFUT", "BUY", AT_QUANTITY, stoploss, 1);

Above function will place a buy cover order for NIFTY JAN 2018 Future, quantity = 75 (i.e.
1 lot), you can see that we are passing variables configured on chart parameters to the
function.

Parameters

45 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: What is a Help Authoring tool?

How to cancel an order?


In order to cancel an order, you need to have the order_id. So first you need to save order
id.

Save order id

Every place order function returns an order_id of the order that was placed. We will store
this order id in a static variable, so that we can use it later when we want to cancel the
order.

We will place a limit order here & save the order id in a variable orderId.

The function we use for saving order id is atStaticVarSetText(key, value). This function
saves the value in a static variable, and makes sure that the key is unique so that it is not
affected by strategies running in other charts.

orderId = placeOrderUsingParams("BUY", "LIMIT", AT_QUANTITY, buyPrice,


defaultTriggerPrice(), 1);

/* Save entry order id for later use */


atStaticVarSetText("ENTRY_ORDER_ID", orderId);

Cancel order

Now we use function atStaticVarGetText(key) to get order_id that we saved earlier & use it
to cancel order.

/* We assume your order is open & you will have some logic based on which you may want to
cancel an order */

if (some_condition) {
// Now we want to cancel open order
orderId = atStaticVarGetText("ENTRY_ORDER_ID");
if(isOrderOpen(orderId) == 1) {
cancelOrder(orderId);
}
}

46 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Free help authoring environment

How to exit from Bracket/Cover order?


In order to cancel an order, you need to have the order_id. So first you need to save order
id.

Save order id

Every place order function returns an order_id of the order that was placed. We will store
this order id in a static variable, so that we can use it later when we want to cancel the
order.

We will place a limit order here & save the order id in a variable orderId.

The function we use for saving order id is atStaticVarSetText(key, value). This function
saves the value in a static variable, and makes sure that the key is unique so that it is not
affected by strategies running in other charts.

orderId = placeBracketOrder("NFO", "NIFTY18JANFUT", "BUY", AT_QUANTITY, buyPrice,


target, stoploss, trailingStoploss, 1);

/* Save entry order id for later use */


atStaticVarSetText("ENTRY_ORDER_ID", orderId);

Cancel order

Now we use function atStaticVarGetText(key) to get order_id that we saved earlier & use it
to cancel order.

/* We assume your order is complete & you will have some logic based on which you may
want to exit from bo/co position */

if (some_condition) {
// Now we want to exit from bracket/cover order's position
orderId = atStaticVarGetText("ENTRY_ORDER_ID");
cancelOrExitOrder(orderId);
}

47 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Free HTML Help documentation generator

Place orders with external data or different symbol?


External data providers sometimes have symbols associated with prices which are not actual
symbols used in trading. For example, your data provider may give symbol as NIFTY-I for
near month nifty future.

In such cases you can use Mapping option available with AutoTrader to map these data
provider symbols to exchange traded symbols.

Once you have done the mapping, then you can pass NIFTY-I to AutoTrader provided
functions & it will internally map it to the contract you have configured in Mapping.

For details about how to map, see Mapping section.

48 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Easy to use tool to create HTML Help files and Help web sites

Excel
Here we discuss about how to place orders from Microsoft Excel.

Readymade Files

You will find sample files under C:\autotrader\scripts\excel folder. These files can be used
to place orders automatically.

BulkOrders-WebPlatforms - It is used for sending multiple orders (in bulk) to


Kite/AliceBlue/Upstox trading platform. You can place any type of orders (regular order,
bracket order, cover order or amo (after market order)) in bulk with a single click.
BulkOrders-MultipleOrders - It is used for sending multiple orders to your trading platform.
BulkOrders-OneOrderMultiClient - It is used by dealers to place a single order for multiple
clients.
BulkOrders-MultiOrderMultiClient - It is used by dealers to place a multiple orders for multiple
clients.
autotrader-options-buy-call-put - It is an excel sheet which receives signal (from user-
defined formula) and based on that buys call or put option

Using automation with your own excel files

To make autotrader functions available to your own excel, you will have to install autotrader
addin.

Steps:
1. The addin is available at C:\autotrader\scripts\excel\autotrader.xlam
2. Copy the file to C:\Users\UserName\AppData\Roaming\Microsoft\AddIns. See this link for
more information on how to install addins.

Once you have addins install, then you can see all place order functions available in the User
Defined category (see below).

Double-click on placeOrder functions to see list of parameters to pass. Alternatively you can
type a function in excel cell:
=placeOrderStock
And press Ctrl + A to see help.

49 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Write eBooks for the Kindle

Other Softwares
AutoTrader can be integrated with any software because it uses a simple file based inter
process communication.

Read this article which explains how to connect AutoTrader with any other software.

50 / 51
AutoTrader 4.0.2

Created with the Personal Edition of HelpNDoc: Single source CHM, PDF, DOC and HTML Help creation

Help & Support

If you need help or have queries, we recommend going through following help material:
· AutoTrader Support
· YouTube videos
· Blog
· AutoTrader User Guide
· FAQ
· API Function Reference
· AmiBroker Tutorial
· MetaTrader Tutorial

You can always email us on help@stocksdeveloper.com

Please read the terms & conditions for support.


Created with the Personal Edition of HelpNDoc: Single source CHM, PDF, DOC and HTML Help creation

51 / 51

Вам также может понравиться