It's an indicator that plots the spread between two selectable instruments and also each individual instrument's line chart, with a colored fill to make it more clear visually when trading ratios.
In cointegrated pairs like audcad-0.50% , you can trade the range extremes, and buy the laggard/sell the leader when overbought/sold conditions are met + distance from the 66/253 EMAs, as outlined in my AUDCAD-0.50% post. (see related ideas)
Hope you find it useful!
study("Pair trader", overlay=true) Pair1 = security((input("FX_IDC:audusd")), input("D"), hl2) Pair2 = security((input("FX_IDC:nzdusd")), input("D"), hl2) PairA = plot(Pair1, color=yellow) PairB = plot(Pair2, color=black) fill(PairA, PairB, white, 80, "Spread") Spread = Pair1 - Pair2 plotarrow(Spread, colorup=teal, colordown=orange, transp=80)