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,325 / 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?

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


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.
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

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
 
  #12 (permalink)
Elite Member
Memphis TN
 
Futures Experience: Intermediate
Platform: Ninjatrader
Favorite Futures: CL
 
Posts: 23 since Apr 2014
Thanks: 6 given, 3 received

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

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

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



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

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

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
The following 4 users say Thank You to Fat Tails for this post:
 
  #14 (permalink)
Elite Member
Memphis TN
 
Futures Experience: Intermediate
Platform: Ninjatrader
Favorite Futures: CL
 
Posts: 23 since Apr 2014
Thanks: 6 given, 3 received


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)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,538 since Mar 2010
Thanks: 4,215 given, 24,939 received

Futures Edge on FIO

Which products do you trade?

 

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
The following 5 users say Thank You to Fat Tails for this post:
 
  #16 (permalink)
Elite Member
Memphis TN
 
Futures Experience: Intermediate
Platform: Ninjatrader
Favorite Futures: CL
 
Posts: 23 since Apr 2014
Thanks: 6 given, 3 received

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)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,538 since Mar 2010
Thanks: 4,215 given, 24,939 received


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
The following user says Thank You to Fat Tails for this post:
 
  #18 (permalink)
Elite Member
Memphis TN
 
Futures Experience: Intermediate
Platform: Ninjatrader
Favorite Futures: CL
 
Posts: 23 since Apr 2014
Thanks: 6 given, 3 received

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)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,538 since Mar 2010
Thanks: 4,215 given, 24,939 received


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
The following 2 users say Thank You to Fat Tails for this post:
 
  #20 (permalink)
Elite Member
Memphis TN
 
Futures Experience: Intermediate
Platform: Ninjatrader
Favorite Futures: CL
 
Posts: 23 since Apr 2014
Thanks: 6 given, 3 received


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

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
 

Bookmap New Indicator Panel, Cumulative Delta, Order Flow demo

Jan 17
 

An Afternoon with FIO member Massive l

Elite only

Leo Murphy: Making sense of Technical Analysis and Random Walk

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 05:33 PM.

no new posts
Page generated 2017-01-17 in 0.16 seconds with 20 queries on phoenix via your IP 174.129.120.155