How to Reveal anaSuperTrendU11 Trend Direction? - NinjaTrader Programming | futures io social day trading
futures io futures trading


How to Reveal anaSuperTrendU11 Trend Direction?
Updated: Views / Replies:5,246 / 31
Created: by aventeren Attachments:3

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 3  
 
Thread Tools Search this Thread
 

How to Reveal anaSuperTrendU11 Trend Direction?

  #21 (permalink)
Elite Member
Memphis TN
 
Futures Experience: Intermediate
Platform: Ninjatrader
Favorite Futures: CL
 
Posts: 23 since Apr 2014
Thanks: 6 given, 3 received

I get the error StopDot does not exist in the current context, also one for UpTrend when I add this to the code. I added private double lastStopValue to the variables and what you said into the Initialize block. Am I missing something?

Reply With Quote
 
  #22 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,621 since Mar 2010
Thanks: 4,223 given, 25,485 received
Forum Reputation: Legendary


bstzgr View Post
I get the error StopDot does not exist in the current context, also one for UpTrend when I add this to the code. I added private double lastStopValue to the variables and what you said into the Initialize block. Am I missing something?

You need to create an instance of the anaSuperTrendU11 before you can access the BoolSeries and DataSeries objects.

 
Code
#region Variables
......
private double multiplier = 2.618; 
private int rangePeriod = 14;
private int basePeriod = 13;
private anaSuperTrendU11BaseType thisBaseType = anaSuperTrendU11BaseType.SMA; 
private anaSuperTrendU11OffsetType thisOffsetType = anaSuperTrendU11OffsetType.SMA; 
private anaSuperTrendU11VolaType thisVolaType	= anaSuperTrendU11VolaType.True_Range; 
private Indicator.anaSuperTrendU11 STU;
private double lastStopValue;
....
#endregion

protected override void Initialize()
{
   ....
   STU = anaSuperTrendU11(basePeriod, multiplier, rangePeriod, false, thisBaseType, thisOffsetType, thisVolaType);
   Add(STU);
   ....
}

protected override void OnBarUpdate()
{
   ......
   if (CalculateOnBarClose)
   {
       if ((STU.UpTrend[0] && !STU.UpTrend[1]) || (!STU.UpTrend[0] && STU.UpTrend[1]))
         lastStopValue = STU.StopDot[0]
   }
   ....
}



I had simplified the code as I thought that you would be able to modify it as needed.

Reply With Quote
The following 6 users say Thank You to Fat Tails for this post:
 
  #23 (permalink)
Elite Member
Memphis TN
 
Futures Experience: Intermediate
Platform: Ninjatrader
Favorite Futures: CL
 
Posts: 23 since Apr 2014
Thanks: 6 given, 3 received


Sincerely, thank you for all of your help @FatTails. I would not have been able to do what I wanted without your help.

Reply With Quote
 
  #24 (permalink)
Elite Member
Denver, CO
 
Futures Experience: Intermediate
Platform: ToS, NT
Favorite Futures: ES
 
Posts: 11 since Aug 2013
Thanks: 7 given, 2 received

anaSuperTrendU11 vs TSSuperTrend

I've been reading through the forums for three hours now, so if I've made a stupid mistake, please keep your flamethrower setting to "gentle".

I've recently been exploring SuperTrend indicators. The most popular one is probably this one ... the anaSuperTrendU11 indicator. However, I've also been playing with an older one, called TSSuperTrend v 2.4. I've fiddled around with both, but I've actually been happier with the TSSuperTrend version. Now, my intent here is not to start a food fight. In fact, I'd rather stick with newer versions of an indicator. So I've been trying to replicate the results I get from TSSuperTrend v 2.4, using FatTails' anaSuperTrendU11. But I haven't been successful.

So, here are my hopefully not-too-repetitive questions:

(1) Are anaSuperTrendU11 and TSSuperTrend v 2.4 different implementations of the same base algorithm, with different features and flexibility - or are they fundamentally different trend indicators?

(2) FatTails' anaSuperTrendU11 indicator seems to have more flexibility. How can I configure it to replicate the results from TSSuperTrend v 2.4 (on its default parameter values, say)?

(3) My intent is to use these trend indicators in an automated strategy. Which of the DataSeries/BoolSeries are the key ones to refer to, to expose trend direction? I'm a software developer, so I'm pretty comfortable fiddling with C# code.

Reply With Quote
 
  #25 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,621 since Mar 2010
Thanks: 4,223 given, 25,485 received
Forum Reputation: Legendary


pbailey19 View Post
I've been reading through the forums for three hours now, so if I've made a stupid mistake, please keep your flamethrower setting to "gentle".

I've recently been exploring SuperTrend indicators. The most popular one is probably this one ... the anaSuperTrendU11 indicator. However, I've also been playing with an older one, called TSSuperTrend v 2.4. I've fiddled around with both, but I've actually been happier with the TSSuperTrend version. Now, my intent here is not to start a food fight. In fact, I'd rather stick with newer versions of an indicator. So I've been trying to replicate the results I get from TSSuperTrend v 2.4, using FatTails' anaSuperTrendU11. But I haven't been successful.

So, here are my hopefully not-too-repetitive questions:

(1) Are anaSuperTrendU11 and TSSuperTrend v 2.4 different implementations of the same base algorithm, with different features and flexibility - or are they fundamentally different trend indicators?

(2) FatTails' anaSuperTrendU11 indicator seems to have more flexibility. How can I configure it to replicate the results from TSSuperTrend v 2.4 (on its default parameter values, say)?

(3) My intent is to use these trend indicators in an automated strategy. Which of the DataSeries/BoolSeries are the key ones to refer to, to expose trend direction? I'm a software developer, so I'm pretty comfortable fiddling with C# code.


@pbailey19: Let me summarize some of the key differences between the TSSuperTrend and anaSuperTrendU11.

The SuperTrend indicator is basically derived from a moving average and a measure for volatility. The calculation of the stop line is done in two steps: First you calculate the value of a moving average. Then in a second step a multiple of the average true range is subtracted (uptrend) or added (downtrend). That is about all.

Originally such indicators were created to be used with daily data. Traders waited to receive the printed charts, then performed calculations. They never calculated indicator values for broken days. With modern charting programs available you can now calculate indicator values for unstable bars. Many users love to set their indicators to CalculateOnBarClose = false, and that is where the problem starts

(1) first this leads to false values for some indicators
(2) second this increases CPU load

Let us have a look at the ATR. It takes its prior value and the true range of the current bar. Unfortunately, the true range of a new bar is close to zero, which means that the ATR always increases during the life of a bar. The ATR is therefore one of the indicators, which should never be used with setting CalculateOnBarClose = false. Applied to the TSSuperTrend used in COBC = false this means that the stopline contracts when a new bar prints and then gradually expands as the range of the new bar develops. I do not think that this behavior is useful, and therefore the indicator uses the ATR one bar ago. Another advantage of this solution is that the ATR of the last bar only needs to be calculated once with the first tick of each bar. It also reduces the CPU load.

The same applies to the moving averages or median. Some of them use a complex algorithm, and it is unnecessary to recalculate the moving average with every incoming tick. If you think about it, Bollinger Bands are even worse. When price moves up, the moving average moves up as well, and the standard deviation increases during the life of the bar. Therefore, when price approaches the upper Bollinger Band, the Bollinger Band has already moved away, and price has to catch up. The whole thing reminds me the paradox of Achilles and the Tortoise...

The whole behavior can be avoided by simply calculating both moving average and average true range one bar ago. For this reason the indicator is called anaSuperTrendU11 - 1 bar ago for the SMA and 1 bar ago for the ATR.
This is the main difference between the anaSuperTrendU11 and the TSSuperTrend. Other differences are:

- anaSuperTrend shows dots + connectors, while TSSuperTrend shows line
- anaSuperTrend shows where the stopline is touched
- both indicators have a paintbar options, but only the TSSuperTrend has background flooding
- anaSuperTrendU11 works with 29 different moving averages, TSSuperTrend with 11
- anaSuperTrendU11 can calculate volatility from true range, simple range and standard deviation, while TSSuperTrend uses average true range, dual thurst or adaptive
- anaSuperTrendU11 can be set to change direction intra-bar (this setting is independent from the COBC setting, that is it can also be used within a strategy that is set to COBC = true)
- anaSuperTrend exposes the trend information as BoolSeries (good for use with automated strategies, but cannot be used with Strategy Builder and Market Analyzer), while TSSuperTrend exposes the trend information as DataSeries (good for Strategy Builder and Market Analyzer)

But now to your question. The chart attached shows the TSSuperTrend with the following settings:

SuperTrend mode = ATR
Period for ATR = 10
Multiplier = 1.5
Moving average type = EMA
Period for EMA = 3

Now let us translate this to the anaSuperTrendU11. The anaSuperTrendU11 does not have the original ATR inbuilt. The ATR uses Wilder's smoothing. With a period of 10, Wilder's average uses a smoothing constant of 1/N = 1/10. A modern EMA has a smoothing constant of 2/(N+1), therefore you have to select a period of N = 19 for the EMA to obtain the ATR(10) or otherwise put

ATR(10) = EMA( TrueRange, 19)

Also remember that the anaSuperTrendU11 does not take into account the current bar, therefore we would use an EMA(TrueRange, 18) to come as close to the TSSuperTrend. In a similar fashion, we would use the EMA(2) one bar ago to get an approximation of the EMA(3) calculated by the TSSuperTrend. This results in the following settings:

Baseline Smoothing = EMA
Offset Smoothing = EMA (to build the ATR)
Offset Type = True_Range
Reverse intra-bar = false
Baseline period = 2 (reduced by 1)
Offset multiplier = 1.5
Offset period = 18 (as per calculation above)

The result is shown in the chart attached. The blue/red stoplines show the anaSuperTrendU11, the green/gold stoplines the TSSuperTrend. The behavior of both indicators is similar.

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Reply With Quote
The following 12 users say Thank You to Fat Tails for this post:
 
  #26 (permalink)
Elite Member
Denver, CO
 
Futures Experience: Intermediate
Platform: ToS, NT
Favorite Futures: ES
 
Posts: 11 since Aug 2013
Thanks: 7 given, 2 received

First of all, thank you a million times over. I could never have asked for such a rich, detailed answer, and it's everything I wanted to know. I especially appreciate your description of the fundamentals of the indicator (what it basically is), and the details of the implementation.

Ironically, I'm also trying to duplicate the SuperTrend indicator's functionality in a customized, simplified indicator, and one of the things I'm trying to do is convert it to run with CalculateOnBarClose = true. So I may be able to significantly simplify the code, now.

Reply With Quote
The following user says Thank You to pbailey19 for this post:
 
  #27 (permalink)
Elite Member
Calgary AB, Canada
 
Futures Experience: Master
Platform: NinjaTrader
Broker/Data: Zen-Fire
Favorite Futures: CL, GC, ZB
 
master trader's Avatar
 
Posts: 66 since Apr 2010
Thanks: 34 given, 15 received


Fat Tails View Post
@pbailey19: Let me summarize some of the key differences between the TSSuperTrend and anaSuperTrendU11.

The SuperTrend indicator is basically derived from a moving average and a measure for volatility. The calculation of the stop line is done in two steps: First you calculate the value of a moving average. Then in a second step a multiple of the average true range is subtracted (uptrend) or added (downtrend). That is about all.

Originally such indicators were created to be used with daily data. Traders waited to receive the printed charts, then performed calculations. They never calculated indicator values for broken days. With modern charting programs available you can now calculate indicator values for unstable bars. Many users love to set their indicators to CalculateOnBarClose = false, and that is where the problem starts

(1) first this leads to false values for some indicators
(2) second this increases CPU load

Let us have a look at the ATR. It takes its prior value and the true range of the current bar. Unfortunately, the true range of a new bar is close to zero, which means that the ATR always increases during the life of a bar. The ATR is therefore one of the indicators, which should never be used with setting CalculateOnBarClose = false. Applied to the TSSuperTrend used in COBC = false this means that the stopline contracts when a new bar prints and then gradually expands as the range of the new bar develops. I do not think that this behavior is useful, and therefore the indicator uses the ATR one bar ago. Another advantage of this solution is that the ATR of the last bar only needs to be calculated once with the first tick of each bar. It also reduces the CPU load.

The same applies to the moving averages or median. Some of them use a complex algorithm, and it is unnecessary to recalculate the moving average with every incoming tick. If you think about it, Bollinger Bands are even worse. When price moves up, the moving average moves up as well, and the standard deviation increases during the life of the bar. Therefore, when price approaches the upper Bollinger Band, the Bollinger Band has already moved away, and price has to catch up. The whole thing reminds me the paradox of Achilles and the Tortoise...

The whole behavior can be avoided by simply calculating both moving average and average true range one bar ago. For this reason the indicator is called anaSuperTrendU11 - 1 bar ago for the SMA and 1 bar ago for the ATR.
This is the main difference between the anaSuperTrendU11 and the TSSuperTrend. Other differences are:

- anaSuperTrend shows dots + connectors, while TSSuperTrend shows line
- anaSuperTrend shows where the stopline is touched
- both indicators have a paintbar options, but only the TSSuperTrend has background flooding
- anaSuperTrendU11 works with 29 different moving averages, TSSuperTrend with 11
- anaSuperTrendU11 can calculate volatility from true range, simple range and standard deviation, while TSSuperTrend uses average true range, dual thurst or adaptive
- anaSuperTrendU11 can be set to change direction intra-bar (this setting is independent from the COBC setting, that is it can also be used within a strategy that is set to COBC = true)
- anaSuperTrend exposes the trend information as BoolSeries (good for use with automated strategies, but cannot be used with Strategy Builder and Market Analyzer), while TSSuperTrend exposes the trend information as DataSeries (good for Strategy Builder and Market Analyzer)

But now to your question. The chart attached shows the TSSuperTrend with the following settings:

SuperTrend mode = ATR
Period for ATR = 10
Multiplier = 1.5
Moving average type = EMA
Period for EMA = 3

Now let us translate this to the anaSuperTrendU11. The anaSuperTrendU11 does not have the original ATR inbuilt. The ATR uses Wilder's smoothing. With a period of 10, Wilder's average uses a smoothing constant of 1/N = 1/10. A modern EMA has a smoothing constant of 2/(N+1), therefore you have to select a period of N = 19 for the EMA to obtain the ATR(10) or otherwise put

ATR(10) = EMA( TrueRange, 19)

Also remember that the anaSuperTrendU11 does not take into account the current bar, therefore we would use an EMA(TrueRange, 18) to come as close to the TSSuperTrend. In a similar fashion, we would use the EMA(2) one bar ago to get an approximation of the EMA(3) calculated by the TSSuperTrend. This results in the following settings:

Baseline Smoothing = EMA
Offset Smoothing = EMA (to build the ATR)
Offset Type = True_Range
Reverse intra-bar = false
Baseline period = 2 (reduced by 1)
Offset multiplier = 1.5
Offset period = 18 (as per calculation above)

The result is shown in the chart attached. The blue/red stoplines show the anaSuperTrendU11, the green/gold stoplines the TSSuperTrend. The behavior of both indicators is similar.

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).








Good job FT, your're certainly very knowledgeable in this. You used a 15 min chart in this example. When you use smaller timeframe, how do the settings change? For example if you're to use a 6 Range chart in that example, what would be your settings for anaSupperTrend for:

Baseline period ...
Offset multiplier ...
Offset period ....


Thanks.

Reply With Quote
 
  #28 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,621 since Mar 2010
Thanks: 4,223 given, 25,485 received
Forum Reputation: Legendary


master trader View Post
Good job FT, your're certainly very knowledgeable in this. You used a 15 min chart in this example. When you use smaller timeframe, how do the settings change? For example if you're to use a 6 Range chart in that example, what would be your settings for anaSupperTrend for:

Baseline period ...
Offset multiplier ...
Offset period ....


Thanks.

One of the properties of the SuperTrend is that it autoadjusts to volatility. When volatility rises the stops will be wider, while stops will be narrower after volatility has declined. This adjustment to volatility is achieved via the average true range, which is a measure for volatility, if you use it with minute charts.

If you apply the indicator to range bars, the average true range will be constant most of the time, as it only reflects the selected range. Therefore the indicator can no longer adjust to volatility when used with range bars. It becomes a different animal and works more like a fixed channel.

I have never used this indicator with range bars.

Reply With Quote
The following 2 users say Thank You to Fat Tails for this post:
 
  #29 (permalink)
Elite Member
Calgary AB, Canada
 
Futures Experience: Master
Platform: NinjaTrader
Broker/Data: Zen-Fire
Favorite Futures: CL, GC, ZB
 
master trader's Avatar
 
Posts: 66 since Apr 2010
Thanks: 34 given, 15 received


Fat Tails View Post
One of the properties of the SuperTrend is that it autoadjusts to volatility. When volatility rises the stops will be wider, while stops will be narrower after volatility has declined. This adjustment to volatility is achieved via the average true range, which is a measure for volatility, if you use it with minute charts.

If you apply the indicator to range bars, the average true range will be constant most of the time, as it only reflects the selected range. Therefore the indicator can no longer adjust to volatility when used with range bars. It becomes a different animal and works more like a fixed channel.

I have never used this indicator with range bars.







WOW! I value that response so much. In other words this indicator only works as originally intended when used with time-based charts. Tick charts and range charts will give results and they may be good results but they are not the original purpose of the indicator. I hope those using the indicator will take note of that. Thanks FT.


Last edited by master trader; May 19th, 2015 at 03:14 PM. Reason: correction
Reply With Quote
The following 2 users say Thank You to master trader for this post:
 
  #30 (permalink)
Elite Member
Prospect, KY. USA
 
Futures Experience: None
Platform: Sierra Chart
Broker/Data: Infinity
Favorite Futures: /CL
 
WilleeMac's Avatar
 
Posts: 683 since Jan 2012
Thanks: 301 given, 606 received


I'm a little late to the party

Thank you @Fat Tails

-William

Reply With Quote
The following user says Thank You to WilleeMac for this post:

Reply



futures io > > > > > How to Reveal anaSuperTrendU11 Trend Direction?

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)
 

RandBots: AutoTrading Bots to diversify your trading

Oct 24
 

TopstepTrader: Profiting Without Risking Your Own Money

Oct 26

Building Open Source Indicators for NT8 w/Fat Tails @ Lizard Indicators

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
[newb] question on mult entries in direction of trend jordis NinjaTrader Programming 5 November 21st, 2012 02:58 PM
Barclays Chief Could Reveal 'Embarrassing' Details Quick Summary News and Current Events 0 July 3rd, 2012 01:40 AM
S&P balks at SEC proposal to reveal rating errors GridKing News and Current Events 3 August 10th, 2011 11:37 PM
Trades Reveal China Diversifying Away From Dollar Quick Summary News and Current Events 1 July 14th, 2011 06:49 PM
Irish Bank Stress Tests May Not Reveal All Quick Summary News and Current Events 0 March 31st, 2011 03:10 AM


All times are GMT -4. The time now is 06:32 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-10-21 in 0.17 seconds with 20 queries on phoenix via your IP 54.158.55.5