These Indicators: SwingHi, SwingHiLo and SwingLo (from Community Indicators) peek (heavily) into the future and should be marked as such.
Feature Request:
Add a red flag to indicators which should not be used in trading strategies because their usage will lead to unrealistic results in backtests.
Reasons are:
* using future information
* using external information which may contain future information
* etc...
This red flag should be accessible from code as well to enable tools like Indicator Profiler to flag results or avoid these indicators in the first place.
Feature Request:
Add a red flag to indicators which should not be used in trading strategies because their usage will lead to unrealistic results in backtests.
Reasons are:
* using future information
* using external information which may contain future information
* etc...
This red flag should be accessible from code as well to enable tools like Indicator Profiler to flag results or avoid these indicators in the first place.
Rename
The SwingHi/Lo indicators can be pretty valid indicators depending on their settings. I doubt we need to mark something to crowd the interface with extra signs. Rather fix the problem or if it's not possible, just expel such indicator because it's misleading.
If the indicators really peek into the future I think such a warning flag is very desirable, and I'd support it by voting for the feature. Why allow less experienced users to be led astray by something like this??
I marked this a Feature Request and you can vote for it in the Wish List.
https://www.wealth-lab.com/wishlist
I marked this a Feature Request and you can vote for it in the Wish List.
https://www.wealth-lab.com/wishlist
But why overload the GUI when you can just weed something bad out?
It's not even determined that these indicators peek, aren't the opinions different now?
It's not even determined that these indicators peek, aren't the opinions different now?
91% success rate! I'm itching to start trading this new Holy Grail!!
I especially loved how it completely side-stepped the COVID crash!! ;)
CODE:
using WealthLab.Backtest; using WealthLab.Core; using WealthLab.Community; namespace WealthScript2 { public class MyStrategy : UserStrategyBase { //Initialize public override void Initialize(BarHistory bars) { shl = new SwingHiLo(bars.High,13,3.50,13,3.50,0.00,false,false,false,false); PlotIndicator(shl); StartIndex = 14; } //Execute public override void Execute(BarHistory bars, int idx) { if (LastPosition?.IsOpen == true) { if (shl[idx] < shl[idx - 1]) PlaceTrade(bars, TransactionType.Sell, OrderType.Market); } else { if (shl[idx] > shl[idx - 1]) PlaceTrade(bars, TransactionType.Buy, OrderType.Market); } } //private members private SwingHiLo shl; } }
I especially loved how it completely side-stepped the COVID crash!! ;)
Hmm you're right. Never used them before but apparently the key to avoiding peeking are its companion functions in Community Components - and their implementation is missing in the WL7 version:
http://www2.wealth-lab.com/WL5WIKI/SwingFunctions.ashx
QUOTE:
These series display 'peaked' values from the (right side) swing bar until the bar since that is true to the RightBars or RightReversalAmount value. To overcome this, the returned series could be used in conjunction with associated methods IsSwingHi() and IsSwingLo(). Alternative a series could be built completely using these methods.
http://www2.wealth-lab.com/WL5WIKI/SwingFunctions.ashx
QUOTE:I agree. I would try fixing the problem so it doesn't peek in the first place; otherwise, it's misleading.
... fix the problem or if it's not possible, just expel such indicator because it's misleading.
Maybe I would just include a warning in the documentation for now until it's fixed. (This makes me wonder how good the fixed version will be?)
You mean I can’t trade my new Holy Grail?? 🥲
I think a clear flag in the indicators list and the description, which would be obvious but only appear for such flagged indicators, would be a step in the right direction.
I think a clear flag in the indicators list and the description, which would be obvious but only appear for such flagged indicators, would be a step in the right direction.
I feel this is pretty important so I’m going to add the warning flag for Build 10!
I remember many sad stories with "peeking" strategies through all the versions of WL.
Many users, full of hope, who discovered the "peeking issue" much too late - heavily disappointed.
So it is a good idea to get it better with WL7!
Many users, full of hope, who discovered the "peeking issue" much too late - heavily disappointed.
So it is a good idea to get it better with WL7!
QUOTE:
I remember many sad stories with "peeking" strategies through all the versions of WL.
Many users, full of hope, who discovered the "peeking issue" much too late - heavily disappointed.
So it is a good idea to get it better with WL7!
Isn't this really a "foundational" issue? Shouldn't WL7 PREVENT a user from ever peeking by its design??
Vince
No, WL offers a .NET framework for a developer to use to build a trading system. Adding such a restriction would be prohibitive and against our philosophy.
I tried to develop a solution to this issue in WL6.9 (I have not yet started running strategies in WL7), by re-defining “bars” so the indicator generated signals based on a bar prior to the most recently completed bar occurring in real time. So any signal generated is, in effect, “stale” but the results are still quite good.
WL operates like this by default. There’s no need to do the kind of manipulation you deceived.
What we are talking about here are just a few very specific indicators that have code that uses future information.
What we are talking about here are just a few very specific indicators that have code that uses future information.
I devised this specifically for use with SwingHiLo to deal with the settings of the "right" side parameter.
QUOTE:
GlitchA
May 29, 2021, 07:20 PM - 4 hours ago
#13
WL operates like this by default. There’s no need to do the kind of manipulation you deceived.
If this were true, WL code would automatically remove peeking from any script.
QUOTE:
I tried to develop a solution to this issue in WL6.9 (I have not yet started running strategies in WL7), by re-defining “bars” so the indicator generated signals based on a bar prior to the most recently completed bar occurring in real time. So any signal generated is, in effect, “stale” but the results are still quite good.
WL (6 and 7 and every other version) already executes signals on the bar following the one for which the signal was generated. There's simply no need to re-define "bars" like you described.
It all depends on the Swing indicators are used.
Used one way, they can create a peeking effect.
Used another way, they are robust, non-peeking indicators.
Used one way, they can create a peeking effect.
Used another way, they are robust, non-peeking indicators.
If the fractal indicator does not look to the future, then why does the swingHi (Lo) do it? Why not rewrite it in the likeness of the fractal indicator, only with a choice of parameters. Indeed, in fact, a fractal is a special case of a swingHi(Lo) indicator, only with a built-in parameter 2 (two bars on the left and two bars on the right around the extreme)
Sorry for the bump - I noticed the "peeking" warning in WL8 for the SwingHi indicator, which lead me to this discussion. Is there a way to check whether my usage of the indicator is peeking or not? I only found it through the indicator profiler, so I don't really follow what it's doing behind-the-scenes.
Don't get me started on this terrible, troublesome indicator. The only reason it's in WL is because the "Community" wanted it. If I were king, I would throw it in the circular file.
Isn't this clear?
Isn't this clear?
I don't see that, this is the message I see:
This message suggests that it can be used in trading decisions, if used correctly. But I will just avoid it entirely.
This message suggests that it can be used in trading decisions, if used correctly. But I will just avoid it entirely.
That Warning is still there, but many builds ago I added the extra bold guidance, so as not to be confused by that warning. Aren't you up-to-date with Wealth-Lab 8?
Sure, you can use it, but it peeks. Avoiding it entirely is the correct action!
Sure, you can use it, but it peeks. Avoiding it entirely is the correct action!
@mdosey:
You'll find detailed info on this indicator in the old WLab Wiki here:
https://www2.wealth-lab.com/WL5Wiki/SwingFunctions.ashx
The time it takes to read and truly understand this indicator is well worth it IMHO.
Used incorrectly, sure it peeks but used correctly there is NO peeking and you'll find it's a gem.
Likewise, used correctly the kitchen knife is safe but used incorrectly it can chop your finger off.
You'll find detailed info on this indicator in the old WLab Wiki here:
https://www2.wealth-lab.com/WL5Wiki/SwingFunctions.ashx
The time it takes to read and truly understand this indicator is well worth it IMHO.
Used incorrectly, sure it peeks but used correctly there is NO peeking and you'll find it's a gem.
Likewise, used correctly the kitchen knife is safe but used incorrectly it can chop your finger off.
Sammy, please show us one example of it being "used correctly". It's a challenge.
There's a simple logic to it: Retrieve the value of the indicator from 'n' bars ago where 'n' = Right Bars.
Here's how I actually use it in one of my weekly strategies:
Here's how I actually use it in one of my weekly strategies:
CODE:
// Initialize ... //Variables: (TimeSeries, LeftBars, LeftRvrslAmt, RightBars, RightRvrslAmt, EqualPrcThreshold, %mode, SetLeftSwings, SetOuterSwings, SetSteppedSeries) swLo = new SwingLo(bars.Low, 2, 0, 1, 0, 1E-06, true, false, false, true); ... ... // Execute double stp = swLo[idx-1] -0.01; //lookback period = RighttBars ...
Okay, very good. You compensate for the peeking by accessing a previous bar.
For others interested, another way to go about it is to shift the series to the right by the number of right bars. Then you can access the "current bar" of the TimeSeries. You can see the effect with this example.
For others interested, another way to go about it is to shift the series to the right by the number of right bars. Then you can access the "current bar" of the TimeSeries. You can see the effect with this example.
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript123 { public class MyStrategy : UserStrategyBase { public override void Initialize(BarHistory bars) { int rightbars = 1; IndicatorBase swLo = new SwingLo(bars.Low, 2, 0, rightbars, 0, 1E-06, true, false, false, true); PlotIndicator(swLo); TimeSeries swLo1 = swLo >> rightbars; // use swLo1 in the trading rules PlotTimeSeries(swLo1, swLo1.Description, "Price"); } //execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) { if (!HasOpenPosition(bars, PositionType.Long)) { //code your buy conditions here } else { //code your sell conditions here double stp = swLo1[idx] - 0.01; } } //declare private variables below TimeSeries swLo1; // non-peeking SwingLo series } }
👍
Cone, this last script does not produce the results shown by Glitch (graphically) earlier in this thread. Would it be possible to have an executable version of this script?
What is "this script"? I was just showing an alternative example of how not to peek with the indicator.
I'm sorry, Cone. I was referring to the strategy/discussion provided earlier in this thread by Glitch, which he referred to as a "Holy Grail".
I don't claim to know what this is doing, but I don't think it's peeking. Surprisingly , it still seems to beat buy and hold.
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; namespace WealthScript2 { public class MyStrategy : UserStrategyBase { //Initialize public override void Initialize(BarHistory bars) { int rightbars = 13; shl = new SwingHiLo(bars.High, 13, 3.50, rightbars, 3.50, 0.00, false, false, false, false); PlotIndicator(shl); StartIndex = 14; shlshifted = shl >> rightbars; } //Execute public override void Execute(BarHistory bars, int idx) { if (LastPosition?.IsOpen == true) { if (shlshifted[idx] < shlshifted[idx - 1]) PlaceTrade(bars, TransactionType.Sell, OrderType.Market); } else { if (shlshifted[idx] > shlshifted[idx - 1]) PlaceTrade(bars, TransactionType.Buy, OrderType.Market); } } //private members SwingHiLo shl; TimeSeries shlshifted; } }
Like I said, I don't know what these Swing Lo/Hi indicators are doing, but I know that if you use them, you're bound to be peeking. Here's a graphical explanation.
Even after shifting the bars to the right by the number of "right bars", 13, it's clear that if you use the delayed (shifted) series, you're still going to be peeking because the trend, trajectory, and value of the indicator often depends on a Swing point that's in the future.
Use these indicators at your own peril.
Even after shifting the bars to the right by the number of "right bars", 13, it's clear that if you use the delayed (shifted) series, you're still going to be peeking because the trend, trajectory, and value of the indicator often depends on a Swing point that's in the future.
Use these indicators at your own peril.
@Cone,
You missed an important point in the sample code I posted above... I did NOT use percentage reversals, only bars, to define swing pivots. When used like this it's 100% non-peeking and robust.
Side note: Can the developers please allow users to choose which discussions (other than the ones they created for which they're automatically notified) they get notified about when new comments get posted in them.
CODE:
swLo = new SwingLo(bars.Low, 2, 0, 1, 0, 1E-06, true, false, false, true);
You missed an important point in the sample code I posted above... I did NOT use percentage reversals, only bars, to define swing pivots. When used like this it's 100% non-peeking and robust.
Side note: Can the developers please allow users to choose which discussions (other than the ones they created for which they're automatically notified) they get notified about when new comments get posted in them.
QUOTE:
Side note: Can the developers please allow users to choose which discussions (other than the ones they created) they get notified about when new comments get posted in them.
See Bookmark / Notify buttons. Not easy to miss, they're in the header/footer of any topic.
I see them now, thanks Eugene!
Your Response
Post
Edit Post
Login is required