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.

PlaceOrder – Multi Broker Exectuion Code Snippets for Amibroker

7 min read

This tutorial explains how to build a button trading right from scratch and with a click of a button how you can send orders simultaneously to 4 brokers.

This tutorial explores the requirements for building a multi-broker execution module using Amibroker. Algomojo Multi-Broker Bridge is required to send orders to multiple brokers simultaneously.

Here are the Building Blocks of Multi Broker Execution Module

1)RequestTimedRefresh

RequestTimedRefresh(1, False); // Send orders even if Amibroker is minimized or Chart is not active

2)Get API Key and API Secret Key of Multiple Brokers with Short Code

. use the ParamStr function to receive the inputs of User API Key, User API secret key, Broker Short code. Broker Short code is used to identify which broker you are sending the order.

ab – Aliceblue , tj – Tradejini , zb – Zebu, en – enrich

Pass the Version of the API used. Currently, version 1.0 is used as the default version. In the future if Algomojo is getting upgraded to a higher version then this parameter will be helpful to migrate to newer versions without much of a coding change.

Algomojo API and Trading Bridges are designed with backward compatibility. This means even if the future if newer Algomojo API versions are released still the traders can make use of the older versions.

//Broker Authentication Parameters
user_apikey1 = ParamStr("user_apikey1","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Enter your API key here
api_secretkey1 = ParamStr("api_secretkey1","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Enter your API secret key here
user_apikey2 = ParamStr("user_apikey2","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Enter your API key here
api_secretkey2 = ParamStr("api_secretkey2","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Enter your API secret key here
user_apikey3 = ParamStr("user_apikey2","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Enter your API key here
api_secretkey3 = ParamStr("api_secretkey2","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Enter your API secret key here
user_apikey4 = ParamStr("user_apikey2","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Enter your API key here
api_secretkey4 = ParamStr("api_secretkey2","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Enter your API secret key here

broker1 = ParamStr("Broker Code1","tj"); //Broker Short code for Tradejini - tj
broker2 = ParamStr("Broker Code2","ab"); //Broker Short code for Aliceblue - ab
broker3 = ParamStr("Broker Code3","zb"); //Broker Short code for Zebu - zb
broker4 = ParamStr("Broker Code4","en"); //Broker Short code for Enrich - en
ver = ParamStr("version","1.0"); //Enter your API secret key here

3)Trading Parameters

The trading parameter section explains the list of parameters users have to send to their broker for example Exchange Type(NSE, NFO, BSE, MCX), Trading Symbol, order type(MKT, LMT,SL-MKT, SL-LMT), Order Retention Type, Product Code(NRML,MIS,BO,CO), Order Quantity, Order Disclosed Quantity, AMO Orders..etc

//Trading Parameters
s_prdt_ali = ParamList("product alias","BO:BO|CNC:CNC|CO:CO|MIS:MIS|NRML:NRML",3); //Product Alias
Tsym = ParamStr("Trading Symbol","RELIANCE-EQ"); //Symbol Name
exch = ParamList("Exchange","NFO|NSE|BSE|CDS|MCX|NCDEX|BFO|MCXSXFO|MCXSX",1); //Exchange
Ret = ParamList("Ret","DAY|IOC",0); //Retention
prctyp = ParamList("prctyp","MKT|L|SL|SL-M",0); // Pricetype
Pcode = ParamList("Product code","NRML|BO|CNC|CO|MIS",4); // Product Code
qty = Param("Quantity",40,0,100000,1); // Quantity
AMO = ParamList("AMO Order","NO|YES",0); //AMO Order
placeordertype = ParamList("Place Order On","Realtime|CandleCompletion",0); // Place Order Type
EnableAlgo = ParamList("Algo Mode","Disable|Enable|LongOnly|ShortOnly",0); // Algo Mode
stgy_name = ParamStr("Strategy Name","Test Strategy Chart"); // Strategy Name

4)Log Section and Static Variables declaration

static_name_ = Name()+GetChartID()+interval(2)+stgy_name;
static_name_algo = Name()+GetChartID()+interval(2)+stgy_name+"algostatus";
//StaticVarSet(static_name_algo, -1); 
GfxSelectFont( "BOOK ANTIQUA", 14, 100 );
GfxSetBkMode( 1 );
if(EnableAlgo == "Enable")
{
AlgoStatus = "Algo Enabled";
GfxSetTextColor( colorGreen ); 
GfxTextOut( "Algostatus : "+AlgoStatus+" ChartID = "+GetChartID() , 20, 40); 
if(Nz(StaticVarGet(static_name_algo),0)!=1)
{
_TRACE("Algo Status : Enabled"+" ChartID = "+GetChartID());
StaticVarSet(static_name_algo, 1);
}
}
if(EnableAlgo == "Disable")
{
AlgoStatus = "Algo Disabled"+" ChartID = "+GetChartID();
GfxSetTextColor( colorRed ); 
GfxTextOut( "Algostatus : "+AlgoStatus+" ChartID = "+GetChartID() , 20, 40); 
if(Nz(StaticVarGet(static_name_algo),0)!=0)
{
_TRACE("Algo Status : Disabled"+" ChartID = "+GetChartID());
StaticVarSet(static_name_algo, 0);
}
}
if(EnableAlgo == "LongOnly")
{
AlgoStatus = "Long Only";
GfxSetTextColor( colorYellow ); 
GfxTextOut( "Algostatus : "+AlgoStatus+" ChartID = "+GetChartID() , 20, 40); 
if(Nz(StaticVarGet(static_name_algo),0)!=2)
{
_TRACE("Algo Status : Long Only");
StaticVarSet(static_name_algo, 2);
}
}
if(EnableAlgo == "ShortOnly")
{
AlgoStatus = "Short Only";
GfxSetTextColor( colorYellow ); 
GfxTextOut( "Algostatus : "+AlgoStatus+" ChartID = "+GetChartID() , 20, 40); 
if(Nz(StaticVarGet(static_name_algo),0)!=3)
{
_TRACE("Algo Status : Short Only");
StaticVarSet(static_name_algo, 3);
}
}



resp1 = "";
resp2 = "";
resp3 = "";
resp4 = "";

5)Creating a Function for Buy Order with Voice Alert

function Buyorder()
{
	
    algomojo=CreateObject("AMAMIBRIDGE.Main");
    api_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+"\"}";
    resp1=algomojo.AMDispatcher(user_apikey1, api_secretkey1,"PlaceOrder",api_data,broker1,ver);
    resp2=algomojo.AMDispatcher(user_apikey2, api_secretkey2,"PlaceOrder",api_data,broker2,ver);
    resp3=algomojo.AMDispatcher(user_apikey3, api_secretkey3,"PlaceOrder",api_data,broker3,ver);
    resp4=algomojo.AMDispatcher(user_apikey4, api_secretkey4,"PlaceOrder",api_data,broker4,ver);
    StaticVarSet(static_name_+"buyCoverAlgo",1); //Algo Order was triggered, no more order on this bar
    _TRACE("Broker 1 : Tradejini , Strategy : "+ stgy_name +"AlgoStatus : "+ EnableAlgo +"Chart Symbol : "+ Name() +"  Trading Symbol : "+  Tsym +"  Quantity : "+ qty +"  Signal : Buy Signal  TimeFrame : "+ Interval(2)+"  Response : "+ resp1 +"  ChardId : "+ GetChartID() + " Latest Price : "+LastValue(C));
    _TRACE("Broker 2 : Aliceblue , Strategy : "+ stgy_name +"AlgoStatus : "+ EnableAlgo +"Chart Symbol : "+ Name() +"  Trading Symbol : "+  Tsym +"  Quantity : "+ qty +"  Signal : Buy Signal  TimeFrame : "+ Interval(2)+"  Response : "+ resp2 +"  ChardId : "+ GetChartID() + " Latest Price : "+LastValue(C));
	Say( "Order Placed" ); 
}

6)Creating a Function for Sell Order with Voice Alert

function Sellorder()
{
    algomojo=CreateObject("AMAMIBRIDGE.Main");
    api_data ="{\"stgy_name\":\""+stgy_name+"\",\"s_prdt_ali\":\""+s_prdt_ali+"\",\"Tsym\":\""+Tsym+"\",\"exch\":\""+exch+"\",\"Ttranstype\":\""+"S"+"\",\"Ret\":\""+Ret+"\",\"prctyp\":\""+prctyp+"\",\"qty\":\""+qty+"\",\"discqty\":\""+"0"+"\",\"MktPro\":\""+"NA"+"\",\"Price\":\""+"0"+"\",\"TrigPrice\":\""+"0"+"\",\"Pcode\":\""+Pcode+"\",\"AMO\":\""+AMO+"\"}";
    resp1=algomojo.AMDispatcher(user_apikey1, api_secretkey1,"PlaceOrder",api_data,broker1,ver);
    resp2=algomojo.AMDispatcher(user_apikey2, api_secretkey2,"PlaceOrder",api_data,broker2,ver);
    resp3=algomojo.AMDispatcher(user_apikey3, api_secretkey3,"PlaceOrder",api_data,broker3,ver);
    resp4=algomojo.AMDispatcher(user_apikey4, api_secretkey4,"PlaceOrder",api_data,broker4,ver);
    StaticVarSet(static_name_+"buyCoverAlgo",1); //Algo Order was triggered, no more order on this bar
    _TRACE("Broker 1 : Tradejini , Strategy : "+ stgy_name +"AlgoStatus : "+ EnableAlgo +"Chart Symbol : "+ Name() +"  Trading Symbol : "+  Tsym +"  Quantity : "+ qty +"  Signal : Sell Signal  TimeFrame : "+ Interval(2)+"  Response : "+ resp1 +"  ChardId : "+ GetChartID() + " Latest Price : "+LastValue(C));
    _TRACE("Broker 2 : Aliceblue , Strategy : "+ stgy_name +"AlgoStatus : "+ EnableAlgo +"Chart Symbol : "+ Name() +"  Trading Symbol : "+  Tsym +"  Quantity : "+ qty +"  Signal : Sell Signal  TimeFrame : "+ Interval(2)+"  Response : "+ resp2 +"  ChardId : "+ GetChartID() + " Latest Price : "+LastValue(C));
            
    Say( "Order Placed" );
}

7)Create Button Functions (Supports both old and new Amibroker Versions)

X0 = 20;
Y0 = 100;
X1 = 100;

LBClick = GetCursorMouseButtons() == 9;	// Click
MouseX  = Nz(GetCursorXPosition(1));		// 
MouseY  = Nz(GetCursorYPosition(1));		//

procedure DrawButton (Text, x1, y1, x2, y2, colorFrom, colorTo)
{
	GfxSetOverlayMode(0);
	GfxSelectFont("Verdana", 9, 700);
	GfxSetBkMode(1);
	GfxGradientRect(x1, y1, x2, y2, colorFrom, colorTo);
	GfxDrawText(Text, x1, y1, x2, y2, 32|1|4|16);
}
GfxSetTextColor(colorWhite);

8)Configure the Buy and Sell Buttons for Multi Broker Execution


if(EnableAlgo == "Enable")
{

	DrawButton("Buy", X0, Y0, X0+X1, Y0+30, colorGreen, colorGreen);
	CursorInBuyButton = MouseX >= X0 AND MouseX <= X0+X1 AND MouseY >= Y0 AND MouseY <= Y0+30;
	BuyButtonClick = CursorInBuyButton AND LBClick;
	
	DrawButton("Sell", X0, Y0+40, X0+X1, Y0+70, colorRed, colorRed);
	CursorInSellButton = MouseX >= X0 AND MouseX <= X0+X1 AND MouseY >= Y0+40 AND MouseY <= Y0+70;
	SellButtonClick = CursorInSellButton AND LBClick;
	
	if( BuyButtonClick AND StaticVarGet(Name()+GetChartID()+"buyAlgo")==0 ) 
	{
		BuyOrder();
		StaticVarSet(Name()+GetChartID()+"buyAlgo",1); 
	}
	else
	{
		StaticVarSet(Name()+GetChartID()+"buyAlgo",0);
	}
	if( SellButtonClick AND StaticVarGet(Name()+GetChartID()+"sellAlgo")==0 ) 
	{
		SellOrder();
		StaticVarSet(Name()+GetChartID()+"sellAlgo",1); 
	}
	else
	{
		StaticVarSet(Name()+GetChartID()+"sellAlgo",0); 
	}
	
	
	
	

}

_SECTION_END();

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = "");
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

Here is the fully functional Amibroker AFL code for button trading module with multi-broker execution.


Title = " ";

_SECTION_BEGIN("Button Trading For Old Amibroker Versions");

RequestTimedRefresh(1, False); // Send orders even if Amibroker is minimized or Chart is not active

//Broker Authentication Parameters
user_apikey1 = ParamStr("user_apikey1","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Enter your API key here
api_secretkey1 = ParamStr("api_secretkey1","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Enter your API secret key here
user_apikey2 = ParamStr("user_apikey2","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Enter your API key here
api_secretkey2 = ParamStr("api_secretkey2","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Enter your API secret key here
user_apikey3 = ParamStr("user_apikey2","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Enter your API key here
api_secretkey3 = ParamStr("api_secretkey2","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Enter your API secret key here
user_apikey4 = ParamStr("user_apikey2","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Enter your API key here
api_secretkey4 = ParamStr("api_secretkey2","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Enter your API secret key here

broker1 = ParamStr("Broker Code1","tj"); //Broker Short code for Tradejini - tj
broker2 = ParamStr("Broker Code2","ab"); //Broker Short code for Aliceblue - ab
broker3 = ParamStr("Broker Code3","zb"); //Broker Short code for Zebu - zb
broker4 = ParamStr("Broker Code4","en"); //Broker Short code for Enrich - en
ver = ParamStr("version","1.0"); //Enter your API secret key here



//Trading Parameters
s_prdt_ali = ParamList("product alias","BO:BO|CNC:CNC|CO:CO|MIS:MIS|NRML:NRML",3); //Product Alias
Tsym = ParamStr("Trading Symbol","RELIANCE-EQ"); //Symbol Name
exch = ParamList("Exchange","NFO|NSE|BSE|CDS|MCX|NCDEX|BFO|MCXSXFO|MCXSX",1); //Exchange
Ret = ParamList("Ret","DAY|IOC",0); //Retention
prctyp = ParamList("prctyp","MKT|L|SL|SL-M",0); // Pricetype
Pcode = ParamList("Product code","NRML|BO|CNC|CO|MIS",4); // Product Code
qty = Param("Quantity",40,0,100000,1); // Quantity
AMO = ParamList("AMO Order","NO|YES",0); //AMO Order
placeordertype = ParamList("Place Order On","Realtime|CandleCompletion",0); // Place Order Type
EnableAlgo = ParamList("Algo Mode","Disable|Enable|LongOnly|ShortOnly",0); // Algo Mode
stgy_name = ParamStr("Strategy Name","Test Strategy Chart"); // Strategy Name

static_name_ = Name()+GetChartID()+interval(2)+stgy_name;
static_name_algo = Name()+GetChartID()+interval(2)+stgy_name+"algostatus";
//StaticVarSet(static_name_algo, -1); 
GfxSelectFont( "BOOK ANTIQUA", 14, 100 );
GfxSetBkMode( 1 );
if(EnableAlgo == "Enable")
{
AlgoStatus = "Algo Enabled";
GfxSetTextColor( colorGreen ); 
GfxTextOut( "Algostatus : "+AlgoStatus+" ChartID = "+GetChartID() , 20, 40); 
if(Nz(StaticVarGet(static_name_algo),0)!=1)
{
_TRACE("Algo Status : Enabled"+" ChartID = "+GetChartID());
StaticVarSet(static_name_algo, 1);
}
}
if(EnableAlgo == "Disable")
{
AlgoStatus = "Algo Disabled"+" ChartID = "+GetChartID();
GfxSetTextColor( colorRed ); 
GfxTextOut( "Algostatus : "+AlgoStatus+" ChartID = "+GetChartID() , 20, 40); 
if(Nz(StaticVarGet(static_name_algo),0)!=0)
{
_TRACE("Algo Status : Disabled"+" ChartID = "+GetChartID());
StaticVarSet(static_name_algo, 0);
}
}
if(EnableAlgo == "LongOnly")
{
AlgoStatus = "Long Only";
GfxSetTextColor( colorYellow ); 
GfxTextOut( "Algostatus : "+AlgoStatus+" ChartID = "+GetChartID() , 20, 40); 
if(Nz(StaticVarGet(static_name_algo),0)!=2)
{
_TRACE("Algo Status : Long Only");
StaticVarSet(static_name_algo, 2);
}
}
if(EnableAlgo == "ShortOnly")
{
AlgoStatus = "Short Only";
GfxSetTextColor( colorYellow ); 
GfxTextOut( "Algostatus : "+AlgoStatus+" ChartID = "+GetChartID() , 20, 40); 
if(Nz(StaticVarGet(static_name_algo),0)!=3)
{
_TRACE("Algo Status : Short Only");
StaticVarSet(static_name_algo, 3);
}
}



resp1 = "";
resp2 = "";
resp3 = "";
resp4 = "";




function Buyorder()
{
	
    algomojo=CreateObject("AMAMIBRIDGE.Main");
    api_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+"\"}";
    resp1=algomojo.AMDispatcher(user_apikey1, api_secretkey1,"PlaceOrder",api_data,broker1,ver);
    resp2=algomojo.AMDispatcher(user_apikey2, api_secretkey2,"PlaceOrder",api_data,broker2,ver);
    resp3=algomojo.AMDispatcher(user_apikey3, api_secretkey3,"PlaceOrder",api_data,broker3,ver);
    resp4=algomojo.AMDispatcher(user_apikey4, api_secretkey4,"PlaceOrder",api_data,broker4,ver);
    StaticVarSet(static_name_+"buyCoverAlgo",1); //Algo Order was triggered, no more order on this bar
    _TRACE("Broker 1 : Tradejini , Strategy : "+ stgy_name +"AlgoStatus : "+ EnableAlgo +"Chart Symbol : "+ Name() +"  Trading Symbol : "+  Tsym +"  Quantity : "+ qty +"  Signal : Buy Signal  TimeFrame : "+ Interval(2)+"  Response : "+ resp1 +"  ChardId : "+ GetChartID() + " Latest Price : "+LastValue(C));
    _TRACE("Broker 2 : Aliceblue , Strategy : "+ stgy_name +"AlgoStatus : "+ EnableAlgo +"Chart Symbol : "+ Name() +"  Trading Symbol : "+  Tsym +"  Quantity : "+ qty +"  Signal : Buy Signal  TimeFrame : "+ Interval(2)+"  Response : "+ resp2 +"  ChardId : "+ GetChartID() + " Latest Price : "+LastValue(C));
	Say( "Order Placed" ); 
}

function Sellorder()
{
    algomojo=CreateObject("AMAMIBRIDGE.Main");
    api_data ="{\"stgy_name\":\""+stgy_name+"\",\"s_prdt_ali\":\""+s_prdt_ali+"\",\"Tsym\":\""+Tsym+"\",\"exch\":\""+exch+"\",\"Ttranstype\":\""+"S"+"\",\"Ret\":\""+Ret+"\",\"prctyp\":\""+prctyp+"\",\"qty\":\""+qty+"\",\"discqty\":\""+"0"+"\",\"MktPro\":\""+"NA"+"\",\"Price\":\""+"0"+"\",\"TrigPrice\":\""+"0"+"\",\"Pcode\":\""+Pcode+"\",\"AMO\":\""+AMO+"\"}";
    resp1=algomojo.AMDispatcher(user_apikey1, api_secretkey1,"PlaceOrder",api_data,broker1,ver);
    resp2=algomojo.AMDispatcher(user_apikey2, api_secretkey2,"PlaceOrder",api_data,broker2,ver);
    resp3=algomojo.AMDispatcher(user_apikey3, api_secretkey3,"PlaceOrder",api_data,broker3,ver);
    resp4=algomojo.AMDispatcher(user_apikey4, api_secretkey4,"PlaceOrder",api_data,broker4,ver);
    StaticVarSet(static_name_+"buyCoverAlgo",1); //Algo Order was triggered, no more order on this bar
    _TRACE("Broker 1 : Tradejini , Strategy : "+ stgy_name +"AlgoStatus : "+ EnableAlgo +"Chart Symbol : "+ Name() +"  Trading Symbol : "+  Tsym +"  Quantity : "+ qty +"  Signal : Sell Signal  TimeFrame : "+ Interval(2)+"  Response : "+ resp1 +"  ChardId : "+ GetChartID() + " Latest Price : "+LastValue(C));
    _TRACE("Broker 2 : Aliceblue , Strategy : "+ stgy_name +"AlgoStatus : "+ EnableAlgo +"Chart Symbol : "+ Name() +"  Trading Symbol : "+  Tsym +"  Quantity : "+ qty +"  Signal : Sell Signal  TimeFrame : "+ Interval(2)+"  Response : "+ resp2 +"  ChardId : "+ GetChartID() + " Latest Price : "+LastValue(C));
            
    Say( "Order Placed" );
}


X0 = 20;
Y0 = 100;
X1 = 100;

LBClick = GetCursorMouseButtons() == 9;	// Click
MouseX  = Nz(GetCursorXPosition(1));		// 
MouseY  = Nz(GetCursorYPosition(1));		//

procedure DrawButton (Text, x1, y1, x2, y2, colorFrom, colorTo)
{
	GfxSetOverlayMode(0);
	GfxSelectFont("Verdana", 9, 700);
	GfxSetBkMode(1);
	GfxGradientRect(x1, y1, x2, y2, colorFrom, colorTo);
	GfxDrawText(Text, x1, y1, x2, y2, 32|1|4|16);
}
GfxSetTextColor(colorWhite);

if(EnableAlgo == "Enable")
{

	DrawButton("Buy", X0, Y0, X0+X1, Y0+30, colorGreen, colorGreen);
	CursorInBuyButton = MouseX >= X0 AND MouseX <= X0+X1 AND MouseY >= Y0 AND MouseY <= Y0+30;
	BuyButtonClick = CursorInBuyButton AND LBClick;
	
	DrawButton("Sell", X0, Y0+40, X0+X1, Y0+70, colorRed, colorRed);
	CursorInSellButton = MouseX >= X0 AND MouseX <= X0+X1 AND MouseY >= Y0+40 AND MouseY <= Y0+70;
	SellButtonClick = CursorInSellButton AND LBClick;
	
	if( BuyButtonClick AND StaticVarGet(Name()+GetChartID()+"buyAlgo")==0 ) 
	{
		BuyOrder();
		StaticVarSet(Name()+GetChartID()+"buyAlgo",1); 
	}
	else
	{
		StaticVarSet(Name()+GetChartID()+"buyAlgo",0);
	}
	if( SellButtonClick AND StaticVarGet(Name()+GetChartID()+"sellAlgo")==0 ) 
	{
		SellOrder();
		StaticVarSet(Name()+GetChartID()+"sellAlgo",1); 
	}
	else
	{
		StaticVarSet(Name()+GetChartID()+"sellAlgo",0); 
	}
	
	
	
	

}

_SECTION_END();

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = "");
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.

VB Script for Placing Orders From Excelsheet to Algomojo…

This tutorial provides a sample VB Script code to place orders from the Algomojo Platform. Algomojo offers Free API + Free Trading Platform to...
Rajandran R
2 min read

How to use Postman to Send Orders to Your…

Postman is an API testing tool that started in 2012 as a side project by Abhinav Asthana to simplify API workflow in testing and...
Rajandran R
1 min read

What is Algomojo API?

Algomojo offers Free API + Free Trading Platform to algomojo users to Place, Modify, Cancel Orders. Currently, Algomojo API is free for the users...
Rajandran R
2 min read

6 Replies to “PlaceOrder – Multi Broker Exectuion Code Snippets for Amibroker”

      1. sir i have taken the API from algomojo. registration of the bridge exactly means what. Help me by explaining clearly. i have cleaned my system more than twice and rerun the installation and followed the steps exactly. Still the error persists

Leave a Reply

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