Scan for Extremes


I wish to write a script to scan for extremes on an indicator, in this case Force Index overlaid with Moving Average Bands.

As per diagram below, I have overlaid 3 Moving Average Bands with ATR channels on the Force Index indicator. I wish to write a scan that scans for when the Force Index indicator pops above/below the outer ATR channels (in this case 3 times ATR).

On the chart, I clicked in Force Index and then selected the MAB indicator to overlay on the Force Index. What I am struggling with is how do I bind the MAB to the Force Index indicator in a script?

Any help would be greatly appreciated.



The following script will work…

V1 = FI() ;
V2 = MAB(V1, OPTION=ATR, MULT=3.00, DEFAULT=UpperLine, BARS=20);
V3 = MAB(V1, OPTION=ATR, MULT=3.00, DEFAULT=LowerLine, BARS=20);
V1 CrossesAbove V2 or V1 CrossesBelow V3

This will find when a Force Index crosses above or below the 20 period MA Bands using a 3ATR setting. (Wasn’t sure what settings you used on the Force index so my script uses the default settings, you can adjust this to your own settings if they are different).


Green Shaded Zone shows where the criteria passes.



Thanks Matthew, worked a treat!