Super Trend – Intraday AFL code for Amibroker

Super trend is a popular mql strategy converted for the use of intraday amibroker Traders. And you can also watch the same indicator live with various instruments like Nifty , MCX Metals and for few stocks here

Features of the Super Trend AFL code

- Buy and Sell Signals(Green and Red Arrows)
- Trailing stop loss : For Buy signal trailing stop loss is displayed in Green color and for Sell it is Red color
- Template Displaying Buy/Sell Price, Trailing stop loss, Current profit.
- Target Lines T1,T2,T3 (Targets are just a rough estimation and to add value to the AFL code. Its not prediction based)
- Suits lower timeframes like 5min,1min, 15min, hourly timeframe.
- As usual Code is open source. Any body can use it, modify and reuse it.

Nifty Futures 15min charts

Watch Super Trend Trailer

Download Non Repainting Super Trend Indicator with time bar left AFL code

For Amibroker version less than 5.3 version

Download Super Trend for Old Amibroker Version

Trend Indicator with the new feature seconds left for the new bar to begin.

I would like each and everyone to go thro the nature of SuperTrend Optimized trading system

- To be honest the trading system accuracy is currently at 42% means out of 100 trades only 42 trades are profitable.

Then how does your wealth is created?
It created with discipline and proper money management to catch those 42% of Winning Trades and Exiting properly at Stop Loss Hits.

What is the maximum continious losses the trading system can yield?
Since 2010 after backtesting with 5min data it is inferred that till to date 9 consecuitve losses had occured. Refer with Bactest results.

What is the Best Paramters to fine tune the system to eliminate more whipsaws?
Optimized Parameters are Multiplier =2 and ATR=11. However the default values of trading system are Multiplier =3 and ATR=10.

For Which Instrument the Trading System is Optimized?
The Trading system is optimized for 5min Nifty Futures charts

Can i trade with Any other stocks/indices?
Stricly No. As the Trading system is optimized for 5min Nifty future charts only.

How to Enter and Exit?

Entry should be based on the completion of the close of 5min Bar Candle. Trade should be executed with 5secs once the 5min candle complete. Trade should not be executed before the completion of 5min bars.

Trade Should be taken only if you see the next bar open. And Strictly not at the intermediate points between the signals.

How many Nifty Future Lots is required to Trade the Trading system?
2 Lots (100 shares) of Nifty at any trades. Size of the trade should not vary throughout the trading system and it is fixed.

Can i trade using the live Buy or Sell indicator?
Charts shown in marketcalls is to study the nature of the trading system to improve your knowledge on trading system. If you are trading based on these buy and sell signals then do it at your own risk. marketcalls wont be responsible for the losses incurred.

Backtest Results
Super Trend Optimized Backtest Results from 1st Jan 2010 – 25th March 2012

Many hours has been spent on making this final code. So give your feedbacks here or mail to rajandran@marketcalls.in

Happy Trading!
Rajandran R
Founder – Marketcalls

Related Readings and Observations

Comments

  1. dinesh says

    Good innovation rajendra .Now a days I am daily visiting to your blog and spending atleast 20 min in a day .
    and your blog is indian wikipedia in indian market .I would like to know how to test this code .

  2. says

    @Dinesh : You need to do backtesting. Goto New Analysis ->Select the AFL file -> Set the Backtesting parameters ->Press backtest button->Click on the report button to view the test results.

    Any How will post short article soon on how to backtest using amibroker

    • Nitin Agarwal says

      sir iam from bareilly u.p sir i had lost huge amount in mcx now iam in great prolem. sir please help me sir please suggest me that which software i should use to cover my losses, i dont know much about software system and how to use them but ihad a knowledge of physical market. my weaknness is i dont know where to put stopploss and where to take profit. sir please suggest me that i should go for which software. which will have the best results, iwill be very gratefull to you

  3. shaggy says

    Greetings Brother….

    At the out set GOD BLESS YOU & YOUR FAMILY… before i give you the performance feedback of your AFL,
    I would like to give a feedback on your SELFLESS EFFORTS towards people from trading fraternity…
    RARE is the word for a person like you.. its a very humble work your are doing on the this space here…
    you will definitely get rewarded for all your support to all of us in one or the other way in your life…
    i will keep clicking all the adds on your site everyday as part of my support… thanks for everything…

    Coming back to AFL performance, i just checked the levels where the signals are generated and stunningly
    all are same when it compare to my PAID software…. what else we need??? people make life out of your site
    and bless you through their hearts…

    Great Work
    Take Care

    Shaggy Boo
    Bangalore

  4. Harshit Patel says

    Hey Raj,

    Wanted to ask you a Question, If someone needs to learn the basics of Amibroker and how to use that, where can we find Tutorials or guide on that.

  5. says

    @Harshit Patel

    You need to be clear what you are going to learn

    1) Do you want to Build your own trading system -- Then you need programming langugage skills to proceed. You can go to the amibroker website and download the AFL guide and proceed with that.

    2)Other wise if you want to test your own trading system and to optimize it then tutors are available in amibroker website itself.

  6. sidharth says

    @Rajandran…….that link gives a code but that does not have any buy sell signal…..etc. Also probably there are different settings…there are more whipsaws….can u please update the settings to the same as your AFL code

  7. says

    @Sidharth : Yes the mql4 doesnt has any signal.

    The default parameters are Factor = 3 and ATR=10 and you can change those parameters for your requirement.

    Factor=Param(“Factor”,3,1,10,1);
    Pd=Param(“ATR Periods”,10,1,100,1);

  8. shaggy boo says

    the last 3 signals(showing on the pic) are same in my software and let me instal the AFL and check it with Ami…

  9. Udit says

    DEAR RAJANDRAN,

    CAN YOU TELL ME WHICH AFL CODE IS USED IN THIS CHART ? IT’S LOOKING VERY GOOD. IS IT POSSIBLE TO MAKE THIS TYPE OF AFL CODE ?

  10. P. SHAILU says

    AS FAR AS THE SUPER TREND INDICATOR IS CONCERNED ERROR 29 IS WHAT I AM FACING IT SAYS
    VARIABLE ‘ENTRY’ USED WITHOUT BEING INITIALIZED.

  11. Rajesh says

    Excellent Code !!

    Can you modify the AFL code to include the output for exploiration so that we can get parameters for all stocks in excel

  12. Nitin Gupta says

    Hi Rajandran,

    I checked the supertrend, it is not working on 15 minutes timeframe ( not profitable :result (-19.24%)). whereas
    on the 5 minute timeframe, it is giving too many calls, may be some refining on the calls like some filters would help it to be better… have u thought of including volume as an indicator for filtering calls.

  13. rajesh says

    @udit

    if you can tell us which system is generating this signal then we can try for it…

    thanks

    Rajesh

  14. P Shailu says

    Looks very nice but giving error ‘LINE 29 VARIABLE “ENTRY ” USED NOT BEING INITIALIZED PLS HELP

  15. says

    @Nitin Gupta :

    What is your backtesting period?

    I had backtested for 3 years and the results are good and descent . If you want i can share with you

  16. raghu says

    sir i am new to trading… need help…. installed amibroker… and RTDS data for REAL time data…
    amibroker is showing NO data in it… how i would link the RTDS data to amibroker… amibroker data file is empty…
    RTDS has generated all its data in amibroker format and located a file at C:\NSEFUTURESAMI and ther is an other file at C:\Program Files\RTDS

    how i can make this data linked with my amibroker and how can i make my chart look like your chart in the video,,, please help

    thanks … raghu

  17. rajesh says

    @Udit

    if its from Nexgen Revolution then the entire AFL is Based of Fimb…

    hope you have not back tested it yet…
    you can check the levels on the same day…. if others then please specify so that we arrive at AFL…
    see the image

  18. dinesh says

    Rajendra :-Could you please explain how to test this code .I am very new in amibroker .This can be help for all naw user to explore this new area .If you have any such usefull link then please share us .I tried to dig out from google but not succicde.

  19. Udit says

    @ Rajesh,

    I got its image only from tradaerji.com I am not sure which AFL code are use. But I think it is heikein ashi chart and plot with zigzag indicator. I think it’s B/S signal generate after 4/5 candle (reprint signal). So it is useless.

  20. Amirishali says

    Rajandran….as usual,you are on cherryon top of the cream…let me test this.but as per ur glorious record…it should be fine.
    God Bless you for your selfless & tireless efforts!!!

    Amirishali

  21. Mohsin says

    Hi sir,

    please sir kindly give us a solution , i am using amibroker 5.20 and getting error 29 --
    variable ‘entry’ used without being initialized .. …

    please please -- this super trend afl is looking so good , thanks to you, but not able to use it because of error — please help

  22. shaggy boo says

    Dear Raj…

    is it possible to make an alert out to show the list of all latest alerts generate through this AFL?

    is yes please let us know how to do it?

    regards

    shaggy boo

  23. Mohsin says

    Sir, the afl is giving error 29.

    variable ‘ entry’ used without being initialized ,
    please help,

    this looks so good, but because of error not able to use it ,

    my amibroker ver 5.2

    thanks for your great work, but please help with this error soon,

    cant wait to see it working fast

  24. Udit says

    Dear Rajandran,

    First so many thanks for this super trend AFL. Today its give amazing result in nifty. Good job, keep it up.

  25. Udit says

    Dear Rajandran,

    First so many thanks for this super trend AFL. Today its give amazing result in nifty. Good job, keep it up.

  26. vasanth kalyana kumar says

    Dear Rajandran

    I downloaded your super trend afl and used it. its very useful. Thanks a lot. More over i want to appreciate and say thanks to your SELFLESS EFFORTS.

  27. dinesh sharma says

    Dear Rajendra

    Can you please tell me how can we conver Mql4 to Afl Or Afl in Mql for . Can u please guide me in this

  28. arjun says

    Hi Rajandran,
    i am unable to backtest. Will u pls share backtesting reults for couple months depending on timeframe.
    And most important, on which which timeframe best results are seen….5min or 15 min.

    pls revert back

  29. arjun says

    hi
    i don’t understand how my recent post has vanished Hence posting again.
    Rajandran i am unable to backtest.Wil u pls share backtesting resuts for couple month.
    And on which timeframe best results are seen? 5min or 15 min

  30. arjun says

    Rajandran, one more thing. As most of us are intraday aspirant traders/players.
    In your backtesting, my sense you will be giving arithmetic of plain entry and exit calcuations and returns and cumulative points etc. But it will be better if u can also add how many instances call was able to get xyz points, the bare minium points at which most of day traders look as first target.Some take as 15 or 20 or 25 depending on their mindst and brokerage.
    Today, Nifty FUTURE as per super trend gave a sell @5103 09.45 and reverse long came at 5106 11.10. So at first glance, it was a loss of 3 points. But there was a dip to 5072 means was a chnce of booking 15/20/25 points depending on persoanl first target level.I am aware of super trend’s T1/T2/T3. But i am talking about bare minium first target.Also you are welcome with analysis of supertrend’s T1/T2 achieved.

    Hope u get my point..

  31. Ramakrishnan says

    Sir,

    I am using Amibroker 5.1. Today I have add your Super Trend Afl Code in my Amibroker 5.1 ver but it is showing error 29. Sir pls rectify and give at your earliest will me a Great needfull, also for Mr.Ajay choudhary & Mr.Mohsin. Expecting your reply very eagerly. Bye.

  32. Ramakrishnan says

    Sir,

    I am using Amibroker 5.1. Today I have add your Super Trend Afl Code in my Amibroker 5.1 ver but it is showing error 29. Sir pls rectify and give at your earliest will do me a Great needfull, also for Mr.Ajay choudhary & Mr.Mohsin. Expecting your reply very eagerly. Bye.

  33. Ramakrishnan says

    Sir

    I am using Amibroker 5.1 Ver. I am very much impressed by your Super Trend Afl Code and added in my Amibroker 5.1 Ver but it is giving error 29. Hence pls rectify & give at your earliest will do me a Great Needfull. Thank you. Bye.

  34. Dj says

    Hi Is This System Look In To Future Like Other System If Yes Then It’s Useless To Do Backtest And Use In Realtime

  35. Mukesh Radia says

    Hi Rajandran R

    Many Of My Friends Using SuperTrend (ATR Length 5,ATR Multiplier 1,HighLow Bars 5) of FALCON software
    and i heard it gives excelant result and narrow stoploss for nifty and Banknifty (30Minites) Time Frame. And as per their record it gives highest return in backtest also

    I Tried Same Parameters In Amibroker in Your Super Trend afl file But it is not giving the same signals,

    I am encloseing niftycash5min.jpg file for your referance

    Hoping your early reply with best solution.
    Thanks

  36. Mukesh Radia says

    Hi Rajandran R
    I Was serching supertrend formula for my amibroker since last 2 months i found best formula from your site.
    Many Of My Friends Useing Supertrend System (ATR Length 5days, ATR Mulitiplier 1 , Highlow Bar 5)
    For Nifty / Bank nifty in 30 miniutes time frame and it gives best result with narrow stoploss.

    I Change Parameters as per above mention in amibroker. But its not giving same indication as falcon software is giving. I enclosed please find nifty cash 5 min.jpg file for your referance.

  37. Mukesh Radia says

    Hi Rajandran R
    I Was serching supertrend formula for my amibroker since last 2 months i found best formula from your site.
    Many Of My Friends Useing Supertrend System (ATR Length 5days, ATR Mulitiplier 1 , Highlow Bar 5)
    For Nifty / Bank nifty in 30 miniutes time frame and it gives best result with narrow stoploss.

    I Change Parameters as per above mention in amibroker. But its not giving same indication as falcon software is giving. I enclosed please find nifty cash 5 min.jpg file for your referance.

    Hopeing your best solution for the same

  38. kalyan says

    many thanx for this afl, its near pro afl. now in parameter what to set for factor from 1,2,3

  39. P. SHAILU says

    HI,
    I HAVE JUST MIXED YOUR OLD & NEWER {FOR OLDER VERSIONS} AFL FOR SUPER TREND B’CAUSE THE NEWER VERSION WAS NOT SHOWING MASSAGE BOARD CHECK OUT & REPLY

    /* Done by Rajandran R */
    /* Author of http://www.marketcalls.in */

    _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();

    /* Done by Rajandran R */
    /* Author of http://www.marketcalls.in */

    _SECTION_BEGIN(“SuperTrend”);
    SetBarsRequired(100000,0);
    GraphXSpace = 15;
    SetChartOptions(0,chartShowArrows|chartShowDates);

    Plot( C, “Close”, ParamColor(“Color”, colorBlack ), styleNoTitle | ParamStyle(“Style”) | GetPriceStyle() );

    _N(Title = StrFormat(“{{NAME}} -- {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}”, O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

    PositionSize = 100000;

    Factor=Optimize(“Factor”,3,2,10,1);
    Pd=Optimize(“ATR Periods”,10,1,20,1);
    Up=(H+L)/2+(Factor*ATR(Pd));
    Dn=(H+L)/2-(Factor*ATR(Pd));
    iATR=ATR(Pd);
    TrendUp=TrendDown=Null;
    trend[0]=1;
    changeOfTrend=0;
    flag=flagh=0;

    for (i = 1; i Up[i-1]) {
    trend[i]=1;
    if (trend[i-1] == -1) changeOfTrend = 1;

    }
    else if (Close[i]<Dn[i-1]) {
    trend[i]=-1;
    if (trend[i-1] == 1) changeOfTrend = 1;
    }
    else if (trend[i-1]==1) {
    trend[i]=1;
    changeOfTrend = 0;
    }
    else if (trend[i-1]==-1) {
    trend[i]=-1;
    changeOfTrend = 0;
    }

    if (trend[i]0) {
    flag=1;
    }
    else {
    flag=0;
    }

    if (trend[i]>0 && trend[i-1]0 && Dn[i]<Dn[i-1]){
    Dn[i]=Dn[i-1];
    }

    if (trend[i]Up[i-1])
    { Up[i]=Up[i-1];
    }

    if (flag==1)
    { Up[i]=(H[i]+L[i])/2+(Factor*iATR[i]);;
    }
    if (flagh==1)
    { Dn[i]=(H[i]+L[i])/2-(Factor*iATR[i]);;
    }
    if (trend[i]==1) {
    TrendUp[i]=Dn[i];
    if (changeOfTrend == 1) {
    TrendUp[i-1] = TrendDown[i-1];
    changeOfTrend = 0;
    }
    }
    else if (trend[i]==-1) {
    TrendDown[i]=Up[i];
    if (changeOfTrend == 1) {
    TrendDown[i-1] = TrendUp[i-1];
    changeOfTrend = 0;
    }
    }
    }

    Plot(TrendUp,”Trend”,colorGreen);
    Plot(TrendDown,”Down”,colorRed);

    Buy = trend==1;
    Sell=trend==-1;

    Buy=ExRem(Buy,Sell);
    Sell=ExRem(Sell,Buy);
    Short=Sell;
    Cover=Buy;

    BuyPrice=ValueWhen(Buy,C);
    SellPrice=ValueWhen(Sell,C);
    ShortPrice=ValueWhen(Short,C);
    CoverPrice=ValueWhen(Cover,C);

    Title = EncodeColor(colorWhite)+ “Super Trend AFL code from http://www.marketcalls.in” + ” -- ” + Name() + ” -- ” + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
    ” -- ” + Date() +” -- “+”
    ” +EncodeColor(colorRed) +”Op-”+O+” “+”Hi-”+H+” “+”Lo-”+L+” “+
    “Cl-”+C+” “+ “Vol= “+ WriteVal(V)+”
    “+
    EncodeColor(colorLime)+
    WriteIf (Buy , ” GO LONG / Reverse Signal at “+C+” “,””)+
    WriteIf (Sell , ” EXIT LONG / Reverse Signal at “+C+” “,””)+”
    “+EncodeColor(colorYellow)+
    WriteIf(Sell , “Total Profit/Loss for the Last Trade Rs.”+(C-BuyPrice)+””,””)+
    WriteIf(Buy , “Total Profit/Loss for the Last trade Rs.”+(SellPrice-C)+””,””);

    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(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
    PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
    PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

    TrendSL=IIf(trend==1,TrendUp,TrendDown);

    for(i=BarCount-1;i>1;i--)
    {
    if(Buy[i] == 1)
    {
    entry = C[i];
    sig = “BUY”;
    sl = TrendSL[i];
    tar1 = entry + (entry * .0050);
    tar2 = entry + (entry * .0092);
    tar3 = entry + (entry * .0179);

    bars = i;
    i = 0;
    }
    if(Sell[i] == 1)
    {
    sig = “SELL”;
    entry = C[i];
    sl = TrendSL[i];
    tar1 = entry -- (entry * .0050);
    tar2 = entry -- (entry * .0112);
    tar3 = entry -- (entry * .0212);

    bars = i;
    i = 0;
    }
    }
    Offset = 20;
    Clr = IIf(sig == “BUY”, colorLime, colorRed);
    ssl = IIf(bars == BarCount-1, TrendSL[BarCount-1], Ref(TrendSL, -1));
    sl = ssl[BarCount-1];

    Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), “”, Clr, styleLine|styleDots, Null, Null, Offset);
    Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), “”, Clr, styleLine|styleDots, Null, Null, Offset);
    Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), “”, Clr, styleLine|styleDots, Null, Null, Offset);

    //Plot(LineArray(bars-Offset, sl, BarCount, sl,1), “”, colorDarkRed, styleLine|styleLine, Null, Null, Offset);
    //Plot(LineArray(bars-Offset, entry, BarCount, entry,1), “”, colorGreen, styleLine|styleLine, Null, Null, Offset);

    for (i=bars; i <BarCount;i++)
    {
    PlotText(""+sig+"@"+entry, BarCount+1,entry,Null,colorBlue);
    PlotText("T1@"+tar1,BarCount+3,tar1,Null,Clr);PlotText("T2@"+tar2,BarCount+3,tar2,Null,Clr);PlotText ("T3@"+tar3,BarCount+3,tar3,Null,Clr);

    }

    messageboard = ParamToggle("Message Board","Show|Hide",1);
    if (messageboard == 1 )
    {
    GfxSelectFont( "Tahoma", 13, 100 );
    GfxSetBkMode( 1 );
    GfxSetTextColor( colorWhite );

    if ( sig =="BUY")
    {
    GfxSelectSolidBrush( colorBlue ); // this is the box background color
    }
    else
    {
    GfxSelectSolidBrush( colorRed ); // this is the box background color
    }
    pxHeight = Status( "pxchartheight" ) ;
    xx = Status( "pxchartwidth");
    Left = 1100;
    width = 310;
    x = 5;
    x2 = 290;

    y = pxHeight;

    GfxSelectPen( colorGreen, 1); // broader color
    GfxRoundRect( x, y -- 98, x2, y , 7, 7 ) ;
    GfxTextOut( ( "Marketcalls -- Supertrend"),13,y-100);
    GfxTextOut( (" "),27,y-100);
    GfxTextOut( ("Last " + sig + " Signal came " + (BarCount-bars-1) * Interval()/60 + " mins ago"), 13, y-80) ; // The text format location
    GfxTextOut( ("" + WriteIf(sig =="BUY",sig + " @ ",sig + " @") + " : " + entry), 13, y-60);
    GfxTextOut( ("Trailing SL : " + TrendSL + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"), 13, y-40);
    /*GfxTextOut( ("TGT:1 : " + tar1), 13, y -80);
    GfxTextOut( ("TGT:2 : " + tar2), 13,y-60);
    GfxTextOut( ("TGT:3 : " + tar3), 13,y-40);*/
    GfxTextOut( ("Current P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2)), 13, y-22);;

    }

    _SECTION_END();

  40. P. SHAILU says

    SIR I WANT ONE MORE HELP FROM YOU. AS I TOLD YOU I DID LITTLE BIT EDITING OF YOUR BOTH SUPER TREND VERSIONS FOR BORD DISPLAY BUT FOR THE LOWER VERSION IT SHOWS NOTHING IN PARAMETER BOX SO IF I HAVE TO CHANGE ATR LINE OR MULTIPLIER I HAVE TO GO TO AFL CANT EDIT IT FROM PARAMETERS WINDOW PLS HELP … OR DO REPLY A.S.A.P.

    THNX IN ADVANCE

  41. Korath Kurian says

    Hi Rajendran,

    Am new to intraday trading in Nifty futures and Bank Nifty futures.
    Been watching your Super Trend live charts. ( not working today though !)
    Am very impressed with the results. How can I get this onto y desktop?
    Am on icicidirect Traderacer.

    Advance thanks, best regards.

  42. Korath Kurian says

    Thanks. Got the site.

    Can something like this be configured in icicidirect Traderacer software?

  43. Ram says

    Dear Rajandran,

    Very much inspired by your work and the help you are providing to all. I m new to the amibroker and I have version 5.2. I downloaded the .afl from this page, but after running the same, I m not able to get the same kind of graph which you have mentioned or the one that is shown in the youtube. Can you pls send me the .afl code to my mail address, dotone555@gmail.com. Thanks in advance.

    Regards
    Ram

  44. Swetal Shah says

    Hi,

    I would want to use this AFL code in my newly purchased Amibroker software.
    Sorry to bother but can some one reply or email (swetalshah99@gmail.com) on how to add this .zip file or any other AFL code (.txt) into my Amibroker and start using / testing it?
    I would highly appreciate your support / help in this regard.

    Thanks.
    Swetal

  45. yogesh says

    Hi Rajandran,

    Super trend is working fine with MT platform. I have one query, can we predict a trend, either up or down, will go for a long time so that we can put our position in that to get maximum return. OR can we get signal of trend reversal few sticks earlier so that we can close out current position and quit so that we could not trap in reverse trend, losing our profit. If yes please tell.

    Thank you for super SUPERTREND

    Yogesh

    • says

      Its tough to predict even a structured market in lower timeframes where you dont know when it reacts and when it turns/twists its direction. Its tough to predict a sideways market though prediction tools like Elliot Wave, GANN are available. But the problem is that the risk involved in such system are tough to evaluated.

  46. arjun says

    @ Swetal
    From your amib upper tool bar click on ‘Formula Editor’ ( icon resembles hammer) and just copy paste that code from text file and save that AFL to desired sub- folder under Formuals.

  47. suraj says

    Hi
    please tell me how to install amibroker and how to add AFL and after done all things, how to run real time data free as can do in mt4..

    hope you will guide me step by step

    Thanks

  48. Rakesh says

    Very very thanks Rajandra for your code. I have recently purchased Amibroker Professional and made and tried many system, But today i found your super trend and I visualize it on 3-min IEOD data of Nifty future and found excellent.

    But when I back tested I found it giving negative results can you please tell me what position size, periodicity and equity, margin and brokerage to be used when backtesting to get original results as we see in the charts.

    I am going to trade your system for next month and I am sure will get huge profit, obviously with my own risk.

    Once again very thanks for your help.

    Rakesh

  49. shwetha says

    hi mr.rajendra am a s/w engg. student i want to learn creating such s/w so can you tell me which programming language and platform used to built Amibroker Software .AFL thanks

    • suraj says

      Hi All friends
      I just like to know step by step how to install amibroker and after that how to use this indicator and main part that how to get real time data free to run this indicator…

      Hope I will get my solution….

      thaks

  50. neeru says

    i wanna to buy supertrend afl software for option and mcx…………plz tell me from where and with charges……….

  51. TAM says

    Average True Range (ATR)
    Introduction

    Developed by J. Welles Wilder, the Average True Range (ATR) is an indicator that measures volatility. As with most of his indicators, Wilder designed ATR with commodities and daily prices in mind. Commodities are frequently more volatile than stocks. They were are often subject to gaps and limit moves, which occur when a commodity opens up or down its maximum allowed move for the session. A volatility formula based only on the high-low range would fail to capture volatility from gap or limit moves. Wilder created Average True Range to capture this “missing” volatility. It is important to remember that ATR does not provide an indication of price direction, just volatility.

    Wilder features ATR in his 1978 book, New Concepts in Technical Trading Systems. This book also includes the Parabolic SAR, RSI and the Directional Movement Concept (ADX). Despite being developed before the computer age, Wilder’s indicators have stood the test of time and remain extremely popular.
    True Range

    Wilder started with a concept called True Range (TR), which is defined as the greatest of the following:

    Method 1: Current High less the current Low
    Method 2: Current High less the previous Close (absolute value)
    Method 3: Current Low less the previous Close (absolute value)

    Absolute values are used to ensure positive numbers. After all, Wilder was interested in measuring the distance between two points, not the direction. If the current period’s high is above the prior period’s high and the low is below the prior period’s low, then the current period’s high-low range will be used as the True Range. This is an outside day that would use Method 1 to calculate the TR. This is pretty straight forward. Methods 2 and 3 are used when there is a gap or an inside day. A gap occurs when the previous close is greater than the current high (signaling a potential gap down or limit move) or the previous close is lower than the current low (signaling a potential gap up or limit move). The image below shows examples of when methods 2 and 3 are appropriate.

    ATR -- True Range Image

    Example A: A small high/low range formed after a gap up. The TR equals the absolute value of the difference between the current high and the previous close.

    Example B: A small high/low range formed after a gap down. The TR equals the absolute value of the difference between the current low and the previous close.

    Example C: Even though the current close is within the previous high/low range, the current high/low range is quite small. In fact, it is smaller than the absolute value of the difference between the current high and the previous close, which is used to value the TR.
    Calculation

    Typically, the Average True Range (ATR) is based on 14 periods and can be calculated on an intraday, daily, weekly or monthly basis. For this example, the ATR will be based on daily data. Because there must be a beginning, the first TR value is simply the High minus the Low, and the first 14-day ATR is the average of the daily TR values for the last 14 days. After that, Wilder sought to smooth the data by incorporating the previous period’s ATR value.

    Current ATR = [(Prior ATR x 13) + Current TR] / 14

    -- Multiply the previous 14-day ATR by 13.
    -- Add the most recent day’s TR value.
    -- Divide the total by 14

    ATR -- Spreadsheet

    Click here for an Excel Spreadsheet showing the start of an ATR calculation for QQQQ.

    In the Spreadsheet example, the first True Range value (.91) equals the High minus the Low (yellow cells). The first 14-day ATR value (.56)) was calculated by finding the average of the first 14 True Range values (blue cell). Subsequent ATR values were smoothed using the formula above. The spreadsheet values correspond with the yellow area on the chart below. Notice how ATR surged as QQQQ plunged in May with many long candlesticks.

    ATR -- Chart 1

    For those trying this at home, a few caveats apply. First, ATR values depend on where you begin. The first True Range value is simply the current High minus the current Low and the first ATR is an average of the first 14 True Range values. The real ATR formula does not kick in until day 15. Even so, the remnants of these first two calculations linger to slightly affect ATR values. Spreadsheet values for a small subset of data may not match exactly with what is seen on the price chart. Decimal rounding can also slightly affect ATR values.
    Absolute ATR

    ATR is based on the True Range, which uses absolute price changes. As such, ATR reflects volatility as absolute level. In other words, ATR is not shown as a percentage of the current close. This means low priced stocks will have lower ATR values than high price stocks. For example, a $20-30 security will have much lower ATR values than a $200-300 security. Because of this, ATR values are not comparable. Even large price movements for a single security, such as a decline from 70 to 20, can make long-term ATR comparisons impractical. Chart 4 shows Google with double digit ATR values and chart 5 shows Microsoft with ATR values below 1. Despite different values, their ATR lines have similar shapes.

    ATR -- Chart 4

    ATR -- Chart 5
    Conclusions

    ATR is not a directional indicator, such as MACD or RSI. Instead, ATR is a unique volatility indicator that reflects the degree of interest or disinterest in a move. Strong moves, in either direction, are often accompanied by large ranges, or large True Ranges. This is especially true at the beginning of a move. Uninspiring moves can be accompanied by relatively narrow ranges. As such, ATR can be used to validate the enthusiasm behind a move or breakout. A bullish reversal with an increase in ATR would show strong buying pressure and reinforce the reversal. A bearish support break with an increase in ATR would show strong selling pressure and reinforce the support break.
    SharpCharts

    Listed as “Average True Range”, ATR is on the Indicators drop-down menu. The “parameters” box to the right of the indicator contains the default value, 14, for the number of periods used to smooth the data. To adjust the period setting, highlight the default value and enter a new setting. Wilder often used 8 period ATR. SharpCharts also allows users to position the indicator above, below, or behind the price plot. A moving average can be added to identify upturns or downturns in ATR. Click “advanced options” to add a moving average as an indicator overlay. Click here for a live example of ATR.

  52. Kanwar says

    I have Amibroker 5.5 and Super trend AFL.IT work fine i can see buy sell signal But It shows Error 29 when i scan..so i am not able to scan the signal at right time can you please help how to rectify that?
    thanks in advance

  53. nileysh sane says

    Hi,
    Sir in sacnning supper trend i am getting error like }

    }

    Offset = 20;

    Clr = IIf(sig =
    ————--^

    Error 29.
    Variable ‘sig’ used without having been initialized.

    How can i solve this pls explain me.

    Thanx

  54. Mithoon says

    Couls you please advice on how to code for exiting all open position by eod ,i was given
    no_trading = TimeNum() > 152000;
    Buy = ..your rules AND NOT no_trading;
    Sell = ..your rules… OR no_trading;
    But it does not work,any suggestions?

  55. ash says

    Hi Raj

    Installed your super trend today, the first time when manshi rt opened amibroker it showed the box on the left side where you inform last buy/sell call sl etc. I closed amibroker lot of pain went in actually getting odin data in amibroker and finally data came in to amibroker. Your buy sell is also appearing for previous day. But today (saturday) is not getting updated.

    My question is does your code not work on Saturday ??. Does it work only on weedays? Also I am trying to use your indicator for commodities, will that be a problem?

    I also have another question, is it not possible for your code logic to be somehow put directly in ODIN?

  56. Mani Gupta says

    Error 29: variable ‘entry’ used without having been initialsed.. Line 217 column 75 showing error sir.. can u help

    GfxTextOut( (“Current P/L : ” + WriteVal(IIf(sig == “BUY”,(C-entry),(entry-C)),2.2)), 13, y-22);;

  57. lalitkumar says

    please give me the correct afl for supertrend . bec currently i see the image for supper trend …. stop loss are not correct …

    example : sell 540 tr 530 sl 542 this is correct

    currently i see the sell trade sell 540 tr 530 sl 538

    ????

  58. Mani Gupta says

    I’m using manshiRT demo for data & having 5 days of backfill data.. used with all the commodities same error showing.. Or u can explain any method of using the afl as I haven’t used any before..

  59. shrisha says

    I tried the supertrend AFL Code,but i do get error of entry variable not initialized

    I went through the forum there was not solution given to that problem :(

    version : 5.6 latest

  60. Mani Gupta says

    I’m also using Amibroker 5.6.. there is no solution anywhere.. I have given the images of the error.. plz sort it out.. nothing is helping.. plz enlighten.. Ur video above is only showing bar replay..
    Is there any other video which can help in this error.. plz give d link..

  61. ashu says

    Hi Raj

    first of all god bless you for coming up the afl code, i know as you said accuracy is about 42% or whatever the figure is, however i just want to say that now either i get out at cost or maybe 1 or 2 ticks above my cost either way i am not losing money. earlier i used to take heavy losses now atleast my losses have come down. god bless u once again. making money is in your fate, if i make good if i dont its not fate, but with ur afl code atleast i wont lose a lot.

  62. veeresham says

    Sir,
    The Super Trend AFL code is it valid only for intraday using Amibroker? Can you provide Super Trend AFL code for Short Term(1-3 weeks) and long term (1-3 months) Periods. Iam very much thankful to you.

  63. rajesh says

    SIR, At present i am using ticker plants super trend, in which multiplier is 3 and period is 10.would you suggest 2 and 11 instead of 3 and 10.

  64. ducanh says

    Thank Rajandran for the useful code of super trend. Sir, when I used the function “new analysis” to scan the categories, an error, namely “Error 29. Variable ‘entry’ used without having been initialized. (Ln: 217,Col:75) ocurred. I used “Non Repainting Super Trend Indicator” for Amibroker, version 5.5. Please help me correct the error. Many thanks.

  65. K.M. Ravichandran says

    Sir, I am Ravi from Erode, I like your amibroker chart. I like to contact you I want your cell No. Please reply immediately.

  66. Dick Hoierman says

    I ran into your program on the AB Yahoo Group site but it was not your entire version but one posted by Ed Pottasch. I am not a day traded but a EOD trader. The formula appeared to target changes in Trend which I want to use as trade signals in trading ETF’s long/short (pairs trading) . There are over 100 Long/Short ETF Pairs.
    I would appreciate if you could send me the necessary changes to the program so it will work on a EOD basis. I especially like the PopUP (red) but it is useless with current time periods so a change to daily would be most appreciated. Thanks
    Dick

    Dick

  67. Hoierman says

    Raj,
    This is in follow up to my recent post. I find the Super Trend formula (without the red message board and black background to be more accurate on trend Buy/Sell arrows than the aforementioned newer one. This is based on the long/short silver ETF’s (USLV & DSLV) Why so? As I presume same basic formula used.
    I do like the “Message board” box but would like to get version (tell me how to change) so that daily time period rather than minutes or seconds. Your help on this will be most appreciated. Thanks

    Dick Hoierman
    areehoi@yahoo.com

  68. Hoierman says

    Thanks Raj,
    I’m using 5.60.3 version … which works fine. Will look forard to Dashboard for Daily.

    Dick

  69. vin says

    Your super trend formula for amibroker is excellent -- the only drawback for me is that it is an automated formula system, and also to change the parameters I have to use the edit function. It would be great if you can make a minor modification wherein we can change the settings in the parameters menu. Unfortunately I am not skilled in programming.
    I would also like to know how to plot only the lines of the supertrend on to the price chart itself with an ability to change the parameters from the parameter menu

  70. vin says

    OOps , I am using the older version of the code, but I would still like to plot only the lines on the bar charts. please do help.
    thank you,
    vin

  71. Ravi says

    Dear Raj,
    You are Outstanding man!!!!I am soft engineer and i was just trying to understand the Super Trend AFL code it is fantastically presented but I have one doubt in you code basically i was just trying out first in Excel by creating same set of variables you have created in it. The only doubt I am having is while initializing the values of first time againt Dn and UP variable what should I set also similarly what should be initialize value for Dn-1 and Up-1 since there will not be any values against it. I would appreciate if you help me out in resoving thsi issue. If need I can attache my excel sheet …..pls help!!!

  72. Mukund says

    Sir,
    I have checked this afl for current nifty future. This is not working now (going in loss). Can you tell me why it is now not working?

    Thanks in advance.

  73. Akhilesh says

    Hi Rajandran,

    The code gives an error at line 217 col 75 that “entry” is not initialized. Could you please let me know the fix for it??
    Thanks for advance!!

  74. Amul Pandya says

    You are a great guy helping us. Your backtesting shows results for futures, Can I use the same AFL for options data ? Would it have the similar results ? What will be the changes I would have to make to the AFL script, if any ?

  75. mitesh panchal says

    I’m getting below error. please help. I’m using amibroker 5.4 rc2 version.

    Error 29.
    Variable ‘sig’ used without having been initialized.

  76. Kannan says

    Raj, I tried the supertrend strategy on Nifty 5Mins for the period August 2012 to July 2013 with the same parameter of 2 and 11. The strategy has lost 8% during this period against 11% gain on Nifty (this is excluding the cost). I also tried with Nifty 60 Mins and Gold 60 and 5 Mins, the results are not satisfactory as the strategy lost money in most cases. Does this strategy really work? Has any one traded on live basis and made money? How can I improvise the strategy so that it really makes money in real trading.

    • says

      @Kannan : The Finetuned parameters for Nifty futures is 3 and 7 in 5min. And backtest should be done with atleast with 2-3 years of data to look into the actual result. with three or four month of backtesting we can judge the entire strategy performance.

      • Kannan says

        @ Raj, may be my trade logic needs to be corrected. I buy when current close is greater than previous supertrend value and vice versa for sell; no stop as it a toggle. Is this logic correct? Also, what is the optimized parameters for Nifty 60Mins?

  77. Pravin M says

    hii,
    what is default name of the array used for storing the price’s of intraday stocks ? So i can use it while coding my strategies. I know I am asking very basic question but I am quite new to use this.Please help me.

  78. Amul says

    I saw your backtesting results for NIFTY Future. At what price do you book the profits in the backtesting ? Do you book first lot at first target and second lot at trailing stop loss ?

  79. Priya says

    Dear Raj sir,

    Thnks a lot very much for your supertrend.
    I tried back testing MCX crude oil with your back testing video reference for the five months data in 2010 but its giving negative results.May be i m doing some wrong can you pls asssit me in this or is it possbile for you to share the back test results.

    Regards
    Priya

  80. Kannan says

    Hi Raj,
    In the newer version, your magnified market price is behind the background. Is it because of the layer? How can i bring it to front? Also, your message box is invisible. Do the code need to be update incorporating the zorder? How can this be displayed? Pls suggest.

  81. SHANKAR says

    Dear Mr.Rajendran,
    I would like to Buy AMIBROKER software and also I need SUPER TREND . Will you help me in this regards. I look forward your favourable reply at the earliest.

    Kind regards,
    Shankar,

  82. siddesh TM says

    i have amibroker,i want super trend to trade in nifty/banknifty,please send me details,

    HARE KRISHNA
    Siddesh TM
    9900162253

  83. RoshanRJ says

    Dear Mr.Rajendran,
    Even I would like to Buy AMIBROKER software and also I need SUPER TREND . Will you help me in this regards. the same msg which Shankar send you before. Pls, I look forward your favourable reply at the earliest.

  84. Raj says

    Dear Rajendran,

    Can you please share me the super trend excel formula.
    I would like to calculate it thru excel. Please help me.

  85. SIVA says

    Dear Mr.Rajendran,
    I would like to Buy AMIBROKER software and also I need SUPER TREND . Will you help me in this regards. I look forward your favourable reply at the earliest.

    Kind regards,
    SIVA

  86. Akhilesh says

    Hi Rajendran,

    I have modified the Super trend, and signals are reversed if the High/Low touches the TrendUp/TrendDown line. I have done this to achieve 2 things.

    a) Reducing the Slippage (As the Stoploss order is already with server and there is no delay when the signal is generated and order execution. This is helpful in volatile markets.)

    b) I can trade multiple scripts at the same time as my automated trading system will not work when the multiple orders are generated at the same time.

    Further some of the features are:
    1) I am using the ATR -6 and Multiplier-4 and 10 min TF

    2) I keep trailing the Stoploss as mentioned in step 1.

    3) My setup is fully automated and runs on the VPS.

    Last 3 months I am not getting good results. I would like to know if I am doing anything wrong?
    Can you share the performance of the ST used by you for last 3 months?

  87. bharat says

    I want only last trade signals in Alert Output window.I am using following code.But it is not giving desired results.Pl. see image and correct the code.
    barcomplete = BarIndex() < LastValue(BarIndex());

    AlertIf( barcomplete AND (Buy OR Short), "", "Text", 1+8 );

    regards

    bharat

Leave a Reply

Your email address will not be published. Required fields are marked *