- ago
Since the SwingHiLo indicator looks to the future, it would be nice to have a similar indicator that does not look to the future.

Such an indicator, which is widely used in various technical analysis programs, is called differently: swing, pivot, fractal, etc.

Wealth-Lab has the FractalUp and FractalDown indicator, but in a simple form with a period of 2, without the ability to change the indicator period.

For example, this is how it looks in TradingView, where you can set any period:

1
869
19 Replies

Reply

Bookmark

Sort
- ago
#1
We've got the GannSwing indicator that does the same in the PowerPack but with the hardcoded period of 2 - as per the original concept of William Gann. I see no harm to customize the "period" (i.e. the number of bars before and after the peak/trough bar). Let's make it flexible in the next build of PP.
0
Cone8
 ( 24.99% )
- ago
#2
GannSwing isn't the same thing. Why not add the period to FractalUp and FractalDown (and Bar methods) making the Period an optional parameter so as not to break anything?
1
- ago
#3
A good idea, but since GannSwing is an oscillator with values of 0-1, this will not solve the main purpose - building strategies from blocks to open positions on local lows and highs. For example:

0
- ago
#4
QUOTE:
Why not add the period to FractalUp and FractalDown (and Bar methods) making the Period an optional parameter so as not to break anything?

Added in PowerPack B23.
3
- ago
#5
In a failed "attempt" to understand fractals better, I tried to convert the WL6 fractal demo example into WL8. What I got below is a total mess.


Could someone please fix my conversion below so it makes better sense? I'm running PowerPack Build 22.
CODE:
using WealthLab.Backtest; using WealthLab.Core; using WealthLab.PowerPack; namespace WealthScript4 {    public class FractalDemo : UserStrategyBase    {       //Based from WL6 code: www2.wealth-lab.com/WL5Wiki/FractalUp.ashx       static readonly string upFractal = "\x87";       static readonly string dnFractal = "\x88";              public void ShowFractals(TimeSeries fractalUpBars, TimeSeries fractalDnBars)       {          WLFont dingbats = new WLFont("Wingdings 3", 18, true);          for (int n = 5; n < fractalUpBars.Count; n++)          {             if (fractalUpBars[n] > fractalUpBars[n-1])                DrawBarAnnotation(upFractal, (int)fractalUpBars[n], true, WLColor.DarkGreen, 18, font: dingbats);                          else if (fractalDnBars[n] > fractalDnBars[n-1])                DrawBarAnnotation(dnFractal, (int)fractalUpBars[n], false, WLColor.DarkRed, 18, font: dingbats);          }       }       public override void Initialize(BarHistory bars)       {          /* Fractals */          TimeSeries frUpBar = new FractalUpBar(bars.High);          TimeSeries frDnBar = new FractalDownBar(bars.Low);          ShowFractals(frUpBar, frDnBar);          FractalUp frUp = new FractalUp(bars.High);          FractalDown frDn = new FractalDown(bars.Low);          PlotIndicator(frUp, WLColor.Blue, PlotStyle.Dots);          PlotIndicator(frDn, WLColor.Fuchsia, PlotStyle.Dots);       }       public override void Execute(BarHistory bars, int idx) { }    } }
0
- ago
#6
It's simply a copy/paste error:
CODE:
//DrawBarAnnotation(dnFractal, (int)fractalUpBars[n], false, WLColor.DarkRed, 18, font: dingbats); DrawBarAnnotation(dnFractal, (int)fractalDnBars[n], false, WLColor.DarkRed, 18, font: dingbats);
1
- ago
#7
Wow, I didn't see that typo until I studied your correction for over a minute. Yes, that fix makes a big difference. Thanks for the help!

The FractalUp and FractalDown indicators are based on Bill Williams' book, Trading Chaos.
0
- ago
#8
I replaced the FractalUp and FractalDown dot plots with one PlotIndicatorBands plot, which looks less cluttered.
CODE:
         FractalUp frUp = new FractalUp(bars.High);          FractalDown frDn = new FractalDown(bars.Low);          PlotIndicatorBands(frUp, frDn, WLColor.Yellow, 1, 7);          //PlotIndicator(frUp, WLColor.Blue, PlotStyle.Dots);          //PlotIndicator(frDn, WLColor.Fuchsia, PlotStyle.Dots);

The screenshot below includes the recommended fix discussed in Post #6.

0
- ago
#9
I see that the period was added to the indicator, but now it does not work correctly

0
- ago
#10
True. Back to the drawing board.
0
- ago
#11
Just wanted to add to @fred9999's note of Jun 15th...

I plotted a 4-period (n=4) FractalDown indicator on the daily chart of SPY:


There are 2 issues:
- the indicator starts plotting 1 (occasionally 2) bars before 'n' bars have passed since the Pivot Low was formed; I highlighted the most recent one though others are also visible in the pic
- the value of this aberrant 1-bar-early plot always equals the Low of the bar preceding the Pivot Low... perhaps this may provide a clue as to the fix
0
- ago
#12

--------------------------


-------------------------


-------------------------


-------------------------


-------------------------


0
- ago
#13
What's the problem?
0
- ago
#14
If the period is 10, then on the right and left there should be 10 bars below the fractal. Only then does it become a fractal.



Here there are 10 bars on the left, and only three on the right. Therefore it cannot be a fractal.

0
- ago
#15
Your screenshot in Post #14 confuses me. What it's showing is the FractalDown(Low) indicator. That's the blue line, reflected by the indicator's blue label on the chart. A penetration of an interim high does not reset the low count. You're treating the FractalDown as it would be FractalUp.
0
- ago
#16
Okay, so as not to confuse the FractalDown, let’s remove it. Now the entry is at the breakout of the FractalUP(10), and the exit is in five days.

0
- ago
#17
The indicator code should be something like this:

CODE:
int n = 10 if (bars.High[idx -n] > Highest.Value(idx, bars.High, n)) if (bars.High[idx - n] > Highest.Value(idx-n-1, bars.High, n )) FRACTAL_UP = bars.High[idx - n];
0
- ago
#18
I was flicking through some charts and an aberrant FractalUp (High, 5) plot caught my eye:
Symbol: QQQ/ Scale: Daily/ WealthData/ Time frame evaluated: Nov-Dec 2023


The 6-bar plot of FractalUp (from 11/28/23 - 12/5/23) starts plotting with a value of 391.41 which was the high of 11/20/23 bar but...
- on 11/22/23, 2 bars later, there was a higher High at 393.07
- on 11/29/23, 4 bars later, there was another higher High at 394.14

By definition, there should be 'n' bars (here, 5) on either side of the High for it to be labelled a fractal. That entire 6-bar plot of FractalUp shouldn't be there.
Hopefully this'll get fixed soon.

P.S.
- didn't check other values besides 5
- didn't check FractalDown
0
- ago
#19
Thanks for bringing our attention to the bug. We'll get it squashed for PowerPack B41.
1

Reply

Bookmark

Sort