Rajandran R Creator of OpenAlgo - OpenSource Algo Trading framework for Indian Traders. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Building Algo Platforms, Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in

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 Creator of OpenAlgo - OpenSource Algo Trading framework for Indian Traders. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Building Algo Platforms, Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in

Algomojo Platform Now Open to Finvasia (Shoonya) Users

Algomojo, a leading Algotrading platform for DIY traders, is excited to announce that it is now open to Finvasia (Shoonya) users. This partnership aims...
Rajandran R
5 min read

Algomojo Platform Now Open to 5Paisa Users

Algomojo, a leading Algotrading platform for DIY traders, is excited to announce that it is now open to 5Paisa users. This partnership aims to...
Rajandran R
5 min read

Algomojo Platform Now Open to Goodwill Commodities Users

Algomojo, a leading Algotrading platform for DIY traders, is excited to announce that it is now open to Goodwill Commodities users. This partnership aims...
Rajandran R
5 min read

Leave a Reply

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