TOS Indicators Opening Range Breakout (ORB) Indicator For ThinkOrSwim

woulf1004

Member
VIP
Hi,

I found this:
https://tosindicators.com/indicators/opening-range-breakout
was wondering if this ORB indicator can be modified so it can plot as show on expansion as well?


input entryType = {default wickTouch, closeAbove};

input openingRangeStartTimeEST = 930;
input openingRangeEndTimeEST = 1000;

input tradeEntryStartTimeEST = 1000;
input tradeEntryEndTimeEST = 1100;

def openingRange = if SecondsTillTime(openingRangeStartTimeEST) <= 0 and SecondsTillTime(openingRangeEndTimeEST) >= 0 then 1 else 0;

def openingRangeHigh = if SecondsTillTime(openingRangeStartTimeEST) == 0 then high else if openingRange and high > openingRangeHigh[1] then high else openingRangeHigh[1];

def tradeEntryRange = if SecondsTillTime(tradeEntryStartTimeEST) <= 0 and SecondsTillTime(tradeEntryEndTimeEST) >= 0 then 1 else 0;

def openingRangeLow = if SecondsTillTime(openingRangeStartTimeEST) == 0 then low else if openingRange and low < openingRangeLow[1] then low else openingRangeLow[1];

#plot highCloud = if openingRange then openingRangeHigh else double.nan;
#plot lowCloud = if openingRange then openingRangeLow else double.nan;
#highCloud.setDefaultColor(Color.Gray);
#lowCloud.setDefaultColor(Color.Gray);

#AddCloud(lowCloud, highCloud, color.gray, color.gray);

plot tradeEntryHighExtension = if tradeEntryRange then openingRangeHigh else double.nan;
plot tradeEntryLowExtension = if tradeEntryRange then openingRangeLow else double.nan;

tradeEntryHighExtension.setPaintingStrategy(PaintingStrategy.Horizontal);
tradeEntryLowExtension.setPaintingStrategy(PaintingStrategy.Horizontal);

tradeEntryHighExtension.setStyle(Curve.Short_Dash);
tradeEntryLowExtension.setStyle(Curve.Short_Dash);

tradeEntryHighExtension.setDefaultColor(Color.Gray);
tradeEntryLowExtension.setDefaultColor(Color.Gray);

def bullEntryCondition;
def bearEntryCondition;

switch(entryType){
case wickTouch:
bullEntryCondition = tradeEntryRange and high > openingRangeHigh and high[1] <= openingRangeHigh;
bearEntryCondition = tradeEntryRange and low < openingRangeLow and low[1] >= openingRangeLow;
case closeAbove:
bullEntryCondition = tradeEntryRange and close > openingRangeHigh and close[1] <= openingRangeHigh;
bearEntryCondition = tradeEntryRange and close < openingRangeLow and close[1] >= openingRangeLow;
}

def bullishORB = if bullEntryCondition then 1 else if !tradeEntryRange then 0 else bullishORB[1];
def bearishORB = if bearEntryCondition then 1 else if !tradeEntryRange then 0 else bearishORB[1];

def range = openingRangeHigh - OpeningRangeLow;
def halfRange = range / 2;

def halfwayUpsideProjection = openingRangehigh + halfRange;
plot halfwayUpsideProjectionPlot = if bullishORB and tradeEntryRange then halfwayUpsideProjection else double.nan;
halfwayUpsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
halfwayUpsideProjectionPlot.setDefaultColor(Color.Light_Green);

def fullUpsideProjection = openingRangehigh + range;
plot fullUpsideProjectionPlot = if bullishORB and tradeEntryRange then fullUpsideProjection else double.nan;
fullUpsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
fullUpsideProjectionPlot.setDefaultColor(Color.Green);

#AddLabel(yes, " ^ORB: " + ( Round (fullUpsideProjection, 2)), Color.MAGENTA) ;

def midRange = openingRangeLow + halfRange;
plot midRangePlot = if tradeEntryRange then midRange else double.nan;
midRangePlot.setPaintingStrategy(PaintingStrategy.Horizontal);
midRangePlot.setStyle(Curve.Short_Dash);
midRangePlot.setDefaultColor(Color.Gray);

#AddLabel(yes, " /ORB: " + ( Round (midRange, 2)), Color.ORANGE) ;

def halfwayDownsideProjection = openingRangelow - halfRange;
plot halfwayDownsideProjectionPlot = if bearishORB and tradeEntryRange then halfwayDownsideProjection else double.nan;
halfwayDownsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
halfwayDownsideProjectionPlot.setDefaultColor(Color.Light_Red);

def fullDownsideProjection = openingRangelow - range;
plot fullDownsideProjectionPlot = if bearishORB and tradeEntryRange then fullDownsideProjection else double.nan;
fullDownsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
fullDownsideProjectionPlot.setDefaultColor(Color.Red);

#AddLabel(yes, " !ORB: " + ( Round (fullDownsideProjection, 2)), Color.MAGENTA) ;
 
Last edited by a moderator:

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

Hi,

I found this:
https://tosindicators.com/indicators/opening-range-breakout
was wondering if this ORB indicator can be modified so it can plot as show on expansion as well?


input entryType = {default wickTouch, closeAbove};

input openingRangeStartTimeEST = 930;
input openingRangeEndTimeEST = 1000;

input tradeEntryStartTimeEST = 1000;
input tradeEntryEndTimeEST = 1100;

def openingRange = if SecondsTillTime(openingRangeStartTimeEST) <= 0 and SecondsTillTime(openingRangeEndTimeEST) >= 0 then 1 else 0;

def openingRangeHigh = if SecondsTillTime(openingRangeStartTimeEST) == 0 then high else if openingRange and high > openingRangeHigh[1] then high else openingRangeHigh[1];

def tradeEntryRange = if SecondsTillTime(tradeEntryStartTimeEST) <= 0 and SecondsTillTime(tradeEntryEndTimeEST) >= 0 then 1 else 0;

def openingRangeLow = if SecondsTillTime(openingRangeStartTimeEST) == 0 then low else if openingRange and low < openingRangeLow[1] then low else openingRangeLow[1];

#plot highCloud = if openingRange then openingRangeHigh else double.nan;
#plot lowCloud = if openingRange then openingRangeLow else double.nan;
#highCloud.setDefaultColor(Color.Gray);
#lowCloud.setDefaultColor(Color.Gray);

#AddCloud(lowCloud, highCloud, color.gray, color.gray);

plot tradeEntryHighExtension = if tradeEntryRange then openingRangeHigh else double.nan;
plot tradeEntryLowExtension = if tradeEntryRange then openingRangeLow else double.nan;

tradeEntryHighExtension.setPaintingStrategy(PaintingStrategy.Horizontal);
tradeEntryLowExtension.setPaintingStrategy(PaintingStrategy.Horizontal);

tradeEntryHighExtension.setStyle(Curve.Short_Dash);
tradeEntryLowExtension.setStyle(Curve.Short_Dash);

tradeEntryHighExtension.setDefaultColor(Color.Gray);
tradeEntryLowExtension.setDefaultColor(Color.Gray);

def bullEntryCondition;
def bearEntryCondition;

switch(entryType){
case wickTouch:
bullEntryCondition = tradeEntryRange and high > openingRangeHigh and high[1] <= openingRangeHigh;
bearEntryCondition = tradeEntryRange and low < openingRangeLow and low[1] >= openingRangeLow;
case closeAbove:
bullEntryCondition = tradeEntryRange and close > openingRangeHigh and close[1] <= openingRangeHigh;
bearEntryCondition = tradeEntryRange and close < openingRangeLow and close[1] >= openingRangeLow;
}

def bullishORB = if bullEntryCondition then 1 else if !tradeEntryRange then 0 else bullishORB[1];
def bearishORB = if bearEntryCondition then 1 else if !tradeEntryRange then 0 else bearishORB[1];

def range = openingRangeHigh - OpeningRangeLow;
def halfRange = range / 2;

def halfwayUpsideProjection = openingRangehigh + halfRange;
plot halfwayUpsideProjectionPlot = if bullishORB and tradeEntryRange then halfwayUpsideProjection else double.nan;
halfwayUpsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
halfwayUpsideProjectionPlot.setDefaultColor(Color.Light_Green);

def fullUpsideProjection = openingRangehigh + range;
plot fullUpsideProjectionPlot = if bullishORB and tradeEntryRange then fullUpsideProjection else double.nan;
fullUpsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
fullUpsideProjectionPlot.setDefaultColor(Color.Green);

#AddLabel(yes, " ^ORB: " + ( Round (fullUpsideProjection, 2)), Color.MAGENTA) ;

def midRange = openingRangeLow + halfRange;
plot midRangePlot = if tradeEntryRange then midRange else double.nan;
midRangePlot.setPaintingStrategy(PaintingStrategy.Horizontal);
midRangePlot.setStyle(Curve.Short_Dash);
midRangePlot.setDefaultColor(Color.Gray);

#AddLabel(yes, " /ORB: " + ( Round (midRange, 2)), Color.ORANGE) ;

def halfwayDownsideProjection = openingRangelow - halfRange;
plot halfwayDownsideProjectionPlot = if bearishORB and tradeEntryRange then halfwayDownsideProjection else double.nan;
halfwayDownsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
halfwayDownsideProjectionPlot.setDefaultColor(Color.Light_Red);

def fullDownsideProjection = openingRangelow - range;
plot fullDownsideProjectionPlot = if bearishORB and tradeEntryRange then fullDownsideProjection else double.nan;
fullDownsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
fullDownsideProjectionPlot.setDefaultColor(Color.Red);

#AddLabel(yes, " !ORB: " + ( Round (fullDownsideProjection, 2)), Color.MAGENTA) ;

The input display has 3 choices.

Ruby:
input display     = {default tradeEntry, extended, expansion};   
input entryType   = {default wickTouch, closeAbove};

input openingRangeStartTimeEST = 930;
input openingRangeEndTimeEST   = 1000;

input tradeEntryStartTimeEST = 1000;
input tradeEntryEndTimeEST   = 1100;

def openingRange = if SecondsTillTime(openingRangeStartTimeEST) <= 0 and SecondsTillTime(openingRangeEndTimeEST) >= 0 then 1 else 0;

def openingRangeHigh = if isnan(close) then openingRangeHigh[1] else if SecondsTillTime(openingRangeStartTimeEST) == 0 then high else if openingRange and high > openingRangeHigh[1] then high else openingRangeHigh[1];

def tradeEntryRange = if SecondsTillTime(tradeEntryStartTimeEST) <= 0 and SecondsTillTime(tradeEntryEndTimeEST) >= 0 then 1 else 0;

def openingRangeLow = if isnan(close) then openingRangeLow[1] else if SecondsTillTime(openingRangeStartTimeEST) == 0 then low else if openingRange and low < openingRangeLow[1] then low else openingRangeLow[1];

#plot highCloud = if openingRange then openingRangeHigh else double.nan;
#plot lowCloud = if openingRange then openingRangeLow else double.nan;
#highCloud.setDefaultColor(Color.Gray);
#lowCloud.setDefaultColor(Color.Gray);

#AddCloud(lowCloud, highCloud, color.gray, color.gray);

plot tradeEntryHighExtension = if display==display.expansion and !isnan(close) or display==display.tradeEntry and !tradeEntryRange then double.nan else openingRangeHigh;
plot tradeEntryLowExtension = if display==display.expansion and !isnan(close) or display==display.tradeEntry and !tradeEntryRange then double.nan else openingRangeLow;

tradeEntryHighExtension.setPaintingStrategy(PaintingStrategy.Horizontal);
tradeEntryLowExtension.setPaintingStrategy(PaintingStrategy.Horizontal);

tradeEntryHighExtension.setStyle(Curve.Short_Dash);
tradeEntryLowExtension.setStyle(Curve.Short_Dash);

tradeEntryHighExtension.setDefaultColor(Color.Gray);
tradeEntryLowExtension.setDefaultColor(Color.Gray);

def bullEntryCondition;
def bearEntryCondition;

switch(entryType){
case wickTouch:
bullEntryCondition = tradeEntryRange and high > openingRangeHigh and high[1] <= openingRangeHigh;
bearEntryCondition = tradeEntryRange and low < openingRangeLow and low[1] >= openingRangeLow;
case closeAbove:
bullEntryCondition = tradeEntryRange and close > openingRangeHigh and close[1] <= openingRangeHigh;
bearEntryCondition = tradeEntryRange and close < openingRangeLow and close[1] >= openingRangeLow;
}

def bullishORB = if bullEntryCondition then 1 else if !tradeEntryRange then 0 else bullishORB[1];
def bearishORB = if bearEntryCondition then 1 else if !tradeEntryRange then 0 else bearishORB[1];

plot xborb=bullishorb;
#xborb.setpaintingStrategy(paintingStrategy.VALUES_abOVE);
plot xbearorb=bearishorb;
#xbearorb.setpaintingStrategy(paintingStrategy.VALUES_BELOW);


def range = openingRangeHigh - OpeningRangeLow;
def halfRange = range / 2;

def halfwayUpsideProjection = if isnan(close) then halfwayUpsideProjection[1] else if bullishORB then openingRangehigh + halfRange else halfwayUpsideProjection[1];
plot halfwayUpsideProjectionPlot = if display==display.expansion and !isnan(close) or display==display.tradeEntry and !tradeEntryRange then double.nan else halfwayUpsideProjection;
halfwayUpsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
halfwayUpsideProjectionPlot.setDefaultColor(Color.Light_Green);

def fullUpsideProjection = if isnan(close) then fullUpsideProjection[1] else if bullishORB then openingRangehigh + range else fullUpsideProjection[1];
plot fullUpsideProjectionPlot = if display==display.expansion and !isnan(close) or display==display.tradeEntry and !tradeEntryRange then double.nan else fullUpsideProjection;
fullUpsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
fullUpsideProjectionPlot.setDefaultColor(Color.Green);

#AddLabel(yes, " ^ORB: " + ( Round (fullUpsideProjection, 2)), Color.MAGENTA) ;

def midRange = if isnan(close) then midRange[1] else openingRangeLow + halfRange;
plot midRangePlot = if display==display.expansion and !isnan(close) or display==display.tradeEntry and !tradeEntryRange then double.nan else midRange;
midRangePlot.setPaintingStrategy(PaintingStrategy.Horizontal);
midRangePlot.setStyle(Curve.Short_Dash);
midRangePlot.setDefaultColor(Color.Gray);

#AddLabel(yes, " /ORB: " + ( Round (midRange, 2)), Color.ORANGE) ;

def halfwayDownsideProjection = if isnan(close) then halfwayDownsideProjection[1] else if bearishORB then openingRangelow - halfRange else halfwayDownsideProjection[1];
plot halfwayDownsideProjectionPlot = if display==display.expansion and !isnan(close) or display==display.tradeEntry and !tradeEntryRange and halfwayDownsideProjection[1] then double.nan else halfwayDownsideProjection;
halfwayDownsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
halfwayDownsideProjectionPlot.setDefaultColor(Color.Light_Red);

def fullDownsideProjection = if isnan(close) then fullDownsideProjection[1] else if bearishORB then openingRangelow - range else fullDownsideProjection[1];
plot fullDownsideProjectionPlot = if display==display.expansion and !isnan(close) or display==display.tradeEntry and !tradeEntryRange and fullDownsideProjection[1] then double.nan else fullDownsideProjection;
fullDownsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
fullDownsideProjectionPlot.setDefaultColor(Color.Red);

#AddLabel(yes, " !ORB: " + ( Round (fullDownsideProjection, 2)), Color.MAGENTA) ;
 
Hello,

I’m looking for a back tester for TOS that measures the success of opening range breakouts in either direction over different periods of time. I’d like it to have customizable parameters, seeing what percentage of the time it hits different R multiples.
I'd like this to be able to tell me percentages (exactly like first image below), how often this backtested was able to hit its full range and half range targets. Having the stops at the full and half range as two different options. and for targets id like there to be options for half, full and 2xRange please. I'm an options trader so it would be nice to see this projection with # of contracts as an choice. but if not, then just a share quantity button like second image below.

(i don't have any script for this, unfortunately. i saw these labels in a youtube video. so i wanted it to be identical if possible.)


here is the study:
https://tos.mx/0q6oZKa
Ruby:
#Written by TOS Indicators 2022
#Indicator: Opening Range Breakout (ORB) Indicator
#Full Tutorial Link: tosindicators.com/indicators/opening-range-breakout

input entryType = {default wickTouch, closeAbove};

input openingRangeStartTimeEST = 930;
input openingRangeEndTimeEST = 1000;

input tradeEntryStartTimeEST = 1000;
input tradeEntryEndTimeEST = 1100;

def openingRange = if SecondsTillTime(openingRangeStartTimeEST) <= 0 and SecondsTillTime(openingRangeEndTimeEST) >= 0 then 1 else 0;

def tradeEntryRange = if SecondsTillTime(tradeEntryStartTimeEST) <= 0 and SecondsTillTime(tradeEntryEndTimeEST) >= 0 then 1 else 0;

def openingRangeHigh = if SecondsTillTime(openingRangeStartTimeEST) == 0 then high else if openingRange and high > openingRangeHigh[1] then high else openingRangeHigh[1];

def openingRangeLow = if SecondsTillTime(openingRangeStartTimeEST) == 0 then low else if openingRange and low < openingRangeLow[1] then low else openingRangeLow[1];

plot highCloud = if openingRange then openingRangeHigh else double.nan;
plot lowCloud = if openingRange then openingRangeLow else double.nan;
highCloud.setDefaultColor(Color.Gray);
lowCloud.setDefaultColor(Color.Gray);

AddCloud(lowCloud, highCloud, color.gray, color.gray);

plot tradeEntryHighExtension = if tradeEntryRange then openingRangeHigh else double.nan;
plot tradeEntryLowExtension = if tradeEntryRange then openingRangeLow else double.nan;
tradeEntryHighExtension.setPaintingStrategy(PaintingStrategy.Horizontal);
tradeEntryLowExtension.setPaintingStrategy(PaintingStrategy.Horizontal);
tradeEntryHighExtension.setStyle(Curve.Short_Dash);
tradeEntryLowExtension.setStyle(Curve.Short_Dash);
tradeEntryHighExtension.setDefaultColor(Color.Gray);
tradeEntryLowExtension.setDefaultColor(Color.Gray);

def bullEntryCondition;
def bearEntryCondition;
switch(entryType){
case wickTouch:
    bullEntryCondition = tradeEntryRange and high > openingRangeHigh and high[1] <= openingRangeHigh;
    bearEntryCondition = tradeEntryRange and low < openingRangeLow and low[1] >= openingRangeLow;
case closeAbove:
    bullEntryCondition = tradeEntryRange and close > openingRangeHigh and close[1] <= openingRangeHigh;
    bearEntryCondition = tradeEntryRange and close < openingRangeLow and close[1] >= openingRangeLow;
}

def bullishORB = if bullEntryCondition then 1 else if !tradeEntryRange then 0 else bullishORB[1];

def bearishORB = if bearEntryCondition then 1 else if !tradeEntryRange then 0 else bearishORB[1];

def range = openingRangeHigh - OpeningRangeLow;
def halfRange = range / 2;
def midRange = openingRangeLow + halfRange;

plot midRangePlot = if tradeEntryRange then midRange else double.nan;
midRangePlot.setPaintingStrategy(PaintingStrategy.Horizontal);
midRangePlot.setStyle(Curve.Short_Dash);
midRangePlot.setDefaultColor(Color.Gray);


def halfwayUpsideProjection = openingRangehigh + halfRange;
plot halfwayUpsideProjectionPlot = if bullishORB and tradeEntryRange then halfwayUpsideProjection else double.nan;
halfwayUpsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
halfwayUpsideProjectionPlot.setDefaultColor(Color.Light_Green);


def fullUpsideProjection = openingRangehigh + range;
plot fullUpsideProjectionPlot = if bullishORB and tradeEntryRange then fullUpsideProjection else double.nan;
fullUpsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
fullUpsideProjectionPlot.setDefaultColor(Color.Green);




def halfwayDownsideProjection = openingRangelow - halfRange;
plot halfwayDownsideProjectionPlot = if bearishORB and tradeEntryRange then halfwayDownsideProjection else double.nan;
halfwayDownsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
halfwayDownsideProjectionPlot.setDefaultColor(Color.Light_Red);


def fullDownsideProjection = openingRangelow - range;
plot fullDownsideProjectionPlot = if bearishORB and tradeEntryRange then fullDownsideProjection else double.nan;
fullDownsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
fullDownsideProjectionPlot.setDefaultColor(Color.Red);




#AddChartBubble(bullishORB or bearishORB, close, range, if bullishORB then color.green else if bearishORB then color.red else color.yellow);
dtmWe5f.png
 
Last edited by a moderator:
Hi, would it be possible to have the below code show today's range only?? Tried fixing it to no avail.

Thanks!


Code:
plot hide = double.NaN;
hide.setDefaultColor(color.BLACK);

input ShowTodayOnly = yes;

def Today = if GetDay() == GetLastDay() then 1 else 0;

input entryType = {default wickTouch, closeAbove};

input openingRangeStartTimeEST = 930;
input openingRangeEndTimeEST = 1000;

input tradeEntryStartTimeEST = 1000;
input tradeEntryEndTimeEST = 1100;

def openingRange = if SecondsTillTime(openingRangeStartTimeEST) <= 0 and SecondsTillTime(openingRangeEndTimeEST) >= 0 then 1 else 0;

def tradeEntryRange = if SecondsTillTime(tradeEntryStartTimeEST) <= 0 and SecondsTillTime(tradeEntryEndTimeEST) >= 0 then 1 else 0;

def openingRangeHigh = if SecondsTillTime(openingRangeStartTimeEST) == 0 then high else if openingRange and high > openingRangeHigh[1] then high else openingRangeHigh[1];

def openingRangeLow = if SecondsTillTime(openingRangeStartTimeEST) == 0 then low else if openingRange and low < openingRangeLow[1] then low else openingRangeLow[1];

plot highCloud = if ShowTodayOnly and openingRange then openingRangeHigh else double.nan;
plot lowCloud = if showtodayOnly and openingRange then openingRangeLow else double.nan;
highCloud.setDefaultColor(Color.Gray);
lowCloud.setDefaultColor(Color.Gray);

AddCloud(lowCloud, highCloud, color.gray, color.gray);

plot tradeEntryHighExtension = if showtodayOnly and  tradeEntryRange then openingRangeHigh else double.nan;
plot tradeEntryLowExtension = if showtodayOnly and tradeEntryRange then openingRangeLow else double.nan;
tradeEntryHighExtension.setPaintingStrategy(PaintingStrategy.Horizontal);
tradeEntryLowExtension.setPaintingStrategy(PaintingStrategy.Horizontal);
tradeEntryHighExtension.setStyle(Curve.Short_Dash);
tradeEntryLowExtension.setStyle(Curve.Short_Dash);
tradeEntryHighExtension.setDefaultColor(Color.gray);
tradeEntryLowExtension.setDefaultColor(Color.gray);

def bullEntryCondition;
def bearEntryCondition;
switch(entryType){
case wickTouch:
    bullEntryCondition = tradeEntryRange and high > openingRangeHigh and high[1] <= openingRangeHigh;
    bearEntryCondition = tradeEntryRange and low < openingRangeLow and low[1] >= openingRangeLow;
case closeAbove:
    bullEntryCondition = tradeEntryRange and close > openingRangeHigh and close[1] <= openingRangeHigh;
    bearEntryCondition = tradeEntryRange and close < openingRangeLow and close[1] >= openingRangeLow;
}

def bullishORB = if bullEntryCondition then 1 else if !tradeEntryRange then 0 else bullishORB[1];

def bearishORB = if bearEntryCondition then 1 else if !tradeEntryRange then 0 else bearishORB[1];

def range = openingRangeHigh - OpeningRangeLow;
def halfRange = range / 2;
def midRange = openingRangeLow + halfRange;

plot midRangePlot = if showtodayOnly and tradeEntryRange then midRange else double.nan;
midRangePlot.setPaintingStrategy(PaintingStrategy.Horizontal);
midRangePlot.setStyle(Curve.Short_DASH);
midRangePlot.setDefaultColor(Color.gray);


def halfwayUpsideProjection = openingRangehigh + halfRange;
plot halfwayUpsideProjectionPlot = if bullishORB and tradeEntryRange then halfwayUpsideProjection else double.nan;
halfwayUpsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
halfwayUpsideProjectionPlot.setDefaultColor(Color.Light_Green);


def fullUpsideProjection = openingRangehigh + range;
plot fullUpsideProjectionPlot = if showtodayOnly and  bullishORB and tradeEntryRange then fullUpsideProjection else double.nan;
fullUpsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
fullUpsideProjectionPlot.setDefaultColor(Color.Green);




def halfwayDownsideProjection = openingRangelow - halfRange;
plot halfwayDownsideProjectionPlot = if bearishORB and tradeEntryRange then halfwayDownsideProjection else double.nan;
halfwayDownsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
halfwayDownsideProjectionPlot.setDefaultColor(Color.Light_Red);


def fullDownsideProjection = openingRangelow - range;
plot fullDownsideProjectionPlot = if showtodayOnly and bearishORB and tradeEntryRange then fullDownsideProjection else double.nan;
fullDownsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
fullDownsideProjectionPlot.setDefaultColor(Color.Red);




#AddChartBubble(bullishORB or bearishORB, close, range, if bullishORB then color.green else if bearishORB then color.red else color.yellow);
 
How can i modify this code to only display on intraday charts only and display the ORB indicator for either current day only or multiple days?

Thanks


Code:
input openingRangeStartTimeEST = 930;
input openingRangeEndTimeEST = 1000;
def openingRange = if SecondsTillTime(openingRangeStartTimeEST) <= 0 and SecondsTillTime(openingRangeEndTimeEST) >= 0 then 1 else 0;

def openingRangeHigh = if SecondsTillTime(openingRangeStartTimeEST) == 0 then high else if openingRange and high > openingRangeHigh[1] then high else openingRangeHigh[1];
def openingRangeLow = if SecondsTillTime(openingRangeStartTimeEST) == 0 then low else if openingRange and low < openingRangeLow[1] then low else openingRangeLow[1];

plot highCloud = if openingRange then openingRangeHigh else double.nan;
plot lowCloud = if openingRange then openingRangeLow else double.nan;
highCloud.setDefaultColor(Color.Gray);
lowCloud.setDefaultColor(Color.Gray);

AddCloud(lowCloud, highCloud, color.gray, color.gray);

input tradeEntryStartTimeEST = 1000;
input tradeEntryEndTimeEST = 1100;
def tradeEntryRange = if SecondsTillTime(tradeEntryStartTimeEST) <= 0 and SecondsTillTime(tradeEntryEndTimeEST) >= 0 then 1 else 0;

plot tradeEntryHighExtension = if tradeEntryRange then openingRangeHigh else double.nan;
plot tradeEntryLowExtension = if tradeEntryRange then openingRangeLow else double.nan;

tradeEntryHighExtension.setPaintingStrategy(PaintingStrategy.Horizontal);
tradeEntryLowExtension.setPaintingStrategy(PaintingStrategy.Horizontal);

tradeEntryHighExtension.setStyle(Curve.Short_Dash);
tradeEntryLowExtension.setStyle(Curve.Short_Dash);

tradeEntryHighExtension.setDefaultColor(Color.Gray);
tradeEntryLowExtension.setDefaultColor(Color.Gray);

input entryType = {default wickTouch, closeAbove};

def bullEntryCondition;
def bearEntryCondition;

switch(entryType){
case wickTouch:
    bullEntryCondition = tradeEntryRange and high > openingRangeHigh and high[1] <= openingRangeHigh;
    bearEntryCondition = tradeEntryRange and low < openingRangeLow and low[1] >= openingRangeLow;
case closeAbove:
    bullEntryCondition = tradeEntryRange and close > openingRangeHigh and close[1] <= openingRangeHigh;
    bearEntryCondition = tradeEntryRange and close < openingRangeLow and close[1] >= openingRangeLow;
}

def bullishORB = if bullEntryCondition then 1 else if !tradeEntryRange then 0 else bullishORB[1];
def bearishORB = if bearEntryCondition then 1 else if !tradeEntryRange then 0 else bearishORB[1];

def range = openingRangeHigh - OpeningRangeLow;
def halfRange = range / 2;
def midRange = openingRangeLow + halfRange;

plot midRangePlot = if tradeEntryRange then midRange else double.nan;
midRangePlot.setPaintingStrategy(PaintingStrategy.Horizontal);
midRangePlot.setStyle(Curve.Short_Dash);
midRangePlot.setDefaultColor(Color.Gray);

def halfwayUpsideProjection = openingRangehigh + halfRange;
plot halfwayUpsideProjectionPlot = if bullishORB and tradeEntryRange then halfwayUpsideProjection else double.nan;
halfwayUpsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
halfwayUpsideProjectionPlot.setDefaultColor(Color.Light_Green);

def fullUpsideProjection = openingRangehigh + range;
plot fullUpsideProjectionPlot = if bullishORB and tradeEntryRange then fullUpsideProjection else double.nan;
fullUpsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
fullUpsideProjectionPlot.setDefaultColor(Color.Green);

def halfwayDownsideProjection = openingRangelow - halfRange;
plot halfwayDownsideProjectionPlot = if bearishORB and tradeEntryRange then halfwayDownsideProjection else double.nan;
halfwayDownsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
halfwayDownsideProjectionPlot.setDefaultColor(Color.Light_Red);

def fullDownsideProjection = openingRangelow - range;
plot fullDownsideProjectionPlot = if bearishORB and tradeEntryRange then fullDownsideProjection else double.nan;
fullDownsideProjectionPlot.setPaintingStrategy(PaintingStrategy.Horizontal);
fullDownsideProjectionPlot.setDefaultColor(Color.Red);
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
310 Online
Create Post

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