PeakBar and TroughBar as a bar index for price AND reference to peaks "n" peaks ago
Author: johnls101
Creation Date: 3/21/2018 9:10 AM
profile picture

johnls101

#1
I wish to be able to use peakbar and troughbar as bar references for comparison with changes in price at the same bar locations defined by these series. I have probably made a basic error with syntax, but I would appreciate some help.

e.g. Having defined a dataseries "troughbar", I would have thought that I could then find the int at "bar" from this series. If I include "int TB = troughbar[bar];" below, the code doesn't compile.
The intention of defining this int is to use it in some sort of price comparison such as "if( Low[TB] < Low[LB], SellAt etc )". I am wondering what I am missing?

Also, if there is a more sophisticated way of looking at a peak which was "n" peaks ago, I would appreciate the suggestion.



CODE:
Please log in to see this code.
profile picture

Eugene

#2
QUOTE:
e.g. Having defined a dataseries "troughbar", I would have thought that I could then find the int at "bar" from this series

As per the WealthScript Programming Guide, a DataSeries is a series of floating point data values of type double. Consequently, each value in the series is double precision (14 to 15 significant digits). Which applies to the troughbar etc. as well. Consequently, if you wish to avoid the compile error you have to convert the value from double to integer. This can be done in a multitude of ways one of which is to cast them:

CODE:
Please log in to see this code.


QUOTE:
Also, if there is a more sophisticated way of looking at a peak which was "n" peaks ago, I would appreciate the suggestion.

There are numerous examples scattered across the downloadable Strategies, Wiki and our forum. If you're really after sophisticated ways we've got 'em:

ZigZag Class
TASC 2013-06 | The 1-2-3 Wave Count (Vervoort)
TASC 2013-07 | The Step Candle Pattern (Vervoort)
profile picture

johnls101

#3
Thanks so much Eugene.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).