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


How to Reveal anaSuperTrendU11 Trend Direction?
Started: by aventeren Views / Replies:4,335 / 31
Last Reply: Attachments:3

Welcome to futures.io.

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • 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, and we will never resell your private information.

-- Big Mike

Reply
 3  
 
Thread Tools Search this Thread
 

How to Reveal anaSuperTrendU11 Trend Direction?

  #1 (permalink)
Patient Discipline
Bellingham, WA USA
 
Futures Experience: Beginner
Platform: NT
Broker/Data: Mirus (Broker), Continuum (Data), Dorman (Clearing)
Favorite Futures: Futures
 
aventeren's Avatar
 
Posts: 202 since Mar 2013
Thanks: 426 given, 190 received

How to Reveal anaSuperTrendU11 Trend Direction?

Howdy--

@FatTails indicates in his anaSuperTrendU11 indicator description that the trend direction is revealed by a BoolSeries.

Here is the the anaSuperTrendU11 indicator link: https://futures.io/download/ninjatrader-7/indicators/1207-download.html?view

Does anyone know specifically what code snippets I would have to have in my indicator so that the anaSuperTrendU11 trend direction could be revealed?

I have looked at the anaSuperTrendU11 code, and here is the following BoolSeries related code:

 
Code
#region Variables
private BoolSeries upTrend;
#endregion Variables
 
Code
 protected override void Initialize()
        {
	         upTrend = new BoolSeries(this);
        }
 
Code
#region Properties
        [Browsable(false)]
        [XmlIgnore()]		
        public BoolSeries UpTrend
        {
                get { return upTrend; }
        }
#endregion Properties
So I'm trying to specifically access the anaSuperTrendU11's public BoolSeries UpTrend. Would someone be willing to help me understand what specific code snippets I would need to have in my indicator to access the UpTrend value (ie, 0 or 1)?

Thanks for your help. I really appreciate it.

All best,

Aventeren


Last edited by aventeren; October 2nd, 2013 at 02:11 AM.
Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Patient Discipline
Bellingham, WA USA
 
Futures Experience: Beginner
Platform: NT
Broker/Data: Mirus (Broker), Continuum (Data), Dorman (Clearing)
Favorite Futures: Futures
 
aventeren's Avatar
 
Posts: 202 since Mar 2013
Thanks: 426 given, 190 received

A Night's Sleep...


So I slept on this last night (albeit not very much with a 2 week old newborn baby boy who doesn't quite fancy sleep like I do), and I thought it might help to point out the following:

1. I'm not so much interested in having a fish given to me as I am in learning how to fish. In other words, my hope is that by learning how to grab a value from another indicator, I will be in a better position to do this next time--plus, my hope is that others will come across this post in the future, and they, too, will become fisherman instead of fish mongers.

2. I intuitively know how to do this, as I already have called the EMA indicator into my indicator. To pull in the EMA, I used the following code:

 
Code
if(EMA(period)[1] < EMA(period)[0])
{
        Do something...
}
So I know generally that to call another indicator, I need to know the correct overloads (in the case of the EMA, evidently it just has one overload variable called "int period"). So that leads me to my next clue.

3. The anaSuperTrendU11 appears to have the following required inputs: anaSuperTrendU11(int basePeriod, double multiplier, int rangePeriod, bool reverseIntraBar, anaSuperTrendBaseType thisBaseType, anaSuperTrendU11OffsetType thisOffsetType, anaSuperTrendU11VolaType thisRangeType) (+1 overload).

Therefore, because I was trying to plug the BoolSeries value into a list, I first created the list in my variables section:

 
Code
#region Variables
List<bool> listSuperTrend	= new List<bool>(); // list to store each trade's anaSuperTrend trend value 
#endregion Variables
I then dumped the BoolSeries value into the list by doing this:

 
Code
listSuperTrend.Add(anaSuperTrendU11(3, 2.5, 15, false, anaSuperTrendU11BaseType.Median, anaSuperTrendU11OffsetType.Default, anaSuperTrendU11VolaType.True_Range).UpTrend[0]);
I then printed the result to an output window using this:

 
Code
Print(listSuperTrend[0].ToString());
And lo and behold, she works.

So cool, I'm that much closer to being a fisherman.

Hopefully this post will help others. I guess the most important thing to realize when you are trying to grab the values from another indicator for use in your own indicator is to remember the following:

1. Open up the indicator that you are interested in pulling values from, and find the value that you are interested in. In my case I was interested in "upTrend".

2. Then go to the Properties section in that indicator, and see what the public name for the value would be. Please note, I have learned that variables used within an indicator begin with a lowercase or _ (ie, "upTrend" or "_UpTrend") and public variables begin with a capital letter (ie, "UpTrend"). Therefore, find the capital letter variable (this is the one that you will type into your program, in my case it was "UpTrend") and make sure that the lower case version of this variable matches up with the value you want (in my case I was looking for the value stored in "upTrend", so this was the correct variable).

3. Note what type the public variable is within the Properties section. In my case, the anaSuperTrendU11's Properties for "UpTrend" was:

 
Code
[Browsable(false)]
[XmlIgnore()]		
public BoolSeries UpTrend
{
        get { return upTrend; }
}
Therefore, I knew that the value that "UpTrend" (the public variable) was going to return to my program was going to be of type Bool (ie, true or false).

4. Now jump back to your program and go to the line where you are interested in grabbing the other indicator's value. Now just type in the name of the indicator with a single "(". In my case, I just typed in "anaSuperTrendU11(" and that should pop up the inputs that .NET is looking for on the indicator that you are interested in. In my case, I noted what these were in the top half of this post (item #3 where I discussed overloads). Grab a pencil and a piece of paper, and jot these down, because these will be important.

The most important things to note here, is what inputs have a simple type (i.e., "int", "bool", "double", "etc) and what inputs require an indicator specific type that is defined in the indicator you are trying to pull from (i.e., "anaSuperTrendU11BaseType").

On the "simple" input types, you'll just have to type a number (for the type int and double inputs) or a simple true or false for the type bool inputs.

On the indicator specific inputs, you'll have to type in the whole indicator type followed by a dot and then the indicator input that you are interested in. Which leads me to my next step.

5. If you have indicator specific inputs that are required, now you need to go back to the indicator that you are trying to pull values from, and note the type names and the type inputs (ie, "anaSuperTrendU11BaseType.Median"). This is where you would change the indicator's inputs to alternative types defined in the indicator. In the case of anaSuperTrend, @FatTails had created multiple options for customization with BaseType, OffsetType and VolaType. You would find what is available to you by scrolling down in the indicator you are interested in pulling values from and noting what you can choose from. So in the case of BaseType on the anaSuperTrendU11 indicator, Fat Tails is a freaking all star and he gave us the option to chose from:

Median
ADXVMA
Butterworth_2
Butterworth_3
DEMA
DSMA
DTMA
DWMA
Ehlers
EMA
Gauss_2
Gauss_3
Gauss_4
HMA
HoltEMA
LinReg
LLMA
SMA
SuperSmoother_2
SuperSmoother_3
TEMA
TMA
TSMA
TWMA
VWMA
WMA
ZeroLagHATEMA
AeroLagTEMA
ZLEMA

Like I said, Fat Tails is an all star.

So in any event, just note what you want. So if you were interested in using the LLMA value in your indicator, you would type in "anaSuperTrendU11BaseType.LLMA".

The most important thing to note here on our fisherman quest is to realize that you need to type in the indicator specific type followed by a period and then the type.

6. So now that you know what .NET is looking for, start typing in each required indicator input followed by a comma. Each time you type in a comma, you should notice that the little helper window will advance to the next input. When you get to the last input, close it with a ")".

7. Now before you leave this line, you have some more work to do. Remember when I had you go to the Properties section and find out the public variable name (ie, the variable name with a capital letter, which in my case was "UpTrend")? Now you're going to use this to actually pull the value into your program by typing a period and then the public variable name--and if you are interested in the current bar's value you would type a "[0]" or if you were interested in the previous bar's value you would type a "[1]", etc. So in my case, the whole line looked like this:

 
Code
anaSuperTrendU11(3, 2.5, 15, false, anaSuperTrendU11BaseType.Median, anaSuperTrendU11OffsetType.Default, anaSuperTrendU11VolaType.True_Range).UpTrend[0];
8. So that is how you get the value from another indicator into your indicator. What you elect to do with this value is up to you. In my case, I dropped the value into a list so that I could access the value later for back testing. But you might want to store this value into another variable that you are using in your program to make a calculation or a logic decision or whatever. But at this point, you will have a value from the other indicator that is of the type specified in the Properties section (in my case, "UpTrend" was of type BoolSeries, so the value was either a "true" or "false").

I'm starting to learn that coding is like fishing: you need a lot of patience and a few sandwiches, but you can generally catch a fish.

Good luck.

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

anaSuperTrend previous trend line reference

I'm trying to figure out how to add a condition to a strategy using the anaSuperTrend. Sometimes, the trend lines are breached but the market won't stay on that side of the trend line that was breached.

Example: Stop line is at 93. Market closes above 93 so the trend flips to long. However, the market doesn't stay above 93 so it was a false trend change signal.

I'd like to add a condition in my strategy to reference the previous stop line and tell it to ignore signals if it doesn't stay above for a long or below for a short.

How would you suggest I go about this?


aventeren View Post
So I slept on this last night (albeit not very much with a 2 week old newborn baby boy who doesn't quite fancy sleep like I do), and I thought it might help to point out the following:

1. I'm not so much interested in having a fish given to me as I am in learning how to fish. In other words, my hope is that by learning how to grab a value from another indicator, I will be in a better position to do this next time--plus, my hope is that others will come across this post in the future, and they, too, will become fisherman instead of fish mongers.

2. I intuitively know how to do this, as I already have called the EMA indicator into my indicator. To pull in the EMA, I used the following code:

 
Code
if(EMA(period)[1] < EMA(period)[0])
{
        Do something...
}
So I know generally that to call another indicator, I need to know the correct overloads (in the case of the EMA, evidently it just has one overload variable called "int period"). So that leads me to my next clue.

3. The anaSuperTrendU11 appears to have the following required inputs: anaSuperTrendU11(int basePeriod, double multiplier, int rangePeriod, bool reverseIntraBar, anaSuperTrendBaseType thisBaseType, anaSuperTrendU11OffsetType thisOffsetType, anaSuperTrendU11VolaType thisRangeType) (+1 overload).

Therefore, because I was trying to plug the BoolSeries value into a list, I first created the list in my variables section:

 
Code
#region Variables
List<bool> listSuperTrend	= new List<bool>(); // list to store each trade's anaSuperTrend trend value 
#endregion Variables
I then dumped the BoolSeries value into the list by doing this:

 
Code
listSuperTrend.Add(anaSuperTrendU11(3, 2.5, 15, false, anaSuperTrendU11BaseType.Median, anaSuperTrendU11OffsetType.Default, anaSuperTrendU11VolaType.True_Range).UpTrend[0]);
I then printed the result to an output window using this:

 
Code
Print(listSuperTrend[0].ToString());
And lo and behold, she works.

So cool, I'm that much closer to being a fisherman.

Hopefully this post will help others. I guess the most important thing to realize when you are trying to grab the values from another indicator for use in your own indicator is to remember the following:

1. Open up the indicator that you are interested in pulling values from, and find the value that you are interested in. In my case I was interested in "upTrend".

2. Then go to the Properties section in that indicator, and see what the public name for the value would be. Please note, I have learned that variables used within an indicator begin with a lowercase or _ (ie, "upTrend" or "_UpTrend") and public variables begin with a capital letter (ie, "UpTrend"). Therefore, find the capital letter variable (this is the one that you will type into your program, in my case it was "UpTrend") and make sure that the lower case version of this variable matches up with the value you want (in my case I was looking for the value stored in "upTrend", so this was the correct variable).

3. Note what type the public variable is within the Properties section. In my case, the anaSuperTrendU11's Properties for "UpTrend" was:

 
Code
[Browsable(false)]
[XmlIgnore()]		
public BoolSeries UpTrend
{
        get { return upTrend; }
}
Therefore, I knew that the value that "UpTrend" (the public variable) was going to return to my program was going to be of type Bool (ie, true or false).

4. Now jump back to your program and go to the line where you are interested in grabbing the other indicator's value. Now just type in the name of the indicator with a single "(". In my case, I just typed in "anaSuperTrendU11(" and that should pop up the inputs that .NET is looking for on the indicator that you are interested in. In my case, I noted what these were in the top half of this post (item #3 where I discussed overloads). Grab a pencil and a piece of paper, and jot these down, because these will be important.

The most important things to note here, is what inputs have a simple type (i.e., "int", "bool", "double", "etc) and what inputs require an indicator specific type that is defined in the indicator you are trying to pull from (i.e., "anaSuperTrendU11BaseType").

On the "simple" input types, you'll just have to type a number (for the type int and double inputs) or a simple true or false for the type bool inputs.

On the indicator specific inputs, you'll have to type in the whole indicator type followed by a dot and then the indicator input that you are interested in. Which leads me to my next step.

5. If you have indicator specific inputs that are required, now you need to go back to the indicator that you are trying to pull values from, and note the type names and the type inputs (ie, "anaSuperTrendU11BaseType.Median"). This is where you would change the indicator's inputs to alternative types defined in the indicator. In the case of anaSuperTrend, @FatTails had created multiple options for customization with BaseType, OffsetType and VolaType. You would find what is available to you by scrolling down in the indicator you are interested in pulling values from and noting what you can choose from. So in the case of BaseType on the anaSuperTrendU11 indicator, Fat Tails is a freaking all star and he gave us the option to chose from:

Median
ADXVMA
Butterworth_2
Butterworth_3
DEMA
DSMA
DTMA
DWMA
Ehlers
EMA
Gauss_2
Gauss_3
Gauss_4
HMA
HoltEMA
LinReg
LLMA
SMA
SuperSmoother_2
SuperSmoother_3
TEMA
TMA
TSMA
TWMA
VWMA
WMA
ZeroLagHATEMA
AeroLagTEMA
ZLEMA

Like I said, Fat Tails is an all star.

So in any event, just note what you want. So if you were interested in using the LLMA value in your indicator, you would type in "anaSuperTrendU11BaseType.LLMA".

The most important thing to note here on our fisherman quest is to realize that you need to type in the indicator specific type followed by a period and then the type.

6. So now that you know what .NET is looking for, start typing in each required indicator input followed by a comma. Each time you type in a comma, you should notice that the little helper window will advance to the next input. When you get to the last input, close it with a ")".

7. Now before you leave this line, you have some more work to do. Remember when I had you go to the Properties section and find out the public variable name (ie, the variable name with a capital letter, which in my case was "UpTrend")? Now you're going to use this to actually pull the value into your program by typing a period and then the public variable name--and if you are interested in the current bar's value you would type a "[0]" or if you were interested in the previous bar's value you would type a "[1]", etc. So in my case, the whole line looked like this:

 
Code
anaSuperTrendU11(3, 2.5, 15, false, anaSuperTrendU11BaseType.Median, anaSuperTrendU11OffsetType.Default, anaSuperTrendU11VolaType.True_Range).UpTrend[0];
8. So that is how you get the value from another indicator into your indicator. What you elect to do with this value is up to you. In my case, I dropped the value into a list so that I could access the value later for back testing. But you might want to store this value into another variable that you are using in your program to make a calculation or a logic decision or whatever. But at this point, you will have a value from the other indicator that is of the type specified in the Properties section (in my case, "UpTrend" was of type BoolSeries, so the value was either a "true" or "false").

I'm starting to learn that coding is like fishing: you need a lot of patience and a few sandwiches, but you can generally catch a fish.

Good luck.


Reply With Quote
 
  #5 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,539 since Mar 2010
Thanks: 4,215 given, 24,924 received

Futures Edge on FIO

Which products do you trade?

 

bstzgr View Post
I'm trying to figure out how to add a condition to a strategy using the anaSuperTrend. Sometimes, the trend lines are breached but the market won't stay on that side of the trend line that was breached.

Example: Stop line is at 93. Market closes above 93 so the trend flips to long. However, the market doesn't stay above 93 so it was a false trend change signal.

I'd like to add a condition in my strategy to reference the previous stop line and tell it to ignore signals if it doesn't stay above for a long or below for a short.

How would you suggest I go about this?

There is a single plot that represents the stop line, and that stop line can be

- either above price (stop for short position)
- or below price (stop for long position)

If you want to reference the previous stopline you can access it via anaSuperTrendU11.StopDot[1]. Now, if you wish to ignore signals when the trend has changed, then you can use the BoolSeries anaSuperTrendU11.UpTrend, which holds the value "true" for an uptrend and "false" for a downtrend.

The condition (anaSuperTrendU11.UpTrend[0] == true && anaSuperTrendU11.UpTrend[1] = false) stands for a trend change from downtrend to uptrend. Accordingly the condition (anaSuperTrendU11.UpTrend[0] == false && anaSuperTrendU11.UpTrend[1] = true) represents a trend change from uptrend to downtrend.

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

anaSuperTrendU11

So, if I understand this correctly, anaSuperTrendU11.StopDot[1] would tell NT that you're referencing the previous value of anaSuperTrendu11, regardless of how many bars have passed since that value occurred?
Thank you, FatTails

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

I'd like to make sure I understand you correctly. I want to write a condition in my strategy that will ignore a trend change IF there's been a false signal.

Let's say the trend line is at 93. The market closes at 93.01 and the trend flips to long. Over the next few bars, price drifts back below 93 and stays there. It was a false signal. I am not interested in attempting to go long until the market is back above 93, the previous trend line.
I've added these lines as conditions. The top one shows that the trend is long. The second one (from what I understand) shows that the previous trend line is below the close of this bar.


&& anaSuperTrendM11(3, 3, 10, false).StopDot[0] < Low[0]
&& anaSuperTrendM11(3, 3, 10, false).StopDot[1] < Close[0])

I added the second condition but it appears to not have changed anything when I look back historically. Is there a better way to accomplish what I'm wanting to do?
Thank you.

Reply With Quote
 
  #8 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,539 since Mar 2010
Thanks: 4,215 given, 24,924 received


bstzgr View Post
So, if I understand this correctly, anaSuperTrendU11.StopDot[1] would tell NT that you're referencing the previous value of anaSuperTrendu11, regardless of how many bars have passed since that value occurred?
Thank you, FatTails

anaSuperTrendU11.StopDot[1] references the value of the stop line 1 bar ago.

Reply With Quote
 
  #9 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,539 since Mar 2010
Thanks: 4,215 given, 24,924 received


bstzgr View Post
I'd like to make sure I understand you correctly. I want to write a condition in my strategy that will ignore a trend change IF there's been a false signal.

Let's say the trend line is at 93. The market closes at 93.01 and the trend flips to long. Over the next few bars, price drifts back below 93 and stays there. It was a false signal. I am not interested in attempting to go long until the market is back above 93, the previous trend line.
I've added these lines as conditions. The top one shows that the trend is long. The second one (from what I understand) shows that the previous trend line is below the close of this bar.


&& anaSuperTrendM11(3, 3, 10, false).StopDot[0] < Low[0]
&& anaSuperTrendM11(3, 3, 10, false).StopDot[1] < Close[0])

I added the second condition but it appears to not have changed anything when I look back historically. Is there a better way to accomplish what I'm wanting to do?
Thank you.

I do not understand what you try to achieve. Please post a chart with the SuperTrend added and explain.

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


I'm coding an entry which trades in the direction of the trend. When there's a false trend change on anasupertrend, I do not want to trade in that direction. In a long situation, if the market doesn't stay above the previous trend line then it's a false signal. What's the best way for me to accomplish this? I thought I'd just need the value of the previous trend line but I don't know how to get that.

I've attached an example chart.
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Reply With Quote

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)

2016 True Edge Awards: Voting is open until Jan 21!

Now
 

Anthony Drager: Pulling the trigger with confidence

Elite only
 

Leo Murphy: The Art and Science of Technical Analysis

Elite only
 

FuturesTrader71: Ask Me Anything

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 03:58 PM
Barclays Chief Could Reveal 'Embarrassing' Details Quick Summary News and Current Events 0 July 3rd, 2012 02:40 AM
S&P balks at SEC proposal to reveal rating errors GridKing News and Current Events 3 August 11th, 2011 12:37 AM
Trades Reveal China Diversifying Away From Dollar Quick Summary News and Current Events 1 July 14th, 2011 07:49 PM
Irish Bank Stress Tests May Not Reveal All Quick Summary News and Current Events 0 March 31st, 2011 04:10 AM


All times are GMT -4. The time now is 09:38 AM.

no new posts
Page generated 2017-01-21 in 0.21 seconds with 21 queries on phoenix via your IP 54.205.47.26