Rajandran R Founder of Marketcalls and Co-Founder Algomojo. Full-Time Derivative Trader. Expert in Designing Trading Systems (Amibroker, Ninjatrader, Metatrader, Python, Pinescript). Trading the markets since 2006. Mentoring Traders on Trading System Designing, Market Profile, Orderflow and Trade Automation.

How to Build your First Execution Module and Cover Order Module in Amibroker

2 min read

This tutorial explores how to build your very first execution module in Amibroker and How to transmit orders from Amibroker to Algomojo trading platoform.

What is a Execution Logic?

Traders who want to automate their Buy and Sell logic they often needs to decide how they want to execute their orders or automate their orders that they are sending to their broker server.

Here a simple button based control is discussed where with a press of the button order gets punched automatically to your broker sever.

What is a Algomojo Bridge?

Algmojo comes with Multi Broker Bridge which provides access to send your automated orders from Amibroker to your broker server

What is AM Dispatcher?

AM Dispatcher is a simple function inside Algomojo Multi Broker Bridge which transports the data from Amibroker to your broker server.

Requirements
Amibroker 5.9 or above version.
Algomojo Trading Account + Algomojo API Credentials
Algomojo Multi Broker Bridge

Building your First Execution Module

Here is a video tutorial where I explained how to create Amibroker Execution module right from the scratch.

Simple Execution Module – Amibroker AFL

_SECTION_BEGIN("Simple Execution Module");

SetChartOptions(0, chartShowArrows | chartShowDates); //x-Axis will be plottted
//plot the candles
Plot(Close,"Close",colorDefault,GetPriceStyle() | styleNoTitle);

apikey = ParamStr("user_apikey","86cbef19e7e61ccee91e497690d5814e"); //Enter your API key here
apisecret = ParamStr("api_secret","6d5acaca5714131814125f8216098782"); //Enter your API secret key here

broker = ParamStr("Broker","tj"); //Broker Short Code - ab - aliceblue, tj - tradejini, zb - zebu, en - enrich, an - angel broking, up - upstox
ver = ParamStr("API Version","1.0");

trigger = ParamTrigger("PlaceOrder","Send Order");


if(trigger)

{
//send order to the broker

api_data = "{
        \"strg_name\":\"Test Strategy\",
        \"s_prdt_ali\":\"BO:BO||CNC:CNC||CO:CO||MIS:MIS||NRML:NRML\",
        \"Tsym\":\"LUPIN-EQ\",
        \"exch\":\"NSE\",
        \"Ttranstype\":\"B\",
        \"Ret\":\"DAY\",
        \"prctyp\":\"MKT\",
        \"qty\":\"100\",
        \"discqty\":\"0\",
        \"MktPro\":\"NA\",
        \"Price\":\"0\",
        \"TrigPrice\":\"0\",
        \"Pcode\":\"MIS\",
        \"AMO\":\"NO\"
      }";
      
      algomojo=CreateObject("AMAMIBRIDGE.Main");
      response = algomojo.AMDispatcher(apikey,apisecret,"PlaceOrder",api_data,broker,ver);
      _TRACE("Broker Server Response : "+ response);

}

_SECTION_END();

Building your First Cover Order Execution Module using Amibroker and Creating Execution Controls

Simple Cover Order Execution Module – Amibroker AFL

_SECTION_BEGIN("Simple Cover Order Module");

SetChartOptions(0, chartShowArrows | chartShowDates); //x-Axis will be plottted
//plot the candles
Plot(Close,"Close",colorDefault,GetPriceStyle() | styleNoTitle);

apikey = ParamStr("user_apikey","86cbef19e7e61ccee91e497690d5814e"); //Enter your API key here
apisecret = ParamStr("api_secret","6d5acaca5714131814125f8216098782"); //Enter your API secret key here

broker = ParamStr("Broker","tj"); //Broker Short Code - ab - aliceblue, tj - tradejini, zb - zebu, en - enrich, an - angel broking, up - upstox
ver = ParamStr("API Version","1.0");
symbol = ParamStr("Symbol Name","RELIANCE-EQ");
stoplevel = Param("Stop Levels",1900,1,10000,1);

trigger = ParamTrigger("PlaceOrder","Send Order");


if(trigger)

{
//send order to the broker

api_data = "{
        \"strg_name\":\"Test Strategy\",
        \"s_prdt_ali\":\"BO:BO||CNC:CNC||CO:CO||MIS:MIS||NRML:NRML\",
        \"Tsym\":\""+symbol+"\",
        \"exch\":\"NSE\",
        \"Ttranstype\":\"B\",
        \"Ret\":\"DAY\",
        \"prctyp\":\"MKT\",
        \"qty\":\"100\",
        \"discqty\":\"0\",
        \"MktPro\":\"NA\",
        \"Price\":\"0\",
        \"TrigPrice\":\""+stoplevel+"\",
        \"Pcode\":\"CO\",
        \"AMO\":\"NO\"
      }";
      
      //Create the object to access the algomojo bridge
      algomojo=CreateObject("AMAMIBRIDGE.Main");
      
      //sending the data using AM Dispatcher to the broker server
      response = algomojo.AMDispatcher(apikey,apisecret,"PlaceOrder",api_data,broker,ver);
      _TRACE("Broker Server Response : "+ response);

}



_SECTION_END();

Now with a click of the Send Order button you should be able to test your orders during live market. See you in the next tutorial with even concepts on building your automated trading using algomojo platform.

Rajandran R Founder of Marketcalls and Co-Founder Algomojo. Full-Time Derivative Trader. Expert in Designing Trading Systems (Amibroker, Ninjatrader, Metatrader, Python, Pinescript). Trading the markets since 2006. Mentoring Traders on Trading System Designing, Market Profile, Orderflow and Trade Automation.

Angel Broking Multi-Client Amibroker Trading Module

Got frequent requirements from Angel Broking Customers to automate Amibroker based trading system where one single generation from charts could punch orders in multiple...
Rajandran R
6 min read

Option Button Trading to Trade ATM, ITM, OTM Options…

Here is a simple button trading module which can be used to send option trading order with buttons. Users can configure the button to...
Rajandran R
7 min read

Multi Broker – Multi Client Algomojo Trading – Amibroker…

Here are simple Amibroker AFL - Button-based Trading modules which help traders to route their orders to different brokers simultaneously. Here is the prototype...
Rajandran R
4 min read

Leave a Reply

Get Notifications, Alerts on Market Updates, Trading Tools, Automation & More