Quantcast
Channel: Market Calls
Viewing all articles
Browse latest Browse all 2070

How to Send Automated Orders without any Amibroker Bridge Installation?

$
0
0

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

The post How to Send Automated Orders without any Amibroker Bridge Installation? appeared first on Marketcalls.


Viewing all articles
Browse latest Browse all 2070

Trending Articles