Drip's 11am rule breakout/breakdown For ThinkOrSwim

samer800

Moderator - Expert
VIP
Lifetime
Thank 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.
converted, check below

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
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

converted, check below

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
Thanks @samer800 for all your conversion.
I would like to add one more time period from 0300 to 0400
I tried to edit to edit the timing in the script but does not work..
May I request your help to create standalone script just for this timing only.

THanks
 
Thanks @samer800 for all your conversion.
I would like to add one more time period from 0300 to 0400
I tried to edit to edit the timing in the script but does not work..
May I request your help to create standalone script just for this timing only.

THanks
I added manual option to input the start and end of the cutoff time and end of session time.

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
# Added manual time frame input

input PredefinedTime = {"09:30-11:00", default "09:30-11:30", "09:30-10:00", "09:30-10:30"}; # "Cutoff time for indentifying HOD/LOD
input UseManualTimeFrame = no;
input cutoffStartTime    = 0930;
input CutoffEndTime      = 1130;
input sesstionEndTime    = 1600;
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 = if UseManualTimeFrame then cutoffStartTime else 0930;
def endTime   = if UseManualTimeFrame then CutoffEndTime else
                if PredefinedTime == PredefinedTime."09:30-11:00" then 1100 else
                if PredefinedTime == PredefinedTime."09:30-11:30" then 1130 else
                if PredefinedTime == PredefinedTime."09:30-10:00" then 1000 else 1030;
def remainStart = endTime;
def remainEnd  = if UseManualTimeFrame then sesstionEndTime else 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
 
I added manual option to input the start and end of the cutoff time and end of session time.

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
# Added manual time frame input

input PredefinedTime = {"09:30-11:00", default "09:30-11:30", "09:30-10:00", "09:30-10:30"}; # "Cutoff time for indentifying HOD/LOD
input UseManualTimeFrame = no;
input cutoffStartTime    = 0930;
input CutoffEndTime      = 1130;
input sesstionEndTime    = 1600;
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 = if UseManualTimeFrame then cutoffStartTime else 0930;
def endTime   = if UseManualTimeFrame then CutoffEndTime else
                if PredefinedTime == PredefinedTime."09:30-11:00" then 1100 else
                if PredefinedTime == PredefinedTime."09:30-11:30" then 1130 else
                if PredefinedTime == PredefinedTime."09:30-10:00" then 1000 else 1030;
def remainStart = endTime;
def remainEnd  = if UseManualTimeFrame then sesstionEndTime else 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
Thank You Samer800. Your conversion is much appreciated!
 
converted, check below

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
Thanks for your work. Are the times ET? If I'm on Central Time, do I need to change the times in the code?
 
A chart with explanations will be very helpful.
Thanks
B0DxNth.png
 
Thanks for your work. Are the times ET? If I'm on Central Time, do I need to change the times in the code?
This is a good question-did anyone respond? I am also central so maybe we should just go by 10am-and change our name to drip 10-thoughts? I

Thanks for your work. Are the times ET? If I'm on Central Time, do I need to change the times in the code?

I just downloaded the script today-I am still figuring it out
 
Last edited by a moderator:
Thanks for your work. Are the times ET? If I'm on Central Time, do I need to change the times in the code?
Thank you MerryDay
this is TOS version /ES March 28. I am on West Coast. Think we don't get Neon to upside?
This is a good question-did anyone respond? I am also central so maybe we should just go by 10am-and change our name to drip 10-thoughts? I
The canned answer from TDA is that the app runs on EST.
I am on the East Coast so don't have any input, currently.

It will be interesting hearing from all of you about how changing the script time settings is impacting various time zones.

Your feedback is crucial in helping members fine-tune and optimize this indicator

So, please don't hesitate to share your observations.
Your participation and input is what makes this a great community.
 
Last edited:
The canned answer from TDA is that the app runs on EST.
I am on the East Coast so don't have any input, currently.

It will be interesting hearing from all of you about how changing the script time settings is impacting various time zones.

Your feedback is crucial in helping members fine-tune and optimize this indicator

So, please don't hesitate to share your observations.
Your participation and input is what makes this a great community.
I'm the one who raised the question. I did change the times, dropping each time entry by 1 hour because I'm on Central Daylight Time. The red band at the top, and the green band at the bottom shifted to different times. I saw no other change. I don't see anything like the long signals nor the neon candles shown in the chart posted by you at 4:34 yesterday.
 
I'm the one who raised the question. I did change the times, dropping each time entry by 1 hour because I'm on Central Daylight Time. The red band at the top, and the green band at the bottom shifted to different times. I saw no other change. I don't see anything like the long signals nor the neon candles shown in the chart posted by you at 4:34 yesterday.
I am on West Coast. Did not change anything. My PC runs on PST. After download times are automatically adjusted. You can always test. If you are on West Coast, the zones should start at 8:30 AM if your PC is set to PST.
 
SecondsTillTime and SecondsFromTime are based on the exchange/server time, not the PC running it. So no user changes should necessary for US traders.

In my code, I do prefer using RegularSessionStart & RegularSessionEnd to get the market open/close in UTC format {then adding the necessary offsets to it), but I only do this in case someone outside of the US also wants to use the script. (I built a rudimentary library of time functions to do that and convert to/from HHMMSS & HHMM format, along with new SecsFromTime & SecsTillTime to handle dynamic time inputs. Let me know if you're interested and I'll upload it to a new post).
 
Thread starter Similar threads Forum Replies Date
samer800 The One Renko To Rule Them All For ThinkOrSwim Custom 8

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
410 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top