Hello, I have tested below with many custom indicators with same inconsistent results. I believe my error lies somewhere else but going through many, many variations are unable to detect it. If someone could please assist with below:
Requiring:
Current low of custom indicator is lower than the lowest low of custom indicator over the last 50 bars.
This is what I have:
V1 = ANY CUSTOM INDICATOR;
L1 = LOWESTLOW(V1,RANGE=Look Back Period,EQUAL=False, BARS=50);
V1 < L1[1]
//Custom Indicator Calculation
V1 = MA((CLOSE() + CLOSE(1)) / (OPEN() + OPEN(1)), BARS=50);
//Lowest Low of custom indicator in the last 50 bars
V2 = LOWESTLOW(V1, BARS=50) ;
//Is the custom indicator lower than the lowest low of the last 50 bars
V1 < V2
This is how it appears on the chart:
Anytime the blue line drops below the red line, a true result is returned by the script.
Just to add to what Matt Humphreys wrote, the LOWESTLOW and HIGHESTHIGH functions have a “Use Last Bar” value which is off by default. That switch is specifically for scripting so that you do not need to do the L1[1] offset. The reason for this is that we can not get a break if today’s low value is included in the lowestlow calculation.
//Custom Indicator Calculation
V1 = MA((CLOSE() + CLOSE(1)) / (OPEN() + OPEN(1)), BARS=50);
//Lowest Low of custom indicator in the last 50 bars
V2 = LOWESTLOW(V1, BARS=50) ;
//Is the custom indicator lower than the lowest low of the last 50 bars
V1 < V2
how would you ignore any V1 result that returned zero. I tried adding a:
V1B = V1>0 and substituting the other V1’s for for V1B’s though were unsuccessful?
So in the case of a script where a zero value can be returned, for example:
V1 = CLOSE() IsUp ;
IF(V1==1,Close(),0)
You can wrap the last line in a NonZero() function. When that is done, in instances where a zero would be returned, the previous days value is used instead…