- Topics: 5
- Replies: 422
- Posts: 427
You should be able to achieve the result you are after using the BARINDEX() function instead of the ACC() setup you have in your example. You can then use an IF() to determine when to use the 100 / 200 offset vs the First Close in cases where there are less than 200 bars.
Here’s an example script:
//Find Bar Total
V1 = BARINDEX();
//Set Criteria if Bar Count is greater than 200
V2 = CLOSE(200) <= (CLOSE() * 1.5) and CLOSE(100) <= (CLOSE() * 1.5) ;
//Set Criteria if Bar Count is less than 200
V3 = FIRST(Close()) <= (CLOSE() * 1.5) ;
//Show result based on above rules
IF(V1 < 200,V3,V2)
I have checked it against codes with less than 200 bars, and those with more than 200 bars and the results returned look to be correct based on your description.
- This reply was modified 1 week ago by Matthew.