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 Send Automated Orders without any Amibroker Bridge Installation?

2 min read

This tutorial explores how to send Automated orders to the brokers using the Algomojo platform without any external Bridge Installation.

Usually a Trading Bridge an external application/dll will be used to convert Amibroker signals into Trading Orders. However now with the Amibroker 6.39 version onwards couple of newly introduced Internet functions (InternetSetHeaders, InternetSetAgent & InternetPostRequest) helps traders to send orders without any bridge installation.

Supported Amibroker Version : Amibroker 6.39 version or higher
Supported Brokers : Aliceblue, Tradejini, Zebu

Note: In case you don’t have access to Amibroker 6.39 version or higher still have to use Multi Broker Bridge in Algomojo to send automated orders for efficient transmission of orders.

Here is the Amibroker AFL Code to Send Automated Orders

//This code requires Amibroker Version 6.39 or higher 

_SECTION_BEGIN("Send Auotmated Orders without Any Algo Bridge Installation");

Version(6.39);

trigger = ParamTrigger("transmit order","Send order");
stgy_name = ParamStr("Strategy Name","Amibroker Chart");
user_apikey = ParamStr("user_apikey","86cbef19e7e61ccee91e497690d5814e"); //Enter your API key here
api_secret = ParamStr("api_secret","8e8b207de43446c65f379bf2145b62fc"); //Enter your API secret key here
s_prdt_ali = "NRML:NRML|BO:BO|CNC:CNC|CO:CO|MIS:MIS"; 
Tsym = ParamStr("Tsym","RELIANCE-EQ");
exch = ParamList("Exchange","NSE|BSE|NFO|CDS|MCX",0);
Ret = "DAY";
prctyp = ParamList("prctyp","MKT|L|SL|SL-M",0);
Pcode = ParamList("Pcode","NRML|BO|CNC|CO|MIS",0);
qty = Param("Quatity",100,0,100000,1);
AMO = "NO";

broker ="tj";
ver = "1.0"; 

EnableAlgo = ParamList("AlgoTrading","Disable|Enable",0); 
 
//Algomojo API data               
api_data ="{\"api_key\":"+ "\""+user_apikey+"\","+ "\"api_secret\":"+"\""+api_secret+"\","+"\"data\":"+"{\"stgy_name\":\""+stgy_name+"\",\"s_prdt_ali\":\""+s_prdt_ali+"\",\"Tsym\":\""+Tsym+"\",\"exch\":\""+exch+"\",\"Ttranstype\":\""+"B"+"\",\"Ret\":\""+Ret+"\",\"prctyp\":\""+prctyp+"\",\"qty\":\""+qty+"\",\"discqty\":\""+"0"+"\",\"MktPro\":\""+"NA"+"\",\"Price\":\""+"0"+"\",\"TrigPrice\":\""+"0"+"\",\"Pcode\":\""+Pcode+"\",\"AMO\":\""+AMO+"\"}}";


if(trigger AND EnableAlgo=="Enable")
{

_TRACE("Broker API Request : "+api_data);

headers = "Content-Type: application/json\r\n" +
          "Accept-Encoding: gzip, deflate\r\n"; // ALL headers in one string
          
//set the Headers all in once          
InternetSetHeaders(headers); 

//set the internet agent as Amibroker
InternetSetAgent("AmiBroker");

//Call the Broker API endpoint for PlaceOrder
ih = InternetPostRequest("https://"+broker+"api.algomojo.com/"+ver+"/PlaceOrder",api_data,1);



if( ih ) 
{ 
    while( ( resp = InternetReadString(ih ) ) != "" ) 
   { 
       _TRACE("Broker API Response : "+resp);
   } 
    
    InternetClose( ih ); 
} 
}

_SECTION_END();


_SECTION_BEGIN("Candle Plot with Axis");

SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 

_SECTION_END();
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

Interactive Brokers – Smart Order Chart Trading Module using…

The IB Controller is an interface designed to facilitate automatic trading with AmiBroker and Interactive Brokers (IB) TWS (Trader Workstation). It serves as a...
Rajandran R
8 min read

Introducing OpenAlgo V1.0: The Ultimate Open-Source Algorithmic Trading Framework…

OpenAlgo V1.0 is an open-source algorithmic trading platform to automate your trading strategies using Amibroker, Tradingview, Metatrader, Python etc. Designed with the modern trader...
Rajandran R
2 min read

[Live Coding Webinar] Build Your First Trading Bridge for…

In this course, you will be learning to build your own trading bridge using Python. This 60-minute session is perfect for traders, Python enthusiasts,...
Rajandran R
1 min read

Leave a Reply

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