rlohmeyer
Active member
Hi,
I extracted code from an opening range breakout indicator, posted below. It defines the opening range as the first 30 minutes of the Regular Session. I am looking for how to modify or add to this code to allow me to define an average of the opening range for any particular instrument for the past x days. This would allow me to add labels or run scans for the instruments that have the largest initial ranges, which is useful for playing the opening range after the first 1-5 minutes.
Can anyone assist? Much appreciated.
I extracted code from an opening range breakout indicator, posted below. It defines the opening range as the first 30 minutes of the Regular Session. I am looking for how to modify or add to this code to allow me to define an average of the opening range for any particular instrument for the past x days. This would allow me to add labels or run scans for the instruments that have the largest initial ranges, which is useful for playing the opening range after the first 1-5 minutes.
Can anyone assist? Much appreciated.
Code:
# 30 min opening range Market Volatility V1.1
# Robert Payne
# Adapted to strategy by WalkingBallista and BenTen
#https://usethinkscript.com/threads/opening-range-breakout-strategy-with-market-volatility-for-thinkorswim.164/
#@rlohmeyer code extracted to determine actual size of opening range
def OpenRangeMinutes = 30;
def MarketOpenTime = 0930;
def ShowTodayOnly = no;
def Today = if GetDay() == GetLastDay() then 1 else 0;
def FirstMinute = if SecondsFromTime(MarketOpenTime) < 60 then 1 else 0;
def OpenRangeTime = if SecondsFromTime(MarketOpenTime) < 60 * OpenRangeMinutes then 1 else 0;
def ORH = if FirstMinute then high else if OpenRangeTime and high > ORH[1] then high else ORH[1];
def ORL= if FirstMinute then low else if OpenRangeTime and low < ORL[1] then low else ORL[1];
#code added to determine size of opening range
def HL = Round(ORH - ORL, 2);