Rajandran R Creator of OpenAlgo - OpenSource Algo Trading framework for Indian Traders. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Building Algo Platforms, Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in

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 Creator of OpenAlgo - OpenSource Algo Trading framework for Indian Traders. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Building Algo Platforms, Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in

Interactive Brokers – Smart Order Chart Trading Module using…

The IB Controller is an interface designed to facilitate automatic trading with AmiBroker and Interactive Brokers (IB) TWS (Trader Workstation). It serves as a...
Rajandran R
8 min read

Introducing OpenAlgo V1.0: The Ultimate Open-Source Algorithmic Trading Framework…

OpenAlgo V1.0 is an open-source algorithmic trading platform to automate your trading strategies using Amibroker, Tradingview, Metatrader, Python etc. Designed with the modern trader...
Rajandran R
2 min read

[Live Coding Webinar] Build Your First Trading Bridge for…

In this course, you will be learning to build your own trading bridge using Python. This 60-minute session is perfect for traders, Python enthusiasts,...
Rajandran R
1 min read

Leave a Reply

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