converted, check belowThank you. I think Drip 11 is more than open range indicator, it also draws cloud, arrows and color codes candles when there is strong trend in one direction to avoid many fake outs (no indicator is 100% accurate). If you can incorporate these into open range indicator, that could make it close to Drip 11.
Yesterday SPY/QQQ is perfect example, it indicated strong downward trend after 11am.
CODE:
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © sensir
#indicator("Drip's 11am rule breakout/breakdown", overlay = true)
# converted and mod by Sam4Cok@Samer800 - 03/2023
input timeFilter = {"09:30-11:00", default "09:30-11:30", "09:30-10:00", "09:30-10:30"}; # "Cutoff time for indentifying HOD/LOD
input fastMAInput = 9; # "Fast EMA Period"
input slowMAInput = 21; # "Slow EMA Period"
input midMAInput = 13; # "Mid EMA Period"
input srcHi = high; # "Source for Highs"
input srcLo = low; # "Source for Lows"
input showHi = yes; # "Show HOD breakout zone"
input showLo = yes; # "Show LOD breakdown zone"
input showMid = yes; # "Show Mid breakdown zone"
input showCloud = yes; # "Show cloud for breakout and breakdown"
input showTrendArrow = yes; # "Show trend arrows for breakout and breakdown"
input showCandleMomentum = no; # "Show candlesticks with strong upside/downside momentum"
def na = Double.NaN;
#--------Color
DefineGlobalColor("green" , CreateColor(76,175,80));
DefineGlobalColor("Red" , CreateColor(255,82,82));
DefineGlobalColor("dgreen" , CreateColor(40, 93, 42));
DefineGlobalColor("dRed" , CreateColor(121,5,5));
def startTime = 0930;
def endTime = if timeFilter == timeFilter."09:30-11:00" then 1100 else
if timeFilter == timeFilter."09:30-11:30" then 1130 else
if timeFilter == timeFilter."09:30-10:00" then 1000 else 1030;
def remainStart = endTime;
def remainEnd = 1600;
def dOpen = open(PEriod = AggregationPeriod.DAY);
def dh = high(PEriod = AggregationPeriod.DAY);
def dl = low(PEriod = AggregationPeriod.DAY);
def rsi = RSI(PRice = close[1], Length = 14);
#ta.dmi(diLength, adxSmoothing)
script f_dmi {
input diLength = 14;
input adxSmoothing = 14;
def hiDiff = high - high[1];
def loDiff = low[1] - low;
def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM = if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
def ATR = MovingAverage(AverageType.WILDERS, TrueRange(high, close, low), diLength);
def "DI+" = 100 * MovingAverage(AverageType.WILDERS, plusDM, diLength) / ATR;
def "DI-" = 100 * MovingAverage(AverageType.WILDERS, minusDM, diLength) / ATR;
def DX = if ("DI+" + "DI-" > 0) then 100 * AbsValue("DI+" - "DI-") / ("DI+" + "DI-") else 0;
def ADX_ = MovingAverage(AverageType.WILDERS, DX, adxSmoothing);
plot diplus = "DI+";
plot diminus = "DI-";
plot adx = ADX_;
}
#f_insession(_session) =>
script f_insession {
input _sessionStart = 0930;
input _sessionEnd = 1030;
def insession = if SecondsTillTime(_sessionEnd) > 0 and SecondsFromTime(_sessionStart) >= 0 then 1 else 0;
plot return = insession;
}
#// Check to see if we are in allowed hours using session info on all 7 days of the week.
def timeIsBeforeCriteria = f_insession(startTime, endTime);
def hiBeforeCriteria;# = 0.0000000010;
def loBeforeCriteria;# = 100000000000;
if timeIsBeforeCriteria {
if !timeIsBeforeCriteria[1] {
hiBeforeCriteria = srcHi;
loBeforeCriteria = srcLo;
} else {
hiBeforeCriteria = Max(srcHi, hiBeforeCriteria[1]);
loBeforeCriteria = Min(srcLo, loBeforeCriteria[1]);
}
} else {
hiBeforeCriteria = hiBeforeCriteria[1];
loBeforeCriteria = loBeforeCriteria[1];
}
#// Calculate the fast and slow moving averages
def fastMA = ExpAverage(close, fastMAInput);
def slowMA = ExpAverage(close, slowMAInput);
def midMA = ExpAverage(close, midMAInput);
#// Average Directional Index (ADX)
def th = f_DMI(7, 3).diplus;
def tl = f_DMI(7, 3).diminus;
def adx = f_DMI(7, 3).ADX;
#// Identify sideways market using ADX
def sideways = adx < 30;
def uptrend = th > 30 and th < 70;
def downtrend = tl >30 and tl < 70;
#// Fill the price bars with a specific color when ADX is below 20
AssignPriceColor(if uptrend and showCandleMomentum then Color.CYAN else
if downtrend and showCandleMomentum then Color.MAGENTA else Color.CURRENT);
def remainingSession = f_insession(remainStart, remainEnd);
def t1 = remainingSession;
def time = GetTime();
#// Check if the stock is trading above ...
def condition1 = close > slowMA and close > dOpen;
#// Check if the stock is making a new high after time specified by user
def condition2 = t1 and close > (hiBeforeCriteria * 1.001) and close[1] > (hiBeforeCriteria * 1.001);
def upConvictionArrow = showTrendArrow and th > 25 and condition1 and condition2 and (close > fastMA);
#// plot hi and low at 11
plot resistanceLowerBound = if t1 and showHi then hiBeforeCriteria else na; # "HOD lower limit"
plot resistanceUpperBound = if t1 and showHi then hiBeforeCriteria * 1.001 else na; # "HOD upper limit"
resistanceLowerBound.SetDefaultColor(GlobalColor("Red"));
resistanceUpperBound.SetDefaultColor(GlobalColor("Red"));
AddCloud(resistanceLowerBound, resistanceUpperBound, GlobalColor("dRed")); # "HOD breakout zone"
plot supportLowerBound = if t1 and showLo then loBeforeCriteria*0.999 else na; # "LOD lower limit"
plot supportUpperBound = if t1 and showLo then loBeforeCriteria else na; # "LOD upper limit"
supportLowerBound.SetDefaultColor(GlobalColor("green"));
supportUpperBound.SetDefaultColor(GlobalColor("green"));
AddCloud(supportUpperBound, supportLowerBound, GlobalColor("dgreen"));# "LOD breakdown zone")
def fastPlot = if condition1 and condition2 and showCloud then slowMA else na;# "Fast EMA support line"
def slowPlot = if condition1 and condition2 and showCloud then fastMA else na;# "Slow EMA support line"
AddCloud(slowPlot, fastPlot, Color.DARK_GREEN, Color.DARK_GREEN, yes); # "Breakout support cloud"
plot shapeUp = if upConvictionArrow then low else na; # "Breakout conviction arrow"
shapeUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
shapeUp.SetDefaultColor(Color.CYAN);
#// Check if the stock is trading below both moving averages
def condition3 = close < slowMA and close < dOpen;
def condition4 = t1 and close < (loBeforeCriteria * 0.999) and close[1] < (loBeforeCriteria * 0.999);
def downConvictionArrow = showTrendArrow and tl > 25 and condition3 and condition4 and (close < fastMA);
#// Combine the conditions and plot the result
def fastPlot1 = if condition3 and condition4 and showCloud then slowMA else na; # "Fast EMA resistance line"
def slowPlot1 = if condition3 and condition4 and showCloud then fastMA else na; # "Slow EMA resistance line"
AddCloud(fastPlot1, slowPlot1, Color.DARK_RED, Color.DARK_RED, yes); # "Breakdown resistance cloud"
plot shapeDn = if downConvictionArrow then high else na; # "Breakdown conviction arrow"
shapeDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
shapeDn.SetDefaultColor(Color.MAGENTA);
def mid = (if(t1,hiBeforeCriteria,na) + if(t1,loBeforeCriteria,na)) / 2;
plot midLine = if showMid then mid else na;
midLine.SetDefaultColor(Color.GRAY);
midLine.SetPaintingStrategy(PaintingStrategy.DASHES);
#--- END of CODE