I am having trouble with BARSTRUE so that every bar for custom indicators is below 1.00 for the last 10 bars. So far I have below but is not performing correctly. Can someone please assist? Thanks
R1 = ANY CUSTOM INDICATOR
BARSTRUE(R1, LOOKBACK=10) < 1.00
In your first script example, that scan would only return a pass if the number of bars that met the criteria over the last 10 days was zero.
If you look at the example in my reply you can see that the BarsTrue (when using a look back period of 10) will procedure a result that oscillates between 0 and 9. A result of zero means none of the bars checked passed the criteria, and 9 means all bars checked passed the criteria.
For the simplest example, set the criteria to be Close() > Open() and use that with BarsTrue(), the output will change between 0 to 9.
To use it with a scan i’d just need to adjust the BarsTrue line to output a Boolean result. For example:
Would mean the criteria would have to have passed 5 out of 10 bars to pass.
With your second script, the line would output the Moving Average value. To convert it to a Boolean you have to setup a rule. I’m not sure what you’re looking for but some common examples are
Close() > MA()
or
MA() IsUp
Anything that returns a 1 or 0 result will work with BarsTrue()