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).
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 && !UpTrend) becomes true. The new trend is down. The last value of the old stop line can be detected as StopDot. 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 && UpTrend) becomes true. The new trend is now up. Again, the last value of the old stop line can be retrieved as StopDot 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 && !UpTrend. 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.
The following 5 users say Thank You to Fat Tails for this post:
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().
The following user says Thank You to Fat Tails for this 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)
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.
The following 2 users say Thank You to Fat Tails for this post: