Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and 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. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in)

How to Automate your Strategy just by Adding Two lines of Code in Amibroker?

2 min read

Since the start of Algomojo, we are focusing on one thing “how to simplify the automated execution controls” – so that traders can easily convert their Buy or Sell trading strategy to automate their trading solutions faster. So started implementing simplified & open-source Amibroker libraries so that traders could connect their trading strategies by adding few lines of code and drastically reducing their coding time in implementing trading alerts, automation, trade connectivity dashboard & controls.

To start with Amibroker we started implementing four main execution modules. Download the Amibroker Open Source Libraries

1)Algomojo Chart Based Execution Module
2)Algomojo Smart Order Execution Module
3) Time-Based Order Execution
4)Split Order Execution to execute large orders

Requirements

1)Algomojo Account
2)Amibroker (6.0 or higher recommended)


1)Download the Library and Install as per the guidelines (Same AFL codes are provided in the link)

Download the Algomojo Amibroker Library

2)API Configuration Settings in Amibroker

 Go to Amibroker->Formulas->Include->Algomojo folder and Edit API.afl using AFL Editor. Enter the APIkey and API secret obtained from Algomojo->My API section

Here is a sample code to do smart order execution

How to Send Orders using Amibroker from the Charts?

Simplified Chart Based Automation Controls can be rendered in Amibroker just by adding two lines of code.

Here are the Two Lines of Code that needs to be added
1)Including Algomojo Charts library

//include the line at the top of your trading strategy code.
#include <algomojo/algomojocharts.afl>

2)Transmit Signals from Amibroker to Algomojo Connected Brokers


//Add the Code after the computation of Buy,Sell,Short,cover Signals
Algomojo(Buy,Sell,Short,cover);


If your strategy contains only Buy, Sell, and not the Short, Cover Signals then add the following code

Algomojo(Buy,Sell,0,0);

Algomojo Controls

Once the appropriate codes are added necessary strategy control parameters, dashboard controls and alert controls are automatically added and code is ready to perform automation once the AlgoMode Parameter is enabled

Sample AFL Code – Chart Based Trading

#include <algomojo/Algomojocharts.afl>


//Candle Plot and 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() ); 

//Controls
len1 = Param("Length1",20,1,100,1);
len2 = Param("Length2",50,1,100,1);

//Plot Functions
Plot(EMA(Close,len1),"EMA1",colorGreen, styleLine | styleThick);
Plot(EMA(Close,len2),"EMA2",coloryellow, styleLine | styleThick);


//Trading Rules
Buy = Cross(EMA(Close,len1), EMA(Close,len2)); //Positive EMA Crossover
Sell = Cross(EMA(Close,len2), EMA(Close,len1)); //Negative EMA Crossover

//Stop and Reverse

Short = Sell;
Cover = Buy;

//Non Repainting  - Signals happens only after the close of the current
Buy = Ref(Buy,-1);
Sell = Ref(Sell,-1);
Short = Ref(Short,-1);
Cover = Ref(Cover,-1);

/* Plot Buy and Sell Signal Arrows */
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

//Transmits Signals to Order
Algomojo(Buy,Sell,Short,Cover);

Start Enjoying the Controls, Reduce your code time, and start focusing on building your trading strategy.


What are the next simplified versions to be released?

We are currently working on execution modules like
1)Automated Trailing Stoploss / Trade Modification Modules
2)Fixed/Perc Stoploss and Target Modules
3)Futures to Options Execution Modules
4)Multi Legged Option Execution Modules
5)Bracket and Cover Order Stop and Reverse Intraday Modules
6)Limit Order with Time-based AutoCancellation Execution Modules
7)Limit Order Strategies with Autocancellation of orders
8)Limit Order Strategies with Combined Stops/Targets
9)Multi-Client Trade Execution
10)Multi-Broker Trade Execution

and more to come. Stay tuned!

Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and 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. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in)

[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

[Webinar] Understanding and Mitigating Curve Fitting in System Trading

"Understanding and Mitigating Curve Fitting in System Trading"! This dynamic session aims to equip novice to intermediate traders, quantitative analysts, and financial engineers with...
Rajandran R
1 min read

P-Signal Strategy Long Only Strategy – Amibroker AFL Code

This tutorial provides an overview of the P-Signal reversal strategy, a quantitative trading strategy that utilizes statistical parameters and error functions to generate probabilistic...
Rajandran R
2 min read

Leave a Reply

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