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 Time Based Automated Orders using Algomojo?

1 min read

This video tutorial explores time-based automated order execution from Amibroker to Algomojo Platform. Generally, Time Based Execution is generally required to close your intraday orders on time or to do automated time-based options hedging to your positions.

You can download the Algomojo Time Based Order Execution Modules by logging into Algomojo-> Tools -> Amibroker Modules

Here is the step by step guidance on how to test Algomojo Time Based Execution Module

Algomojo Time Based Execution Module for Amibroker

//Algomojo Time Based Exection Module//



// Developer: Rajandran R (Founder - Marketcalls / Co-Founder - Algomojo)
// Date: 28-Oct-2020
// Website: algomojo.com / marketcalls.in



_SECTION_BEGIN("Algomojo Timing Module");

RequestTimedRefresh(1, False);

function GetSecondNum()
{
    Time = Now( 4 );
    return Time;
}

user_apikey = ParamStr("user_apikey","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Enter your API key here
api_secret = ParamStr("api_secret","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Enter your API secret key here
otime = ParamTime("Execution Time", "15:15:00", 0);
Otype = ParamList("Execution Type", "Buy|Sell",0);
s_prdt_ali = ParamList("s_prdt_ali","BO:BO|CNC:CNC|CO:CO|MIS:MIS|NRML:NRML",3); 
Tsym = ParamStr("Tsym","RELIANCE-EQ");
exch = ParamList("Exchange","NFO|NSE|BSE|CDS|MCX|NCDEX|BFO|MCXSXFO|MCXSX",1);
Ret = ParamList("Ret","DAY|IOC",0);
prctyp = ParamList("prctyp","MKT|L|SL|SL-M",0);
Pcode = ParamList("Pcode","NRML|BO|CNC|CO|MIS",4);
qty = Param("Quatity",40,0,100000,1);
AMO = ParamList("AMO","NO|YES",0);
Timedexecution = ParamList("Timed Order Execution", "Disable|Enable",0);
stgy_name = ParamStr("Strategy Name","Test Strategy Chart");
static_name = Name()+GetChartID()+interval(2)+stgy_name;

if(Timedexecution == "Enable")
{
SetChartBkColor(colorDarkGrey);
if(GetsecondNum() == otime AND StaticVarGet(static_name + otime) == 0)
{
    StaticVarSet(static_name + otime, 1);
    if( Otype == "Buy" )
    {
         algomojo=CreateObject("XLAMIBRIDGE.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+"\"}";
         resp=algomojo.AMDispatcher(user_apikey, api_secret,"PlaceOrder",api_data);
         _TRACE("Strategy : "+ stgy_name +"  Symbol : "+  Tsym +"  "+ Interval(2)+"  Response : "+ resp +"  ChardId : "+ GetChartID() + " Latest Price : "+LastValue(C));
    }
    if( otype == "Sell")
    {
         algomojo=CreateObject("XLAMIBRIDGE.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+"\"}";
         resp=algomojo.AMDispatcher(user_apikey, api_secret,"PlaceOrder",api_data);
         _TRACE("Strategy : "+ stgy_name +"  Symbol : "+  Tsym +"  "+ Interval(2)+"  Response : "+ resp +"  ChardId : "+ GetChartID() + " Latest Price : "+LastValue(C)); 
    }
    
}
else if(GetsecondNum() != otime)
{
     StaticVarSet(static_name + otime, 0);
}
}
_SECTION_END();


_SECTION_BEGIN("Price");
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