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 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 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.

Virtual Trade Simulator Module Version 1.0 – Amibroker AFL…

Thought of launching a simple and user-friendly Virtual Trade Simulator to study/test your inner intuition before practicing in the live markets. Virtual Trade Simulator...
Rajandran R
3 min read

How to Fetch Trading Account Balance using Amibroker

Amibroker recently launched their Amibroker 6.4 version which comes with new Javascript engines with JSON native object support which is very much required to...
Rajandran R
2 min read

[Webinar ] System Trading using Amibroker

This course is for beginners who want to kickstart systematic trading and get some basics on building and backtesting trading systems and simple metrics...
Rajandran R
19 sec read

Leave a Reply

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