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.

SDA2 Trend Trading System – AFL code

53 sec read

SDA2 Trend Trading system is nothing but a trend trading system made using Standard Deviation(SD) and ATR(2) – Average True range. This is just the variation of the AFBI Channel Trading system with a better performance and backtesting results.

Nifty Daily Charts

[click on the picuture for Bigger Charts -Older Chart has been replaced with the new one due to historical data discrepancy]

 
The Above chart is for Educational Purpose only not for any kind of Buy or Sell Recommendation in Nifty

Channel has been Built using the following formula

Derived=MA(((H+L)/2)+(O-C),3);
Upper=(Derived+StDev(Derived,7))+ATR(2)/1.5;
Lower=(Derived-StDev(Derived,7))-ATR(2)/1;

And the Colour of the Candlestick will be toggled between Green and Red each time when it breaks the Upper Channel or the Lower Channel.

1)Candlestick turn green if the Candle stick breaks and closes above the Upper Channel which indicates the buy signal

2)Candlestick turn red if the Candle stick breaks and closes above the Lower Channel which indicates the sell signal

3)The stop loss for the Buy Signal is the lower Channel and the stop loss for the Sell Signal is the Upper Channel

The following code is use to toggle the Candlestick colour between Green/Red

color=IIf(BarsSince(Cross(Lower,C))>BarsSince(Cross(C,Upper)), colorBrightGreen,colorRed);
Plot(C,””,Color,64);

Further Buy or Sell Signals, Scanning Functionality and Exploration has been added to the AFL code as usual

Download the AFL code for SDA2 Trend Trading System

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

20 Replies to “SDA2 Trend Trading System – AFL code”

  1. Once again a great work done sir, hats off to you 🙂

    Sir can you help me with one thing, as its not possible to adjust all the stocks which have been splitted so is there any way one can arrange all the shares which have been splitted from the beginning till date, how can that be done sir?

    Any Afl to scan the circuit limits also plz?

    Thanks eagerly waiting for a reply

    Tc

    1. @Akki : Sure if i found any interesting work will update it here. Also iam trying to make database wil completely split/bonus adjusted will present here
      soon

      AFL to scan Circuit limits? What do you mean by that… already circuit limits are fixed by nseindia for each and every stock.
      I guess the data is available in nseindia itself. Why should one have to scan for circuit limits?

  2. Gm Sir Have a Nice Day, thx a lot for a quick reply sir, Sir by the Circuit scanner I meant to say that as you said the limits for circuits are available for each share in nse site, but wanted to make a scanner which can scan the closing price with the circuit filter point, and if the stock is near to uc then a yes option can be prompted on the share, is it possible with amibroker, or in excel, if I am able to get the whole list of circuit bands of all the shares, then I may work on an excel sheet….

    Can you provide me the list of bands of the circuits on all the shares sir in nse and bse both.

    And last thing sir, from where can i get 1 min and 5 min data of stocks and indexes?

    ThanksSir KeepRocking

    Have a Niceday

  3. yes in next data base ,pls see that the nse database can be updated with joy,s datadownloader and data base can be created outside c volume.

  4. Thx a lot sir 🙂

    Sir is it possible that during market hours we get the stocks which are hitting new highs and lows on intervals of 1 min in nse?

    This is a very good thing which must be there on the site sir, would request you to find some solution to this and make a stock screen er which can screen the stocks hitting new highs and lows on 1 min intervals

    Thx Sir

  5. Sir one more help can you provide a exploration afl for pivot and camrilla levels generation, which can be used on auto analysis and the camrilla and pivot levels can be plotted for all the shares which we select.

  6. Sir I found the Afl for camrilla here is the code

    _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”, colorBlack ), styleNoTitle | ParamStyle(“Style”) | GetPriceStyle() );
    _SECTION_END();

    _SECTION_BEGIN(“Volume At Price”);
    PlotVAPOverlay( Param(“Lines”, 300, 100, 1000, 1 ), Param(“Width”, 5, 1, 100, 1 ), ParamColor(“Color”, colorCycle ), ParamToggle(“Side”, “Left|Right” ) | 4*ParamToggle(“Z-order”, “On top|Behind”, 1 ) );

    _SECTION_END();
    _SECTION_BEGIN(“Camrilla”);

    A=Ref(O,0);
    B=Ref(H,0);
    D=Ref(L,0);
    E=Ref(C,0);
    F=ATR(2);
    G=((100*F)/E);
    Pivot=((A+B+D+E)/4);
    range=B-D;
    H1=C+((range*(1.1*G))/12);
    H2=C+((range*(1.1*G))/6);
    H3=C+((range*(1.1*G))/4);
    H4=C+((range*(1.1*G))/2);
    H5=C+((range*(1.1*G))/1);
    L1=C-((range*(1.1*G))/12);
    L2=C-((range*(1.1*G))/6);
    L3=C-((range*(1.1*G))/4);
    L4=C-((range*(1.1*G))/2);
    L5=C-((range*(1.1*G))/1);
    Filter=1;
    AddColumn(range,”Range”,1.2,colorDefault,colorDefault,-1);
    AddColumn(F,”ATR”,1.2,colorDefault,colorDefault,-1);
    AddColumn(G,”ATR %”,1.2,colorDefault,colorDefault,-1);
    AddColumn(E,”Close”,1.2,colorDefault,colorGold,-1);
    AddColumn(Pivot,”Pivot”,1.2,colorGold,colorBlue,-1);
    AddColumn(H5,”H5″,1.2,colorDefault,colorDefault,-1);
    AddColumn(H4,”H4″,1.2,colorGold,colorBlue,-1);
    AddColumn(H3,”H3″,1.2,colorGold,colorRed,-1);
    AddColumn(H2,”H2″,1.2,colorDefault,colorDefault,-1);
    AddColumn(H1,”H1″,1.2,colorDefault,colorDefault,-1);
    AddColumn(L1,”L1″,1.2,colorDefault,colorDefault,-1);
    AddColumn(L2,”L2″,1.2,colorDefault,colorDefault,-1);
    AddColumn(L3,”L3″,1.2,colorGold,colorBlue,-1);
    AddColumn(L4,”L4″,1.2,colorGold,colorRed,-1);
    AddColumn(L5,”L5″,1.2,colorDefault,colorDefault,-1);

    _SECTION_END();

    Hope I am able to benefit all the family members 🙂

  7. Dear sir,

    I stumbled across this blog where I find both you and the members to be very helpful. thanks to you all. I am new to Amibroker. Could someone kindly show me how to create an AFL file from the above code? Thanks

  8. DEAR SIR I M TRADER AND I M USING AMIBROKER FOR TAKE MY TRADES
    SIR MY REQUEST TO U CAN U PLZ MAKE A AFL CODE FOR AMIBROKER . USING
    StochasticK AND Stochastic D CROSSOVE BUY SELL ARROW SIGNAL.
    SO PLZ DO IT SIR I NEED IT .IF U DO IT FOR ME THEN I VERY THANKFULL TO U
    SO PLZ SEND IT TO ME ON MY MAIL
    MY MAIL ID IS
    niftystar@rediffmail.com

  9. Scanning Functionality and Exploration has been added to the AFL
    means in the EOD can it give the scanned names of stocks came under buy signal
    from the list (derived from the eod data of getbhavcopy into ami)

Leave a Reply

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