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

1 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 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.

AllinOneAlerts – Amibroker Alerts Module for Amibroker Users

AllinOneAlerts is one of the most important and most requested modules to bring all sorts of alerts with no extra coding efforts. Now even...
Rajandran R
5 min read

How to improve your Amibroker Algo Trading Execution Speed

When comes to Automated Trading speed of execution plays a dominant role in executing at better prices. Here I would like to list three...
Rajandran R
1 min read

Introduction to QuantZilla 2.0

QuantZilla is a 75+ hours of immersive coding mentor-ship program on designing trading systems, converting trading ideas into indicators and trading strategies, automating the...
Rajandran R
4 min read

Leave a Reply

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