Optuma Forums › Optuma Scripting › Persistency of X › Reply To: Persistency of X
March 3, 2022 at 8:53 am
#67636
- Topics: 5
- Replies: 609
- Posts: 614
Hi,
I would use the BarsTrue() function to find the point where MFI has been above 50 for 20 bars, then use switch to keep the value true until the MFI crosses below 50.
1 2 3 4 5 6 7 8 9 10 11 12 |
//Set Money Flow Index V1 = MFI() ; //Is MFI Higher than 50 V2 = V1 > 50; //MFI crosses below 50 V3 = V1 CrossesBelow 50; //MFI has been higher than 50 for 20 days V4 = BARSTRUE(V2, LOOKBACK=20) == 20; //MFI higher than 50 for 20 bars, switch to false after MFI crosses below 50 SWITCH(V4,V3) |
Chart example: