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.

Code Snippets – Plot Buy and Sell Arrows in Amibroker

57 sec read

AFL Tutorial : Beginners

Amibroker AFL script based trading system generally consist of four trading conditions Buy(go long), Sell(Exit Long), Short(go short) and Cover(Exit Short). In todays tutorial we are going to concentrate only how to plot a Buy Signal(Generally we Up arrow is preferred) and Sell Signal(Generally Down Arrow is preferred) using Amibroker.

 
The following Example discusses plotting arrows with simple EMA crossover trading system.

EMA Crossover with Simple Arrows

Buy and Sell Rules are defined as

EMA1 = EMA( C,20);
EMA2 = EMA( C,50);

/*Buy and Sell Condition */
Buy = Cross(EMA1,EMA2);
Sell = Cross(EMA2,EMA1);

This code snippet plots a plain vanilla simple Buy(Green) and Sell Arrows(Red) and this snippet should be pasted below the Buy and Sell Trading conditions in the AFL code.

Nifty Daily – Simple Arrows
Simple Arrows

/* Plot Buy and Sell Signal Arrows */
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );
GraphXSpace = 5;

The PlotShapes Functionality is generally used to plot shapes like Square,Arrows,Triangle,Circle,Digits etc., to indicate the trading conditions visually over/below the candlesticks. However the simple method is not preferred instead one can try with plotting Block Arrows for better user experience.

Download EMA Crossover Simple Arrows afl code

EMA Crossover with Block Arrows

The following code snippet plots a Block Arrows with Buy(Green) and Sell Arrows(Red) Signals and has better user experience when compared to simple arrow plots.

Nifty Daily – Block Arrows
Block Arrows

https://gist.github.com/816b61ebc2176055ea7163a56648eeaa

Download EMA Crossover Simple Arrows afl code

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.

What is QuantZilla?

Quantzilla is 75+ hours of code mentoring program designed for noncoders who want to learn the coding program right from designing indicators, scanners, trading...
Rajandran R
58 sec read

Things to Consider While Building a Bracket Order Execution…

Building a Bracket Order Strategy is the most demanded request we got from most of the algomojo traders. This article explains the list of...
Rajandran R
12 min read

PlaceOrder – Multi Broker Exectuion Code Snippets for Amibroker

This tutorial explains how to build a button trading right from scratch and with a click of a button how you can send orders...
Rajandran R
7 min read

8 Replies to “Code Snippets – Plot Buy and Sell Arrows in…”

  1. Dear Sir

    if my Red Line Cuts the Green Line several times Than how can we stop the system to take Multiple Positions

  2. I have written some ‘if/else if’ condition depending on price, from which I am getting trend. I am assigning this trend to buy and sell signals. After that I am display buy/sell signal and it is displaying correctly.
    After ExRem these buy/sell signals are becoming zero. why ? Could please suggest me.

  3. I have already sent the same request by mail and Mr. Rajendran asked me the whole code snippet. I have already sent it to him.

  4. Hello Sir,

    I would like to plot a square or a rectangle on the chart to indicate the candlestick patterns. For ex: If a bullish Engulfing pattern is formed on the chart, I would like to high light the pattern i.e. both candles by drawing a square on that pattern. Is that possible, if yes, then how can I achieve that? please help me on that.

    Thanks
    Tej

Leave a Reply

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