#### netarchitech

##### Well-known member

@BenTen I attempted to convert the strategy to a scan:

While it compiles with no errors, it has not generated any results either. Please test when you have a chance... Thanks...

Good Luck and Good Trading

Rich (BB code):

```
# 30 min opening range Market Volatility V1.1 SCAN
# Robert Payne
# Adapted to strategy by WalkingBallista and BenTen
# https://usethinkscript.com/d/164-algo-trading-breakouts-indicator-for-thinkorswim
input atrlength = 14;
input avglength = 500;
def vol = reference ATR(atrlength, averageType = AverageType.SIMPLE);
def avgvol = Average(vol, avglength);
def calm = vol < avgvol - (avgvol * .1);
def neutral = avgvol + (avgvol * .1) > vol > avgvol - (avgvol * .1);
def volatile = vol > avgvol + (avgvol * .1);
def window = vol - avgvol;
def OpenRangeMinutes = 30;
def MarketOpenTime = 0930;
def LastBar = SecondsFromTime(1530) == 0;
input TimeToStopSignal = 1525;
def TradeTimeFilter = SecondsFromTime(TimeToStopSignal);
input ShowTodayOnly = no;
input ema1_len = 8;
input ema2_len = 13;
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 ORHigh = if FirstMinute then high else if OpenRangeTime and high > ORHigh[1] then high else ORHigh[1];
def ORLow = if FirstMinute then low else if OpenRangeTime and low < ORLow[1] then low else ORLow[1];
def OpenRangeHigh = if ShowTodayOnly and !Today then Double.NaN else if !OpenRangeTime then ORHigh else Double.NaN;
def OpenRangeLow = if ShowTodayOnly and !Today then Double.NaN else if !OpenRangeTime then ORLow else Double.NaN;
def dailyRange = high(period = "day" )[1] - low(period = "day" )[1];
def range = Average(dailyRange, 10);
def ema1 = MovAvgExponential(length=ema1_len);
def ema2 = MovAvgExponential(length=ema2_len);
# Bullish
plot buy_bullish = ((close crosses above OpenRangeHigh) OR (ema1 crosses above OpenRangeHigh)) and TradeTimeFilter < 1 and volatile;
#def sell_bullish = ema1 crosses below ema2 or (close < OpenRangeHigh) or LastBar;
# Bearish
#plot short_bearish = ((close crosses below OpenRangeLow) OR (ema1 crosses below OpenRangeLow)) and TradeTimeFilter < 1 and volatile;
#def cover_bearish = ema1 crosses above ema2 or (close > OpenRangeLow) or LastBar;
```

Good Luck and Good Trading

Last edited: