- Topics: 4
- Replies: 190
- Posts: 194
There’s a few issues with the script you’ve setup…
On the V3 variable you set, you have the Close() being lower than V1, however V1 is a Boolean (True or False), so V1 only returns a 1 or a 0, so depending on the chart, the Close won’t be lower than that. You don’t really need this part of V3 for the script to return the result you’re after.
V3 is also using V1 * 0.98, as per above, with V1 being a Boolean, this won’t be within 2% of the 20 day high, but of the 1 or 0. You need to split V1 into two variables, one for the 20 day high value itself, and another where the High() > than the 20 day high.
Also in the V3 variable you have a TimeSinceSignal() function, but it’s not referencing an event, it’s been left blank (but it’s been setup correctly in the V2 line).
The adjusted script would look like this:
//Calc 20Day High
V1 = HIGHESTHIGH(BARS=20, BACKTYPE=Days);
V2 = HIGH() > V1 ;
//Has it changed in the last 10 days
V3 = TIMESINCESIGNAL(V2) <=10 ;
//Close occurring within last 2 days comes within 2% of recent 20 Day High
V4 = CLOSE() > (V1*0.98);
V5 = TIMESINCESIGNAL(V4) <=2 ;
V3 and V5