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

Line Trading – OpenAlgo Automation Module for Amibroker Users

The line Trading Automation tool is designed for Manual traders who want to perform level-based trade execution faster and also bring some advanced trade...
Rajandran R
55 sec read

Mini Certification Course on Algorithmic Trading

Welcome to the Mini Certification on Algorithmic Trading using Amibroker and OpenAlgo! This comprehensive 4-part series is designed to equip you with the knowledge...
Rajandran R
1 min read

Pivot Reversal Strategy – Tradingview Pinescript to Amibroker AFL…

Pivot Reversal Strategy is a popular in-built strategy in Tradingview Platform. Here I had attempted to convert the pinescript v5 to Amibroker AFL Code....
Rajandran R
3 min read

Leave a Reply

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