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 WilleeMac with 1 thanks per post
    1. trending_up 12,242 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?

  #11 (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 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.

You will only know with hindsight, whether a signal is a good signal or a bad signal.

When your signal comes - whatever it is - you need to take a trade. When that signal becomes a false signal, what do you want to do? exit your trade, enter a reverse trade?

Can you describe which entry and exit signals you would like to take and mark them at the chart?

What is your exact entry rule?

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Exit Strategy
NinjaTrader
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Online prop firm The Funded Trader (TFT) going under?
Traders Hideout
Ninja Mobile Trader VPS (ninjamobiletrader.com)
Trading Reviews and Vendors
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
60 thanks
Funded Trader platforms
43 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #12 (permalink)
 bstzgr 
Memphis TN
 
Experience: Intermediate
Platform: Ninjatrader
Trading: CL
Posts: 23 since Apr 2014
Thanks Given: 7
Thanks Received: 4

This is a working system. I'm trying to improve its profitability. The way that my system works is by fading counter rotations to the trend. In an uptrend, my system attempts to go long on pull backs using an oscillator. Reverse for a downtrend.
My thought is that I do not want to take those counter rotation trades *IF* the market doesn't stay above the previous trend line for a long or below the previous trend line for a short.

Here's an example.

1. The trend line is flipped because it closes above 93.44 but the market does not stay above.
2. There is a pull back, my oscillator reading says to go long.
3. It's stopped out 10 ticks later


Reply With Quote
  #13 (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
This is a working system. I'm trying to improve its profitability. The way that my system works is by fading counter rotations to the trend. In an uptrend, my system attempts to go long on pull backs using an oscillator. Reverse for a downtrend.
My thought is that I do not want to take those counter rotation trades *IF* the market doesn't stay above the previous trend line for a long or below the previous trend line for a short.

Here's an example.

1. The trend line is flipped because it closes above 93.44 but the market does not stay above.
2. There is a pull back, my oscillator reading says to go long.
3. It's stopped out 10 ticks later


But then when you enter the position, you do not know whether you will be stopped out or not. You cannot change the past with hindsight.

I think that this is not a question of referencing an indicator value, but that you first need to make up your mind what you wish to achieve. Once you know what you wish to code, it is easy to do it.

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


Fat Tails View Post
But then when you enter the position, you do not know whether you will be stopped out or not. You cannot change the past with hindsight.

I think that this is not a question of referencing an indicator value, but that you first need to make up your mind what you wish to achieve. Once you know what you wish to code, it is easy to do it.

I apologize. I seem to not be able to communicate in such a way that you understand me. Let's try this again.

1. This is a working and profitable system.
2. When the trend changes and follows through by either being able to stay above the previous trend line for a long or below for a short, then my positions generally work out.
3. When the trend changes but does not follow through by staying above or below that trend line for the corresponding trend, the signals generally fail.
4. It's elementary that hindsight is always 20-20.
5. All that I want is to reference the last value for the previous trend line. This is all. It's nothing more complicated. I want it to ignore signals during the times that I mentioned.

Reply With Quote
  #15 (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 apologize. I seem to not be able to communicate in such a way that you understand me. Let's try this again.

1. This is a working and profitable system.
2. When the trend changes and follows through by either being able to stay above the previous trend line for a long or below for a short, then my positions generally work out.
3. When the trend changes but does not follow through by staying above or below that trend line for the corresponding trend, the signals generally fail.
4. It's elementary that hindsight is always 20-20.
5. All that I want is to reference the last value for the previous trend line. This is all. It's nothing more complicated. I want it to ignore signals during the times that I mentioned.

In the first place you did not mention that you use an oscillator for generating entry signals. To reference the prior value of the stop line you would need to apply the following logic:

The indicator sets the trend state for each bar. For that purpose it uses a BoolSeries object UpTrend, which either holds the value true or false. This BoolSeries is set for every incoming tick.


Case CalculateOnBarClose = true or ReverseIntraBar = true

Let us assume that the trend has been up. If the current bar breaches the lower stopline, this can be detected when the condition (UpTrend[1] && !UpTrend[0]) becomes true. The new trend is down. The last value of the old stop line can be detected as StopDot[0]. You can store this value and leave it unchanged until a new trend change is detected.

Accordingly if the trend has been down and the current bar breaches the upper stopline, this can be detected when the condition (!UpTrend[1] && UpTrend[0]) becomes true. The new trend is now up. Again, the last value of the old stop line can be retrieved as StopDot[0] and stored as needed.


Case (CalculateOnBarClose = false && ReverseIntraBar = false)

If you run the anaSuperTrendU11 in COBC = false and set the boolean variable ReverseIntraBar to false, a close beyond the stopline is needed for a trend change. In this case you cannot detect a trend change prior to the bar close, as all trend information is preliminary. Therefore you will detect a trend change with the first tick of the bar that follows the trend change.

If the trend has been up, you will detect the trend change when the prior bar has made a close beyond the lower stop line, which is mirrored by the condition (UpTrend[2] && !UpTrend[1]. The new trend is down. The last value of the old stop line can now be retrieved as StopDot81] and stored as needed.

According, if the trend has been down, you can detect the trend change when the prior bar has made a close abobe the upper stop line....


What is important here is to differentiate between two cases:

(a) uptrend information is final (case COBC = true or reverseIntraBar = true)
(b) uptrend information is preliminary (case if both COBC = true and reverseIntraBar = false)

In the second case (b) the check for the trend change can only be performed 1 tick after the fact, that is when the first tick of the new bar signals that the prior bar has closed.

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

Thank you.
The way I have it set up is COBC=True, ReverseIntraBar=false
You may have answered this question in your post but I don't see it.
My signals may not be generated by the oscillator until several bars after the trend change. How can I go about storing the previous trend value so that I can reference it in a condition?

This is a basic example:
Let's say that the last trend changes on Bar 100.
Conditions are met to generate order on bar 132 (or bar 101-1000000, doesn't matter)
How can I add the value for where the trend line was on bar 99 to a condition?

Reply With Quote
  #17 (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
Thank you.
The way I have it set up is COBC=True, ReverseIntraBar=false
You may have answered this question in your post but I don't see it.
My signals may not be generated by the oscillator until several bars after the trend change. How can I go about storing the previous trend value so that I can reference it in a condition?

This is a basic example:
Let's say that the last trend changes on Bar 100.
Conditions are met to generate order on bar 132 (or bar 101-1000000, doesn't matter)
How can I add the value for where the trend line was on bar 99 to a condition?

You need a variable of type double that holds the last value of the stop line. Whenever the trend changes direction you assign a new value to that variable. No need to change it with every run of OnBarUpdate().

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

I have a vague understanding of programming concepts and C# in particular. I know that you don't have to answer my questions and I appreciate the fact that you have been. Would you mind being a little bit more explicit with what you mean with maybe an example? Specifically, how would I reference the last value for the previous trend and then only update that when the trend changes?
This stuff is slowly sinking in. Thanks

Reply With Quote
  #19 (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 have a vague understanding of programming concepts and C# in particular. I know that you don't have to answer my questions and I appreciate the fact that you have been. Would you mind being a little bit more explicit with what you mean with maybe an example? Specifically, how would I reference the last value for the previous trend and then only update that when the trend changes?
This stuff is slowly sinking in. Thanks

This code would only be correct for COBC = true (a trend change is final, when detected)
 
Code
#region Variables
.....
private double    lastStopValue;
.....

if (CalculateOnBarClose)
{
    if ((UpTrend[0] && !UpTrend[1]) || (!UpTrend[0] && UpTrend[1]))
         lastStopValue = StopDot[0]
}


Whenever there is a trend change - from downtrend to uptrend or from uptrend to downtrend - you assign the current value of the stop line to the variable lastStopValue. The value can now be retrieved until the next trend change.

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


Thank you, FatTails! This definitely answers my question.


Fat Tails View Post
This code would only be correct for COBC = true (a trend change is final, when detected)
 
Code
#region Variables
.....
private double    lastStopValue;
.....

if (CalculateOnBarClose)
{
    if ((UpTrend[0] && !UpTrend[1]) || (!UpTrend[0] && UpTrend[1]))
         lastStopValue = StopDot[0]
}


Whenever there is a trend change - from downtrend to uptrend or from uptrend to downtrend - you assign the current value of the stop line to the variable lastStopValue. The value can now be retrieved until the next trend change.


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