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.

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

Leave a Reply

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