NexusFi: Find Your Edge


Home Menu

 





How to Reveal anaSuperTrendU11 Trend Direction?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Fat Tails with 12 posts (35 thanks)
    2. looks_two bstzgr with 11 posts (1 thanks)
    3. looks_3 master trader with 2 posts (2 thanks)
    4. looks_4 aventeren with 2 posts (8 thanks)
      Best Posters
    1. looks_one aventeren with 4 thanks per post
    2. looks_two Fat Tails with 2.9 thanks per post
    3. looks_3 master trader with 1 thanks per post
    4. looks_4 bstzgr with 0.1 thanks per post
    1. trending_up 12,227 views
    2. thumb_up 48 thanks given
    3. group 17 followers
    1. forum 31 posts
    2. attach_file 3 attachments




 
Search this Thread

How to Reveal anaSuperTrendU11 Trend Direction?

  #1 (permalink)
 
aventeren's Avatar
 aventeren 
Bellingham, WA USA
 
Experience: Beginner
Platform: NT
Broker: Mirus (Broker), Continuum (Data), Dorman (Clearing)
Trading: Futures
Posts: 202 since Mar 2013
Thanks Given: 428
Thanks Received: 202

Howdy--

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

Here is the the anaSuperTrendU11 indicator link:

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

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Are there any eval firms that allow you to sink to your …
Traders Hideout
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Exit Strategy
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
38 thanks
NexusFi site changelog and issues/problem reporting
25 thanks
GFIs1 1 DAX trade per day journal
19 thanks
The Program
18 thanks
  #3 (permalink)
 
aventeren's Avatar
 aventeren 
Bellingham, WA USA
 
Experience: Beginner
Platform: NT
Broker: Mirus (Broker), Continuum (Data), Dorman (Clearing)
Trading: Futures
Posts: 202 since Mar 2013
Thanks Given: 428
Thanks Received: 202


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.

Started this thread Reply With Quote
  #4 (permalink)
 bstzgr 
Memphis TN
 
Experience: Intermediate
Platform: Ninjatrader
Trading: CL
Posts: 23 since Apr 2014
Thanks Given: 7
Thanks Received: 4

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)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


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
Thanked by:
  #6 (permalink)
 bstzgr 
Memphis TN
 
Experience: Intermediate
Platform: Ninjatrader
Trading: CL
Posts: 23 since Apr 2014
Thanks Given: 7
Thanks Received: 4

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
Thanked by:
  #7 (permalink)
 bstzgr 
Memphis TN
 
Experience: Intermediate
Platform: Ninjatrader
Trading: CL
Posts: 23 since Apr 2014
Thanks Given: 7
Thanks Received: 4

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)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


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)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


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)
 bstzgr 
Memphis TN
 
Experience: Intermediate
Platform: Ninjatrader
Trading: CL
Posts: 23 since Apr 2014
Thanks Given: 7
Thanks Received: 4


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.

Reply With Quote




Last Updated on August 26, 2016


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts