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.

Non Repainting Super Trend Indicator with Time Bar Left AFL code

2 min read

This is a new implementation of the SuperTrend indicator for Metatrader 4. The SuperTrend indicator is an application of the concept of MAE (maximum adverse excursion), which was introduced by John Sweeney in the mid-nineties.

The Non Repainting SuperTrend is particularly stable and has a few advantages over older version of SuperTrend indicators:

-It uses a moving (statistical) median of the arithmetic mean (High + Low)/2 of the bars instead of a moving average. The (statistical) median is known to be more robust than any average.

-It calculates both the Median and the ATR (average true range) 1 bar ago, whereas the original SuperTrend indicator takes the ATR and moving average of the current bar. If you use the current bar’s ATR, the current bar’s breakout is partly measured against its own range. This is particularly true, if the ATR period is short.

– Signals: The Non Repaiting SuperTrend indicator gives a reversal signal, when the bar closes on the other side of the stop line.

– Magnified Market Price added for instant check of current market price

– Time Bar Left code is added to the AFL code( No of seconds left for the new bar to begin)

Now Download Non Repainting Super 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 continuous losses the trading system can yield?
Since 2010 after backtesting with 5min data it is inferred that till to date 9 consecutive losses had occurred. Refer with Bactest results.

What is the Best Parameters 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?
Strictly 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.

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




 
_SECTION_BEGIN("SuperTrend");
SetBarsRequired(100000,0);
GraphXSpace = 15;
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("bkcolor",ColorRGB(0,0, 0)));
GfxSetBkMode(0); 
GfxSetOverlayMode(1);
SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));
Plot(C,"nPrice",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);

SetTradeDelays(1,1,1,1);


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

Factor=Param("Factor",4,1,10,0.1);
Pd=Param("ATR Periods",10,1,100,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]0) {
         flag=1;
      }
      else {
         flag=0;
      }
      
      if (trend[i]>0 && trend[i-1]<0) {
         flagh=1;
      }
      else {
         flagh=0;
      }
      
      if (trend[i]>0 && Dn[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 www.marketcalls.in" + " - " +  Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
 "  - " + Date() +" - "+"n" +EncodeColor(colorRed) +"Op-"+O+"  "+"Hi-"+H+"  "+"Lo-"+L+"  "+
"Cl-"+C+"  "+ "Vol= "+ WriteVal(V)+"n"+ 
EncodeColor(colorLime)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+"  ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+"  ","")+"n"+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 

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

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

Rajandran R Founder of Marketcalls and Co-Founder Algomojo. Full-Time Derivative Trader. Expert in Designing Trading Systems (Amibroker, Ninjatrader, Metatrader, Python, Pinescript). Trading the markets since 2006. Mentoring Traders on Trading System Designing, Market Profile, Orderflow and Trade Automation.

How to Automate your Strategy just by Adding Two…

Since the start of Algomojo, we are focusing on one thing how to simplify the Automated Execution controls so that traders can easily convert...
Rajandran R
2 min read

[Free Webinar] Starting Amibroker AFL Coding Right from the…

Interested in Creating your own indicators/Buy or Sell Trading System. Learn How to build your own trading system using Amibroker. If you are new...
Rajandran R
27 sec read

Angel Broking Multi-Client Amibroker Trading Module

Got frequent requirements from Angel Broking Customers to automate Amibroker based trading system where one single generation from charts could punch orders in multiple...
Rajandran R
6 min read

66 Replies to “Non Repainting Super Trend Indicator with Time Bar Left…”

  1. Rajandran sir,
    In your earlier post under ‘Optimised ST post ‘ , you mentioned accuracy to be 42%.

    But i feel with introduction of Non-repaint feature, accuracy and/or profit percentage is bound to inrease.

    Will u please share stats with non-repaint feature.If u mention in words with approx figures, it will also suffice instaed of Amibroker’s analysis.

    thanks

    1. @Meena : Even i case of non repainting indicator the accuracy is going to remain the same because to older version also takes decision based on the close of the bar. May be the Month of may is much trendier which gives a higher winning ratio and the sample size is very low when compared to a 3 year of backtesting period

  2. Hi , The Part about entry and exit based on these signals is clear, but what is not clear to me is, is this a Positional System , Intraday System is there a fixed Stop Loss and a Fixed Target price any clarity would help ?

    1. @Devansh.
      Currently it is just a buy when buy signal and sell when sell signal kind of trading system. So the risk are always carry forwarded for the next day. Iam trying to come up with a system which reduces carry forwarding risk.

      1. Sir,

        I am new follower and with in a weektime study i have become your fan. Sir You have mentioned that you are working to come up with a system which reduces carry forwarding risk can you inform if that is out now.

        God Bless,

        Regards,
        Harjot

  3. Hi Rajandara,

    Any such indicator for GCI MT4 instead of amibroker.

    Thanks

    Mitch

  4. dear raj
    If the entry rule is like entering on the break of the high/low of the signal candle several flop chances can be
    avoided. pl excuse me if am wrong
    for eg. on 18-5-2012 two such cases are there

  5. I tried your afl to load in Amibroker 5.2 version, but it is showing lot of errors, can you help to sort it out.
    it shows variable”entry” used being initialised, too many arguments etc, nearly 35 errors in total, why is it so?
    please help.
    regards

  6. Would like to know whether the AFL is applicable for both Nifty Future and Bank Nifty Future? If not, please share the respective AFLs. Thank you in advance

  7. Good Day
    Dear Rajandran
    Thanks a million for sharing this wonderful AFL
    Further Is it possible to identify and include sideways market condition in your.AFL.
    This will make your AFL supreme.
    Thx again and Best Wishes
    Ravi

  8. Hello Rajandran, nice work…..but i am using Metatrader platform……is that possible for you to post your Indicator in Mt4 format.

  9. Hi Rajandran,

    If it is not too much to ask, can you help me in initial parameters for ATR and Multiplier that could be useful for EOD.

    Thanks in advance.

  10. Since 2 to 3 days I am not able to see the NIFTY & BANK NIFTY live charts. Whether it is under modification. I used to trade depending on that signals. Will you please guide me.

    1. Currently Live Signals doesnt Supports < Internet Explorer Browser. Its better to use Mozilla Firexfox, Chrome, Opera, Safari (Mobile&Desktop) , Android Browsers

  11. Rajandran,

    I loaded your indicator into AmiBroker, compiled it before saving it and I get a lot of errors.

  12. Hi Rajandran,
    i would like to use your non repainting supertrend indicator but i use Metastock.Is there a way to translate it into MS language?

  13. does u have this indicator for metatrader also( super trend as show in figure above withlevels )

  14. dear sirm

    does u have this indicator for metatrader also( super trend as show in figure above withlevels )

  15. Dear rajendar,
    Thanks for sharing your supertrend indicator with us free…..can you please share multi trend box which appear in same afl?

  16. Dear sir,

    how to use Non Repainting Super Trend Indicator with Time Bar Left AFL code

  17. Why you are not responding to people who are asking for mt4 version of this indicator, simply let them know whether you have it or not?

  18. Thanks a lot.,., actually I was not aware about this post for downloading this indicator for the same. ThanX again

  19. Hi RAjandran bro,,,,

    Not working your latest supertrend indicator for amibroker , number of times triend, pls check it and tell me step step instruction so if anything mistake , will try to correct and like to use this indicator with box indication..

    Thanks
    Srj

  20. dear rajendran its sanjay here i m purely new for marketcalls, 2 weeks i will observer ur calls then i will think to enter into this commodity trade
    hope ur software works for me
    sanjay

  21. Dear Mr. Rajendran,

    Recently I visited AB on yahoogroup and read few messages. Few messages about getting Email alerts when a BUY/SELL signal is generated attracted my attention. But when went through all those messages, really could not get conclusive answer.

    Since we all know you are a genius, can you please shed some light on how one can get email alerts whenever signal is generated?

    Wait for your response.

    Regards,
    OSK

  22. Hi Rajendar,
    Thanks for sharing this AFL. I appreciate your effort on clarifying our questions.

    Could you clarify these questions:
    1) There are “3142” trades generated in the back test results you have attached. Have you included commission and slippage. As this could impact the trade results, could you let me know on what value you are choosing for this.
    2) As the signals are generated in 5 minutes charts, gap up and gap down against our position could erode the profit. If I understood your AFL correctly, it looks like you are carrying over positions to the next day. Will it be possible for you to modify the AFL to close the position at the end of the day.

    Regards,
    Subbugentleman

  23. Is targets are chosen arbitrary? what is the logic behind choosing the targets with 0.5%; 0.92% and 1.79% from the entry?

  24. non repainting super trend, I tried but no box of time left and traijing stop?

  25. Great master piece of Tec art Demostration from Rajan ,very much appricateable and its boom to inverstors

  26. We can see 3 message boxes for 5 mins, 15 mins & hourly charts. But same is not available for download. I would like to use 3 message boxes with 5 mins, 15 mins & 30 mins charts. Can you please make this AFL available for download?

  27. Hi Raj, i tried super trend for nifty 60min yearwise and observed that it is highly sensitive to volatility. For example, the cumulative return in 2012 was good, but in 2013 the returns were pathetic (even negative); this is because 2012 was less volatile and 2013 was more volatile and hence the parameters 3,10 or 2,11 or any other combination always changes as per the volatility of the underlying and it is difficult to predict volatility and change parameters at the start of the year. I believe the same holds true for gold as well. How can I address this issue?

  28. Hi,
    I used this afl and modified to write signal in file.
    But signals are getting repeated every time.
    Please suggest a way to avoid writing same signal again in file.
    I want to write each signal one time in file.
    How can i get this thing???

      1. I got solution by handling repeating bars…
        1 thing is only remaining that how to write Bar closing time value along with signal???
        I tried other function but that are writing Current time or Time where my mouse pointer is, not exact close time pf that particular bar….
        Please suggest if any way or function to get Bar close time….

  29. sir alot of ths to u, abv charts r usefull to me , but u r delete stochastic charts. ple mentioned it . its to usefull to me

  30. Hi,

    I tried this AFL. Looksgood.
    But, when i tried with Multiple Sheets/Tabs, The POP alert works only on Active TAB.
    May i know how to get alert from Inactive Sheets/TABs?

    Thanks in Advance
    Regards
    Ankita Stallion

  31. rajandran R sir, pls tell me how can idownload supertrend afl code for amibroker 5.60 and install in amibroker.

  32. hi sir,
    pls tell me how to put RIBBIN like Green or Red on non repainting super trend indicator with time bar left.
    so pls help sir…

  33. i just tried to load this on my amibroker and i’m getting lots of errors. I use Amibroker 5.60 version. Please help. Thanks!

  34. Hi …R
    This doesnt seem to work for me…i get error 30…syntax error….unexpected identifier….

    cheers

  35. can u please post last 5 to 8 ( profit / loss) trades in this afl please , its a going to be a good help

  36. How have you considered contract expiry days for Nifty Futures? Do you rollover to the next contract?

  37. hi sir after drag and drop the file it shows that the link in not properly getting …like that ..and it is not getting by email and etc..i tried by the tool settings also..so if u can kindly send me that supertrend indicator link through my email..thanks in asvance

  38. Hello Sir,

    In your supertrend indicators, is it possible to also draw the number of points each signal has made whether profit or loss. THis way it becomes easy to quickly glance the performance of the indicator directly on the chart without working out too much to capture data for backtesting. similar to https://www.mql5.com/en/forum/182267

Leave a Reply

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