Thanks for your reply.
Swing is a complex indicator and it does take some study (and testing) to get things figured out.
Your results would be expected based on your coding. For example, this: recentLow = Swing(5).SwingLow[0]; provides the most recent occurrence of the swing low value while this: priorLow = Low[Swing(5).SwingLowBar(0, 1, 50)]; gets the most recent swing low bar and the low value which would be the same as Swing(5).SwingLow[0];. The swing low value will continue to remain the same on each bar until a new swing low is determined 5 bars after the actual swing low.
The key here is to note that in the help guide for Swing(int strength).SwingLowBar(int barsAgo, int instance, int lookBackPeriod) The helpguide advises that instance = The occurrence to check for (1 is the most recent, 2 is the 2nd most recent, etc...)
So by specifying 1 you are getting the most recent swing low bar. The "prior swing low bar" would be specified as 2.
So all you need to do is to add 1 to each of the "instances" in your code:
prior3Low = Low[Swing(5).SwingLowBar(0, 4, 50)];
prior3High = High[Swing(5).SwingHighBar(0, 4, 50)];
prior2Low = Low[Swing(5).SwingLowBar(0, 3, 50)];
prior2High = High[Swing(5).SwingHighBar(0, 3, 50)];
priorLow = Low[Swing(5).SwingLowBar(0, 2, 50)];
priorHigh = High[Swing(5).SwingHighBar(0, 2, 50)];
recentLow = Swing(5).SwingLow[0];
recentHigh = Swing(5).SwingHigh[0];
Please also note that you may need to test the bars ago overload for a value of -1 as noted in the helpguide if for example the 4th or 3rd occurrence is not found in the lookback period of 50.
Comment