- ago
Just beginning to check out WL7....

1) What happened to the Community Indicators?

2) In particular, where are: SwingHi, SwingHiLo and SwingLo? Do they have a new name??
5
1,918
Solved
53 Replies

Reply

Bookmark

Sort
- ago
#1
1. On Where did Community Indicators go?:

https://www.wealth-lab.com/Discussion/Indicators-KAMA-HullMA-5534#post1
https://www.wealth-lab.com/Discussion/Where-is-Hull-Moving-Average-HullMA-5515#post4

We do plan to start a WealthLab.Community project on Github shortly to include users' contributions like indicators and classes/methods from Community Components together.

2. When reviewing what we're picking from Community Indicators for inclusion into WL7, the Swing Functions was left out as pure user code with unclear demand. http://www2.wealth-lab.com/WL5WIKI/SwingFunctions.ashx

WL7 now allows one to create a Custom Indicator without having to set up Visual Studio for development. Type in custom indicator in built-in Help for a how-to. Since the code of this user submission is open source in the WL6 Wiki you might be interested in giving it a try? If it works out, it could be included in WealthLab.Community on Github.
0
- ago
#2
The Swing indicators are a *hidden gem*. There's quite a bit of learning curve & experimentation involved in fully understanding them but when you get it you GET IT.
They are a crucial component in some of my strategies.

I don't have the programming skills to re-code this indicator so I would appreciate if the developers can restore this gem of an indicator.
0
- ago
#3
I agree with Sammy_G.
Swings and Peak/Trough are the most important indicators. It is a pity that they are not in the building blocks of systems.
0
- ago
#4
QUOTE:
Swings and Peak/Trough are the most important indicators. It is a pity that they are not in the building blocks of systems.


On second thought, what makes the Swing indicators different from the PeakTroughCalculator? In the Wiki on Swing Functions we find that Swings can be defined assymetrically by price or percent as well as bars, and plotted in a stepped or incremental style.

That's what The PeakTroughCalculator accomplishes.. It calculates peaks and troughs by observing when the data moves by a certain reversal amount, which can be expressed as either percent or point value. It has convenient methods like HasFallingPeaks(Troughs), HasRisingPeaks(Troughs), allows to get the top/bottom trendline, previous peaks/troughs etc. To my mind nothing it's a great replacement for Swing Functions.

A demo strategy "Peak Trough Analysis" (Sample Strategies folder) illustrates the application of the built-in PeakTroughCalculator class. Also, click on GetUpperTrendLine/GetLowerTrendLine for more code samples.
2
- ago
#5
The PeakTroughCalculator (PTC) is NOT the same as the Swing Indicators (SI)!!

Here are the notable differences:
- PTC uses BOTH a High (for a Peak) and a Low (for a Trough) to identify a swing whereas SI are based purely on any ONE of the 4 bar data points (O, H, L, C) that you specify
- PTC is symmetrical, SI can be asymmetrical, if so desired
- You cannot use a value of 0 in PTC whereas you can use it in some of the SI fields (0 essentially makes it independent of %age move)
- With SI, you can define separate swings using the High or Low
- etc.
PTC has its own uses but it's *not* a substitute for SI.

It takes a while to wrap one's head around all the ways you can use the Swing Indicators - but when you get it YOU GET IT!
I really wish the developers would re-incorporate these gems (SwingHi, SwingLo, SwingHiLo) in an upcoming build.
0
Glitch8
 ( 7.81% )
- ago
#6
PTC has three constructors. It can be based off Highs and Lows like you suggest, or based off a single TimeSeries. Additionally, it can be based on either a percentage or a raw price value. I’m not sure how passing a zero for reversal amount is useful?
1
- ago
#7
https://www2.wealth-lab.com/WL5WIKI/SwingFunctions.ashx
......
...to drop price-percent filtering set their parameter(s) to zero...
...to drop the bars quota set the left side parameter to zero...
---------------------------
---------------------------

Normally, the Swing function uses 2 values to identify when a swing Low (or High) has occurred:
- Number of bars
- Percent move (if using in % mode; if not then its in Points)

For bars to the Left of the index bar BOTH values must be true.
For bars to the Right of the index bar EITHER value needs to be met.

Here's how 0 works:
- When you set the number of bars ("bar quota) requirement to 0 only the % (or point) move value needs to be met
- When you set the % (or point) move requirement to 0 only the # of bars value needs to be met


Hth.
0
Glitch8
 ( 7.81% )
- ago
#8
Thanks, I see no reason why we can’t get these into our new WL7 Community Components!
1
- ago
#9
More about Peak/Trough. As Eugene wrote above, it is possible to use it in writing code in C#, but there are no indicators for using in building a system using blocks.
0
- ago
#10
@fred9999
This is something on our wish list for future development of Blocks.
0
- ago
#11
Thanks, Glitch - looking forward to their inclusion!!
1
Glitch8
 ( 7.81% )
- ago
#12
QUOTE:
there are no indicators for using in building a system using blocks.


By the way, the ZigZag and ZigZagHL indicators are indeed based off Peak/Trough calculations.
1
- ago
#13
Yes, I saw him. But the functionality of Zigzag is limited. For example, how to set in a block "BuyAtMarketOpen" the rule "if Close > Peak"?
0
- ago
#14
@Glitch
QUOTE:
Thanks, I see no reason why we can’t get these into our new WL7 Community Components!

Do you have an ETA when the Swing indicators will be restored? I've updated to build 6 and don't see them.
0
- ago
#15
Converting 90KB (1800+ lines) of 3rd party code is always an effort. Our team has a long todo list but few time and resources. Sorry but this will have to wait while we're working on higher priority items.

Because it's never been part of WL6, this will not appear in a "Build". Eventually we'll get to pushing this to WealthLab.Community library (which is ready to see the light with a few cosmetic methods and an indicator - but it's another work item for our super busy webmaster).

0
- ago
#16


Although I am not a programmer, I somehow programmed this indicator in a simplified form, in this case with parameter 6. To change a parameter, you need to add or remove lines from the code.

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; using System.Collections.Generic; namespace WealthScript3 { public class MyStrategy : UserStrategyBase { //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) {          zATR = new ATR(bars, 20);          StartIndex = 20; }        //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 (bars.High[idx-6] > bars.High[idx-5])             if (bars.High[idx-6] > bars.High[idx-4])                if (bars.High[idx-6] > bars.High[idx-3])                   if (bars.High[idx-6] > bars.High[idx-2])                      if (bars.High[idx-6] > bars.High[idx-1])                         if (bars.High[idx-6] > bars.High[idx])          if (bars.High[idx-6] > bars.High[idx-7])             if (bars.High[idx-6] > bars.High[idx-8])                if (bars.High[idx-6] > bars.High[idx-9])                   if (bars.High[idx-6] > bars.High[idx-10])                      if (bars.High[idx-6] > bars.High[idx-11])                         if (bars.High[idx -6] > bars.High[idx -12])                                           {                                              zSWH = bars.High[idx - 6];                                              DrawDot(idx-6, bars.High[idx -6] + 0.3 * zATR[idx-6], Color.Green, 3);                                           }     if (bars.Low[idx-6] < bars.Low[idx-5])             if (bars.Low[idx-6] < bars.Low[idx-4])                if (bars.Low[idx-6] < bars.Low[idx-3])                   if (bars.Low[idx-6] < bars.Low[idx-2])                      if (bars.Low[idx-6] < bars.Low[idx-1])                         if (bars.Low[idx-6] < bars.Low[idx])          if (bars.Low[idx-6] < bars.Low[idx-7])             if (bars.Low[idx-6] < bars.Low[idx-8])                   if (bars.Low[idx-6] < bars.Low[idx-9])                      if (bars.Low[idx-6] < bars.Low[idx-10])                         if (bars.Low[idx-6] < bars.Low[idx-11])                            if (bars.Low[idx -6] < bars.Low[idx -12])                                           {                                              zSWL = bars.Low[idx - 6];                                              DrawDot(idx -6, bars.Low[idx - 6] - 0.3 * zATR[idx -6], Color.Red, 3);                                           }           if (!HasOpenPosition(bars, PositionType.Long)) {             if (bars.Close[idx-1] < zSWH)                if (bars.Close[idx] > zSWH)             {                   PlaceTrade(bars, TransactionType.Buy, OrderType.Market);             } } else {                         if (bars.Close[idx] < zSWL)             {                PlaceTrade(bars, TransactionType.Sell, OrderType.Market);                             }    } }       //run after Execute has finished       public override void BacktestComplete()       {          DrawTradeLines(GetPositions(), false);       }       public void DrawTradeLines(List<Position> lst, bool showSignal = false)       {          for (int iPos = 0; iPos < lst.Count; iPos++)          {             Position position = lst[iPos];             int positionExitBar;             double positionExitPrice;             if (position.IsOpen)             {                positionExitBar = position.Bars.Count - 1;                positionExitPrice = position.Bars.Close[positionExitBar];             }             else             {                positionExitBar = position.ExitBar;                positionExitPrice = position.ExitPrice;             }             Color col;             if (position.PositionType == PositionType.Long)                col = (positionExitPrice - position.EntryPrice) > 0 ? Color.Green : Color.Red;             else                col = (positionExitPrice - position.EntryPrice) > 0 ? Color.Red : Color.Green;             DrawLine(position.EntryBar, position.EntryPrice, positionExitBar, positionExitPrice, col, 2, LineStyles.Dashed);             if (showSignal)             {                DrawBarAnnotation(position.EntrySignalName, position.EntryBar, position.PositionType == PositionType.Long, Color.Black, 12);                DrawBarAnnotation(position.ExitSignalName, position.ExitBar, position.PositionType == PositionType.Short, Color.Black, 12);             }          }       }       //declare private variables below       double zSWH, zSWL;       IndicatorBase zATR; } }


After the "Execute" comes the code for drawing the line of the beginning and end of the position, which was provided by Eugene.
0
Glitch8
 ( 7.81% )
- ago
#17
Wow, awesome job, Eugene this could be the first user contributed Community code?
0
- ago
#18
The code looks cool, fred.
But looking for something like this (note that chart scale is Weekly:


Corresponding code in WL6.9:
CODE:
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators; using Community.Indicators; namespace WealthLab.Strategies {    public class MyStrategy0 : WealthScript    {       protected override void Execute()       {          DataSeries SwLo = SwingLo.Series(Low, 0, 5, 1, 0, 1E-06, true, false, false, true);          //Variables: (DataSeries, LeftBars, LeftRvrslAmt, RightBars, RightRvrslAmt, EqualPrcThreshold, %mode, SetLeftSwings, SetOuterSwings, SetSteppedSeries)          //Setting LeftBars to 0 means no minimum bar #s reqd for min price % change; setting LeftRvrslAmt to 5 means minimum 5% change reqd          //for right side the reqt is 1 bar w/o a lower low, there's no % reqt          //in summary, the SwingLow bar is where the Low has declined atleast 5% from peak Low and the subsequent bar's Low has an equal or higher low          //this example illustrates how one can identify SwingLows (or Highs) using a mix of % + bar reqts          //one can also identify swings based on asymmetrical % and/or bar reqts, etc          PlotSeries(PricePane, SwLo, Color.DarkGreen, LineStyle.Dotted, 1);       }    } }
0
- ago
#19
@fred9999

Thank your for your code. To be universal, I would rewrite this fragment...
CODE:
if (bars.High[idx-6] > bars.High[idx-5]) if (bars.High[idx-6] > bars.High[idx-4]) if (bars.High[idx-6] > bars.High[idx-3]) if (bars.High[idx-6] > bars.High[idx-2]) if (bars.High[idx-6] > bars.High[idx-1]) if (bars.High[idx-6] > bars.High[idx]) if (bars.High[idx-6] > bars.High[idx-7]) if (bars.High[idx-6] > bars.High[idx-8]) if (bars.High[idx-6] > bars.High[idx-9]) if (bars.High[idx-6] > bars.High[idx-10]) if (bars.High[idx-6] > bars.High[idx-11]) if (bars.High[idx -6] > bars.High[idx -12])

...with a logic like this (untested):
CODE:
int bars = 6; if(bars.High.GetHighestBar(idx - bars, bars) == idx - bars)    if(Highest.Series(bars.High, bars)[idx] < Highest.Series(bars.High,6)[idx - bars])

Reverse with Lowest.Series.

On second thought, in the PowerPack extension (b3) we have the FractalDown/Up indicators to support a strategy by Bill Williams:
https://www.wealth-lab.com/extension/detail/PowerPack#changeLog

QUOTE:
An up (or buy) fractal is a minimum of 5-bar pattern where the center bar's low is less than the low of the two bars on either side of it.


http://www2.wealth-lab.com/WL5WIKI/FractalUp.ashx
http://www2.wealth-lab.com/WL5WIKI/FractalUpBar.ashx

Isn't this essentially the same "swing" concept, no?

WL6 also had this Gann Swing oscillator (not translated to WL7) but this requires consecutive rising/declining highs and thus is not equal to fred9999's logic:
http://www2.wealth-lab.com/WL5WIKI/GannSwingOscillator.ashx
0
- ago
#20
To Eugene:

Yes, a Fractal is a special case of a Swing with parameter 2:
SwingLo.Series(Low,2,0,2,0,1E-06,false,false,false,false) (WL6)

To Sammy_G

I am just using the swing indicator in a simplified way.
SwingLo.Series(Low,6,0,6,0,1E-06,false,false,false,false) (WL6)

To take into account all the parameters, we need an indicator from the developers, since I am weak in programming :)
0
- ago
#22
Sneak peek: SwingHiLo (Hi, Lo) are on their way to WealthLab.Community. Like I said, it still needs some work to expose that Github project to website.

2
- ago
#23
@fred,
From your parameters I'm guessing you're using Daily charts, I use weekly (less noise).

@Eugene,
😊
Hope 100% fidelity is maintained with WL6.9 - meaning, not just SwingHiLo indicator but also separate SwingHi and SwingLo indicators with all the options so one can use separate values, methods, & asymmetries, etc. with each (just as in WL6.9).
0
- ago
#24
Yes, all the constructors are preserved for motivated users to play with and tune. The settings dialog will look like this:

1
Best Answer
- ago
#25
👍, looking good!

Hope you're restoring not just the SwingHiLo but also the individual SwingHi and SwingLo indicators as they allow one to set parameters for each series independently (which is important).
0
- ago
#26
Yes, the "Plot companion indicators" checkbox on screenshot indicates that they can be plotted alongside SwingHiLo if desired - or by themselves.
0
- ago
#27
Can't wait to try them out...
0
- ago
#28
Upon further thinking I really believe all 3 indicators should be separate, standalone indicators, just as in WL6.9, for the following reasons:
- The SwingHiLo uses the 'bars' property as it uses *both* High & Low to calculate the swings whereas the SwingHi & SwingLo use *one* specified series (High, Low, Open, Close)
- It'll allow for using separate parameters for each
- It'll maintain the sanctity of the indicators as originally created
- It'll provide a seamless transition for all users currently using them in WL6.9
0
- ago
#29
They are standalone like ADX, DI- and DI+. "Plot companion indicator" is WL7's convenient feature. Try plotting ADX with checkbox on or off and see what happens.
0
- ago
#30
I get that but it seems (based on your screenshot above) that the companion indicators will have the same parameters as the parent indicator. What if you want different parameters OR just want to plot one instead of all three?
0
- ago
#31
In this case you can plot the indicators (or call a constructor or Series method in code) separately. Each TimeSeries will operate with a customized set of parameter values then.
0
- ago
#32
(I'm early in my WL7 learning curve so the following Q may appear silly)

So if I want to create & plot just one indicator series (say, SwingLo) I can do that in strategy code w/o creating/plotting all three? And would that be through the base (SwingHiLo) indicator or via SwingLo?

[*Delete after reading* Can you make the Reply box movable so it doesn't overlap previous answers? Thanks.]
0
- ago
#33
QUOTE:
So if I want to create & plot just one indicator series (say, SwingLo) I can do that in strategy code w/o creating/plotting all three?

Yes, just like in WL6.
0
- ago
#34
Looking forward to it.
0
- ago
#35
Thanks for including the Swing indicators in WL7 Build 7.
Took them on a test drive today. Results:

WL6.9




WL7 b7



The WL7 indicators don't adhere to the WL6 indicators as:
- EqualPriceThreshold is set as an integer but it should be double (this is *critical*)
- PercentMode, SetLeftSwings, SetOuterSwings, SetSteppedSeries are all set as integer but they should all be bool. After playing with them I realize that you've made an int value of 1 = true and 0 = false but this is not intuitive; besides, the values can be changed to other than 0 or 1 and the indicator is instantly nullified. To avoid 'unexpected' results these parameters should be set as boolean.
- SwingHiLo is using one TimeSeries for its calculation whereas in WL6 it uses bars as it needs both High and Low for each series, respectively

Hoping you can fix these soon.
0
- ago
#36
QUOTE:
- EqualPriceThreshold is set as an integer but it should be double (this is *critical*)

Minor bug fixed. Please look forward to Build 8. The rest works precisely as intended and requires no fix.

QUOTE:
- PercentMode, SetLeftSwings, SetOuterSwings, SetSteppedSeries are all set as integer

This is by design to allow to optimize on them:

https://www.wealth-lab.com/Discussion/Boolean-Parameter-Missing-From-Optimization-5793

QUOTE:
- SwingHiLo is using one TimeSeries for its calculation whereas in WL6 it uses bars as it needs both High and Low for each series, respectively

There are 4 method signatures that you can call from your C# strategy code. Two accept TimeSeries and two a BarHistory - the latter are what you need. Look them up with IntelliSense by pressing the up/down key on your keyboard as shown in my animated GIF:

0
- ago
#37
QUOTE:
EqualPriceThreshold

Looking forward to build 8.

Rest
I was only playing with Drag & Drop, will try in Strategy Code.
So you replaced bool with int in order to optimize... hmm, I have mixed feelings about that, perhaps it has a use. But I do believe a lot of people are going to trip over them if they set any value other than 0 or 1.
Anyway, if you intend to keep them as such:
- do modify the indicator descriptions as they've been copied from WL6 and still refer to those params as bool
- you may also wish to add a note on usage to avoid people nullifying the indicator
0
- ago
#38
Upon further reflection, I strongly believe PercentMode, SetLeftSwings, SetOuterSwings, SetSteppedSeries should be boolean (as originally) as there's nothing to optimize - PercentMode is a simple Yes or No and the other 3 are used for plotting only.

The only components of the indicators that may be worth optimizing are LeftBars, LeftReversalAmount, RightBars and RightReversalAmount which are already integers.
0
Glitch8
 ( 7.81% )
- ago
#39
What’s the issue with optimizing a Double? Int32 and Double parameters can both be optimized.
0
- ago
#40
Not talking about EqualPriceThreshold - which needs to be changed to a double - but about PercentMode, SetLeftSwings, SetOuterSwings, SetSteppedSeries which should be boolean, not int, see above.
0
Glitch8
 ( 7.81% )
- ago
#41
I would rather see those as Boolean too, and we can add a Feature Request to enable optimization on Boolean parameters.
1
- ago
#42
Checked in the change for Build 8:

1
- ago
#43
AWESOME!!!!!!!

(And please make sure Equal Price Threshold can handle up to 6 decimal places atleast).
0
- ago
#44
Thanks. Being a Double parameter, "Equal Price Threshold" will only be able to handle up to 2 decimals with 0.01 being the minimum and 0.0 by default. This is how it works in WL7. But of course in C# strategy code you have the freedom to use 6 decimal places and even more.
0
- ago
#45
Sounds good.
0
Glitch8
 ( 7.81% )
- ago
#46
Eugene, did you try assigning to the Parameter.StepValue? This is what's used to determine Decimals.
1
Glitch8
 ( 7.81% )
- ago
#47
Here I modified PSAR for demo purposes to assign a StepValue of 0.0001 to Acceleration.

0
- ago
#48
Sounds good, will do!

UPDATE: Done.
1
- ago
#49
These Indicators: SwingHi, SwingHiLo and SwingLo peek (heavily) into the future and should be marked as such.

A (naive) user will get fantastic backtest results using these indicators for entry conditions (or the like).

...and big frustrations in any real time endeavor.


I'll file a #FeatureRequest
0
- ago
#50
If it's a request for a warning sign for peeking indicators, then I doubt its necessity. Where do you see the problem in the code?
0
- ago
#51
@Dr Koch:
Depends on how you use it. Unlike the PeakTrough indicator the SwingHi/Lo/HiLo have an option to use LeftBars/RightBars (ie. # of bars) to define/complete a swing - and that's a robust, non-peeking use vs using % price movement.
0
- ago
#52
QUOTE:
Where do you see the problem in the code?


I see the problem in the chart. The lines drawn (and returned by the indicator) us a peak (or trough) in the future.

Or to put it differently:
If you base today's trading decision on the value of one of these indicators you will be surprised that the indicator changes its (past) values the next day.
0
- ago
#53
I have just started playing around with the swinghilo indicator, but how do you successfully use it and prevent "peeking" (or "repainting" as many other traders refer to it as)?

The documentation says you add isswingHi and isSwingLo? Does that mean you just add a swingLo and swing hi function to the swinghilo strategy?

Is it possible to show an example code or settings snippet for a novice coder like myself to utilize to prevent said peeking/repainting with these type of indicators?
0

Reply

Bookmark

Sort