Super Trend – Intraday AFL code for Amibroker

by

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 see this charts live?
Yes you can observe the charts live amibroker charts for 5min nifty from tommorow onwards

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

Rajandran R

Rajandran is a trading strategy designer and founder of Marketcalls, a hugely popular trading site since 2007 and one of the most intelligent blog in the world to share knowledge on Technical Analysis, Trading systems & Trading strategies. More From Rajandran R »

112 comments… add one

  • sidharth May 5, 2012 at 5:59 pm edit

    Please share the corresponding mql4 for gcimt4 too……………

    Reply
  • dinesh May 5, 2012 at 6:06 pm edit

    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 .

    Reply
  • Rajandran R May 5, 2012 at 6:30 pm edit

    @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

    Reply
    • Nitin Agarwal January 17, 2013 at 12:14 pm edit

      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

      Reply
  • Rajandran R May 5, 2012 at 6:31 pm edit

    @Sidharth : Link is given in the first line of the article.

    Reply
  • shaggy May 5, 2012 at 6:35 pm edit

    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

    Reply
  • Harshit Patel May 5, 2012 at 6:50 pm edit

    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.

    Reply
  • Rajandran R May 5, 2012 at 7:01 pm edit

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

    Reply
  • sidharth May 5, 2012 at 7:21 pm edit

    @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

    Reply
  • Rajandran R May 5, 2012 at 7:42 pm edit

    @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);

    Reply
  • shaggy boo May 5, 2012 at 7:45 pm edit

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

    Reply
  • Rajandran R May 5, 2012 at 7:57 pm edit

    @Shaggy boo

    Share your chart image here. If you dont know how to post charts in the comment section read this
    http://www.marketcalls.in/web-updates/share-your-charts-and-youtube-videos-with-marketcalls.html
    This could help you

    Reply
  • vinay May 5, 2012 at 9:04 pm edit

    i would say only one thing “god bless U”….U r the lighthouse of traders like us…..

    Reply
  • Udit May 5, 2012 at 11:41 pm edit

    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 ?

    Reply
  • cambatta May 6, 2012 at 1:13 am edit

    We get different T1,T2,T3 for different time frames.

    I feel they should be the same.

    Reply
  • Rajandran R May 6, 2012 at 1:40 am edit

    @cambatta : Targets are decided based on the different timeframes

    Reply
  • P. SHAILU May 6, 2012 at 4:00 am edit

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

    Reply
  • Rajesh May 6, 2012 at 9:49 am edit

    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

    Reply
  • Nitin Gupta May 6, 2012 at 11:09 am edit

    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.

    Reply
  • rajesh May 6, 2012 at 12:18 pm edit

    @udit

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

    thanks

    Rajesh

    Reply
  • P Shailu May 6, 2012 at 1:40 pm edit

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

    Reply
  • Rajandran R May 6, 2012 at 1:41 pm edit

    @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

    Reply
  • Rajandran R May 6, 2012 at 1:47 pm edit

    @Rajesh

    Soon will add exploration parameters

    Reply
  • vellingirinathan May 6, 2012 at 2:05 pm edit

    sir super trend afl not working my sytem

    Reply
  • raghu May 6, 2012 at 2:29 pm edit

    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

    Reply
  • rajesh May 6, 2012 at 4:04 pm edit

    @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

    Reply
  • dinesh May 6, 2012 at 5:00 pm edit

    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.

    Reply
  • Udit May 6, 2012 at 8:10 pm edit

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

    Reply
  • Amirishali May 7, 2012 at 1:01 am edit

    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

    Reply
  • ajay choudhary May 7, 2012 at 11:00 am edit

    THERE IS ERROR IN SUPER TREND AFL. CAN U HELP I AM ATTACHING JPEG FILE.

    Reply
  • Mohsin May 7, 2012 at 11:30 am edit

    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

    Reply
  • shaggy boo May 7, 2012 at 12:12 pm edit

    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

    Reply
  • Mohsin May 7, 2012 at 2:58 pm edit

    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

    Reply
  • Udit May 7, 2012 at 7:30 pm edit

    Dear Rajandran,

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

    Reply
  • Udit May 7, 2012 at 7:30 pm edit

    Dear Rajandran,

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

    Reply
  • vasanth kalyana kumar May 7, 2012 at 7:31 pm edit

    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.

    Reply
  • dinesh sharma May 7, 2012 at 10:32 pm edit

    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

    Reply
  • arjun May 8, 2012 at 11:11 am edit

    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

    Reply
  • arjun May 8, 2012 at 11:21 am edit

    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

    Reply
  • arjun May 8, 2012 at 11:40 am edit

    Rajandran, yes take your own time.

    Reply
  • arjun May 8, 2012 at 12:13 pm edit

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

    Reply
  • Ramakrishnan May 8, 2012 at 12:26 pm edit

    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.

    Reply
  • Ramakrishnan May 8, 2012 at 12:27 pm edit

    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.

    Reply
  • Ramakrishnan May 8, 2012 at 12:35 pm edit

    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.

    Reply
  • Arvind May 8, 2012 at 3:56 pm edit

    pls add COPPER, LEAD, and ZINC in realtime

    Reply
  • Dj May 8, 2012 at 4:44 pm edit

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

    Reply
  • Mukesh Radia May 8, 2012 at 10:09 pm edit

    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

    Reply
  • Mukesh Radia May 8, 2012 at 10:20 pm edit

    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.

    Reply
  • Mukesh Radia May 8, 2012 at 10:25 pm edit

    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

    Reply
  • kalyan May 9, 2012 at 8:04 am edit

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

    Reply
  • Thanveer May 9, 2012 at 9:37 am edit

    Sir can u pls upload the version with magified price?

    Reply
  • P. SHAILU May 9, 2012 at 11:28 pm edit

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

    Reply
  • P. SHAILU May 9, 2012 at 11:33 pm edit

    HI

    SEE THIS IMAGE FOR AMI BROKER V. 5.1

    Reply
  • P. SHAILU May 15, 2012 at 11:56 am edit

    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

    Reply
  • Korath Kurian June 7, 2012 at 10:42 am edit

    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.

    Reply
  • Korath Kurian June 7, 2012 at 3:13 pm edit

    Thanks. Got the site.

    Can something like this be configured in icicidirect Traderacer software?

    Reply
  • Mithoon July 17, 2012 at 4:28 pm edit

    SUPER!!!!

    Reply
  • Ram July 19, 2012 at 1:43 pm edit

    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

    Reply
  • Swetal Shah July 22, 2012 at 12:58 pm edit

    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

    Reply
  • yogesh July 23, 2012 at 12:44 pm edit

    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

    Reply
    • Rajandran R July 23, 2012 at 1:37 pm edit

      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.

      Reply
  • arjun July 23, 2012 at 7:24 pm edit

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

    Reply
  • suraj August 5, 2012 at 10:54 pm edit

    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

    Reply
  • Rakesh August 6, 2012 at 12:02 am edit

    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

    Reply
  • shwetha August 17, 2012 at 10:55 am edit

    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

    Reply
    • suraj August 18, 2012 at 9:09 am edit

      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

      Reply
  • neeru August 19, 2012 at 3:57 pm edit

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

    Reply
  • TAM August 19, 2012 at 5:43 pm edit

    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.

    Reply
  • Kanwar September 1, 2012 at 12:56 pm edit

    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

    Reply
  • nileysh sane September 23, 2012 at 9:01 pm edit

    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

    Reply
  • Mithoon October 5, 2012 at 6:35 pm edit

    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?

    Reply
  • ash November 10, 2012 at 1:14 pm edit

    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?

    Reply
  • shrividhya s November 26, 2012 at 3:39 pm edit

    Hi,

    Can the Code of AFL be decoded to EXCELL SPREADSHEETs……

    Reply
  • Mani Gupta December 11, 2012 at 8:18 pm edit

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

    Reply
  • lalitkumar December 11, 2012 at 10:09 pm edit

    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

    ????

    Reply
  • Mani Gupta December 12, 2012 at 3:26 pm edit

    This is the image of the problem i’m facing.. plz help me out..

    http://imgur.com/3fy67

    http://imgur.com/gEHd7

    Plz tell me where my system is going wrong..

    Reply
  • Mani Gupta December 12, 2012 at 4:03 pm edit

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

    Reply
  • shrisha December 12, 2012 at 5:51 pm edit

    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

    Reply
  • Mani Gupta December 13, 2012 at 11:17 pm edit

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

    Reply
  • ashu December 28, 2012 at 10:03 pm edit

    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.

    Reply
  • veeresham January 8, 2013 at 4:40 pm edit

    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.

    Reply
  • ashu January 14, 2013 at 7:10 pm edit

    can you tell me what to change in afl code to make non repainting to repainting,

    Reply
  • anurag saini January 21, 2013 at 3:04 pm edit

    i want to configure super trend in amibroker 5.6 plz tell me how to do it

    Reply
  • rajesh March 5, 2013 at 7:55 pm edit

    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.

    Reply
  • ducanh March 6, 2013 at 1:18 pm edit

    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.

    Reply
  • deepak March 7, 2013 at 6:24 pm edit

    any FREE softwer live data provider

    Reply
  • K.M. Ravichandran March 11, 2013 at 8:19 pm edit

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

    Reply
  • Dick Hoierman March 14, 2013 at 11:56 pm edit

    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

    Reply
  • piyush March 18, 2013 at 6:39 pm edit

    rajandran ji,

    i backtested u superfrend on hourly on currect data. the backtest report gives sell whereas in chart its a buy. i had mailed u too abt the problem. how to solve it
    http://postimage.org/gallery/ah378v7e/

    Reply
  • Hoierman March 19, 2013 at 10:06 pm edit

    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

    Reply
  • Hoierman March 20, 2013 at 6:20 pm edit

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

    Dick

    Reply
  • vin April 5, 2013 at 8:48 am edit

    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

    Reply
  • vin April 5, 2013 at 1:37 pm edit

    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

    Reply
  • s April 10, 2013 at 2:11 am edit

    how to solve error 29 veriabl entry used without having been initialized
    plz help me

    Reply
  • Ravi May 1, 2013 (4 weeks ago) at 11:23 pm edit

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

    Reply
  • Mukund May 17, 2013 (2 weeks ago) at 12:26 am edit

    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.

    Reply

Leave a Comment

Recommend on Google