Trade via AmiBroker buttons

In this tutorial, we will understand how to place order via AmiBroker BUY/SELL buttons. You can place different types of orders like Regular, Bracket or Cover orders. The orders can also be placed in single as well as multiple trading accounts across different stock brokers like Zerodha, Upstox, AliceBlue, Finvasia & more.

Trade via AmiBroker Buttons (English)
Trade via AmiBroker Buttons (Hindi)

Prerequisite

  • You must have a trading account with one of the stock brokers we support. At the time of writing, we support Zerodha, Upstox, AliceBlue & Finvasia
  • Amibroker (Free trial version is sufficient)
  • Live data in amibroker

Initial Setup (One time activity)

  1. Register to AutoTrader Web.
  2. Create a trading account.
  3. Make sure it is working. Look at the trading screen, it should show your account’s data.
    1. If you do not see any data, then most likely you have entered wrong credentials. You can correct them by editing your trading account. (Menu: Settings -> Trading Accounts)
  4. Install AutoTrader Desktop client
  5. Add API Key in client’s settings. You will find your API Key in AutoTrader Web. (Menu: Settings -> API Key)
  6. Install AmiBroker library

Once you have done everything properly, you should see following button afls in your AmiBroker’s Chart section.

amibroker charts button afls

Order Placements

at-desktop

Start at-desktop & make sure it is in monitoring state.

AmiBroker

  • Start AmiBroker
  • Bring up the chart
  • Add BUY/SELL button afl of your choice
  • Set the chart parameters (if applicable)

Trade

  • Click the BUY/SELL button to place the order
  • See AmiBroker logs to make sure order was placed (see screenshot below)
  • You can also check at-desktop logs
  • Check AutoTrader Web’s dashboard to see order status
amibroker logs
AmiBroker Logs

Technical Details

You can perform any kind of actions on click of a button. You just need to write the code accordingly in the buttons action section. You can use our api functions for that.

If you look at the afl code, there two different sections for buy & sell each. See the code below:

Buy Section

case 101:
	_TRACE("Placing a BUY market order");
	
	// You can write any of AutoTrader Web API functions here		
	placeOrder(AT_ACCOUNT, AT_EXCHANGE, AT_SYMBOL, 
		"BUY", "MARKET", AT_PRODUCT_TYPE, AT_QUANTITY, 
		0, defaultTriggerPrice(), False);
break;

Sell Section

case 201:
	_TRACE("Placing a SELL market order");
	
	// You can write any of AutoTrader Web API functions here
	placeOrder(AT_ACCOUNT, AT_EXCHANGE, AT_SYMBOL, 
		"SELL", "MARKET", AT_PRODUCT_TYPE, AT_QUANTITY, 
		0, defaultTriggerPrice(), False);
break;

After spending more than 12 years developing Financial Software, I took a break from my career to start my own algorithmic trading setup. This new journey started well and along with my own proprietary trading systems, I also started building automation systems for retail traders, fund managers and HNIs. I was employed with firms like Morgan Stanley, HSBC & SunGard. I work on various technologies, but my strengths are building server side cloud based algorithmic trading systems built primarily using Java programming language. Apart from all of this, I am a big fan of Formula 1 racing :-)

Leave A Comment