REM calculating expectedRange
sumRange = 0
FOR i = 1 TO periods DO
sumRange = (Dhigh(i) - Dlow(i)) + sumRange
NEXT
expectedRange = sumRange/periods
REM calculating opportunity
longOpp = Dlow(0) + expectedRange - close
shortOpp = close - Dhigh(0) +expectedRange
RETURN 0 COLOURED(0,255,0) AS "MIN", longOpp COLOURED(0,255,0) AS "LONG", shortOpp COLOURED(255,0,0) AS "SHORT", expectedRange COLOURED(255,0,0)AS "MAX"