Archived: Opening Range Breakout

Status
Not open for further replies.
@BenTen How to remove 'RO' ‘1st T’"2nd T" like those bubble, I just need the line is fine,
I tried to uncheck the show plot, but those bubbles still sitting on the chart. since i'm using 4*4 small side chart, these bubbles takes lots of space from the chart. thank you
 
@vince92615 I did. Just pull up the code from your script. Look for any line that starts with AddChartBubble and remove it.

For example:

Code:
AddChartBubble(bar == HighestAll(crossUpBar), ORLriskUP, "RiskON ORH", color.green, no);
 
Turn off extended hours on equities and adjust time axis expansion are bars to the right number. Hope this works for you .
So i had that turned off already but for S&G i turned it back on and now it kinda working. The cloud is not as dark as it use to be and now the time on the graph doesnt match the current time. Do you have a fix?
 
So i had that turned off already but for S&G i turned it back on and now it kinda working. The cloud is not as dark as it use to be and now the time on the graph doesnt match the current time. Do you have a fix?
Fixed the time issue. Is there a way to make the cloud darker?
 
Fixed the time issue. Is there a way to make the cloud darker?
I read it on the comments that some had a problem so they had to delete and download the script again. So far that I know there is no way to make cloud darker, choosing different background makes it look darker, and that's what I did.
 
Can someone provide AddChartBubble code so that when Price cross above and below the Opening High and Low. The Bubble text would display "B" for when price cross above the ORHigh and "S" when price cross below the ORLow. See Code below.

Code:
input opentime = 0930;
input ORend = 0934;

AddChartBubble(SecondsTillTime(0930) == 0, high, "NY", Color.WHITE, yes);
AddVerticalLine(SecondsTillTime(0930) == 0, "NEW YORK ", Color.CYAN, Curve.FIRM);

def na = Double.NaN;
def ORActive = if GetLastDay() == GetDay() and SecondsFromTime(opentime) >= 0 and SecondsFromTime(ORend) < 0 then 1 else 0;
def ORHigh = if ORActive then high else na;
def ORLow = if ORActive then low else na;
def ORLow2 = if ORActive then low else na;

plot OHIGH = if GetLastDay() != GetDay() or !ORActive then na else HighestAll(ORHigh);
plot OLOW = if GetLastDay() != GetDay() or !ORActive then na else LowestAll(ORLow);
plot OLOW2 = if GetLastDay() != GetDay() or !ORActive then na else LowestAll(ORLow);
plot HIGH = if GetLastDay() != GetDay() or SecondsFromTime(ORend) < 0 then na else HighestAll(ORHigh);
plot LOW = if GetLastDay() != GetDay() or SecondsFromTime(ORend) < 0 then na else LowestAll(ORLow);

OHIGH.SetStyle(Curve.SHORT_DASH);
OLOW.SetStyle(Curve.SHORT_DASH);
OLOW2.SetStyle(Curve.SHORT_DASH);
OHIGH.SetDefaultColor(Color.GREEN);
OLOW.SetDefaultColor(Color.RED);
OLOW2.SetDefaultColor(Color.RED);
HIGH.SetStyle(Curve.SHORT_DASH);
LOW.SetStyle(Curve.SHORT_DASH);
HIGH.SetDefaultColor(Color.GREEN);
LOW.SetDefaultColor(Color.RED);

AddCloud(OLOW, OHIGH, COLOR.white, COLOR.white, YES);
 
@Branch For some reason, the code you provided doesn't play well with the AddChartBubble function that I included in it. As a result, I had to try a different code.

This one is similar to what you have, but the settings are different. You may have to modify some of the features to match your old settings.

Code:
# Clayburgs Directional Day Filter
# Written by KumoBob Dec 31 2009

# Thanks to ThinkScriptor and aPPLE_PI for helping me with the secondsfromtime() function by showing me the code writen by Prospectus in his Opening Range study.


# Directional Day Filter Line - After the first five minutes calculate the average range for this 5-minute bar. Draw a horizontal line at this level.
# Time Line - Draw a vertical line at 60-minute bar (Low to High of the day so far).
# (slower value for faster moving charts like currency and S&P – Faster value for slower moving charts) (45 minutes to 90 minutes)
# Determine the amount of activity above and below the Directional Day Filter Line prior to the Time Line.
# (A rectangle can be drawn with Blue shading above and Red below the Directional Day Filter Line)
# If the majority of the activity is above the Directional Day Filter Line the trend bias for the day will be higher.
# If the majority of the activity is below the Directional Day Filter Line the trend bias for the day will be lower.
# If it's even the day will most likely be flat.
# If the closing bar on the Time Line is within 1/3 the distance from the Directional Day Filter Line then added bias can be anticipated.

#hint: Best used in a 1 to 5 minute chart period


def na = double.nan;
############### Directional Day Filter Line ##############


input ORBegin = 0930;
input OREnd = 0935;
# Show Today only? (Default Yes)
input ShowTodayOnly = { default "No", "Yes"};
def s = ShowTodayOnly;
# Create logic for OR definition: 1 if between fist 5 minutes
Def ORActive = if secondsTillTime(OREnd) > 0 AND secondsFromTime(ORBegin) >= 0 then 1 else 0;
# Create logic to paint only current day post-open:
def today = if s == 0 OR getDay() == getLastDay() AND secondsFromTime(ORBegin) >= 0 then 1 else 0;
# Track OR High:
Rec ORHigh = if ORHigh[1] == 0 or ORActive[1] == 0 AND ORActive == 1 then high else if ORActive AND high > ORHigh[1] then high else ORHigh[1];
# Track OR Low:
Rec ORLow = if ORLow[1] == 0 or ORActive[1] == 0 AND ORActive == 1 then low else if ORActive AND low < ORLow[1] then low else ORLow[1];
# Calculate OR width:
Def ORWidth = ORHigh - ORLow;
# Define all the plots:
Def ORHA = if ORActive OR today < 1 then na else ORHigh;
Def ORLA = if ORActive OR today < 1 then na else ORLow;
Def O = ORHA - (ORHA - ORLA) / 2;
Plot ORL = if (o == 0 , na, o);
ORL.SetDefaultColor(color.Yellow);
ORL.SetStyle(curve.Long_DASH);
ORL.SetLineWeight(3);

################## Time Line #####################

input ORBegin2 = 0930;
# Define time that OR is finished (in hhmm format,
# 10:00 is the default):
input OREnd2 = 1030;
# Show Today only? (Default Yes)
####input ShowTodayOnly={"No", default "Yes"};
####def s=ShowTodayOnly;
# Create logic for OR definition:
Def ORActive2 = if secondsTillTime(OREnd2) > 0 AND secondsFromTime(ORBegin2) >= 0 then 1 else 0;
# Create logic to paint only current day post-open:
#####def today=if s==0 OR getday()==getlastday() AND secondsfromtime(ORBegin2)>=0 then 1 else 0;
# Track OR High:
Rec ORHigh2 = if ORHigh2[1] == 0 or ORActive2[1] == 0 AND ORActive2 == 1 then high else if ORActive2 AND high > ORHigh2[1] then high else ORHigh2[1];
# Track OR Low:
Rec ORLow2 = if ORLow2[1] == 0 or ORActive2[1] == 0 AND ORActive2 == 1 then low else if ORActive2 AND low < ORLow2[1] then low else ORLow2[1];
# Calculate OR width:
Def ORWidth2 = ORHigh2 - ORLow2;
# Define all the plots:
Plot ORH2 = if ORActive2 OR today < 1 then na else ORHigh2;
Plot ORL2 = if ORActive2 OR today < 1 then na else ORLow2;
# Formatting:
ORH2.SetDefaultColor(color.green);
ORH2.SetStyle(curve.Long_DASH);
ORH2.SetLineWeight(3);
ORL2.SetDefaultColor(color.red);
ORL2.SetStyle(curve.Long_DASH);
ORL2.SetLineWeight(3);

################################
Def TimeLine = if secondsTillTime(OREnd2) == 0 then 1 else 0;

Def pos = (ORH2 - ORL2) / 10;

plot d1 = if (TimeLine , ORH2, na);
plot d2 = if (TimeLine , ORH2 - ( pos * 2), na);
plot d3 = if (TimeLine , ORH2 - ( pos * 3), na);
plot d4 = if (TimeLine , ORH2 - ( pos * 4), na);
plot d5 = if (TimeLine , ORH2 - ( pos * 5), na);
plot d6 = if (TimeLine , ORH2 - ( pos * 6), na);
plot d7 = if (TimeLine , ORH2 - ( pos * 7), na);
plot d8 = if (TimeLine , ORH2 - ( pos * 8), na);
plot d9 = if (TimeLine , ORH2 - ( pos * 9), na);
plot d10 = if (TimeLine , (ORL2), na);

d1.SetPaintingStrategy(PaintingStrategy.arrow_down);
d2.SetPaintingStrategy(PaintingStrategy.POINTS);
d3.SetPaintingStrategy(PaintingStrategy.POINTS);
d4.SetPaintingStrategy(PaintingStrategy.POINTS);
d5.SetPaintingStrategy(PaintingStrategy.POINTS);
d6.SetPaintingStrategy(PaintingStrategy.POINTS);
d7.SetPaintingStrategy(PaintingStrategy.POINTS);
d8.SetPaintingStrategy(PaintingStrategy.POINTS);
d9.SetPaintingStrategy(PaintingStrategy.POINTS);
d10.SetPaintingStrategy(PaintingStrategy.ARROW_UP);


d2.HideBubble();
d3.HideBubble();
d4.HideBubble();
d5.HideBubble();
d6.HideBubble();
d7.HideBubble();
d8.HideBubble();
d9.HideBubble();



DEF Span = (O - ORL2) / (ORH2 - ORL2);
rec colorState = if Span > 0.66 then -1
else if Span < 0.33 then 1 else 0;


d1.AssignValueColor(
if colorState < 0 then Color.RED else
if colorState > 0 then Color.GREEN else
Color.Yellow
);

d2.AssignValueColor(
if colorState < 0 then Color.RED else
if colorState > 0 then Color.GREEN else
Color.Yellow
);

d3.AssignValueColor(
if colorState < 0 then Color.RED else
if colorState > 0 then Color.GREEN else
Color.Yellow
);

d4.AssignValueColor(
if colorState < 0 then Color.RED else
if colorState > 0 then Color.GREEN else
Color.Yellow
);

d5.AssignValueColor(
if colorState < 0 then Color.RED else
if colorState > 0 then Color.GREEN else
Color.Yellow
);

d6.AssignValueColor(
if colorState < 0 then Color.RED else
if colorState > 0 then Color.GREEN else
Color.Yellow
);

d7.AssignValueColor(
if colorState < 0 then Color.RED else
if colorState > 0 then Color.GREEN else
Color.Yellow
);

d8.AssignValueColor(
if colorState < 0 then Color.RED else
if colorState > 0 then Color.GREEN else
Color.Yellow
);

d9.AssignValueColor(
if colorState < 0 then Color.RED else
if colorState > 0 then Color.GREEN else
Color.Yellow
);

d10.AssignValueColor(
if colorState < 0 then Color.RED else
if colorState > 0 then Color.red else
Color.Yellow
);
d1.SetLineWeight(5);
d2.SetLineWeight(5);
d3.SetLineWeight(5);
d4.SetLineWeight(5);
d5.SetLineWeight(5);
d6.SetLineWeight(5);
d7.SetLineWeight(5);
d8.SetLineWeight(5);
d9.SetLineWeight(5);
d10.SetLineWeight(5);

#######################################################################


Def TimeLineb = if secondsTillTime(OREND) == 0 then 1 else 0;

Def posbd = (ORHA - ORLA) / 10;

plot bd1 = if (TimeLineb , ORHA, na);
plot bd2 = if (TimeLineb , ORHA - ( posbd * 2), na);
plot bd3 = if (TimeLineb , ORHA - ( posbd * 3), na);
plot bd4 = if (TimeLineb , ORHA - ( posbd * 4), na);
plot bd5 = if (TimeLineb , ORHA - ( posbd * 5), na);
plot bd6 = if (TimeLineb , ORHA - ( posbd * 6), na);
plot bd7 = if (TimeLineb , ORHA - ( posbd * 7), na);
plot bd8 = if (TimeLineb , ORHA - ( posbd * 8), na);
plot bd9 = if (TimeLineb , ORHA - ( posbd * 9), na);
plot bd10 = if (TimeLineb , (ORL2), na);

bd1.SetPaintingStrategy(PaintingStrategy.POINTS);
bd2.SetPaintingStrategy(PaintingStrategy.POINTS);
bd3.SetPaintingStrategy(PaintingStrategy.POINTS);
bd4.SetPaintingStrategy(PaintingStrategy.POINTS);
bd5.SetPaintingStrategy(PaintingStrategy.POINTS);
bd6.SetPaintingStrategy(PaintingStrategy.POINTS);
bd7.SetPaintingStrategy(PaintingStrategy.POINTS);
bd8.SetPaintingStrategy(PaintingStrategy.POINTS);
bd9.SetPaintingStrategy(PaintingStrategy.POINTS);
bd10.SetPaintingStrategy(PaintingStrategy.POINTS);

bd1.SetDefaultColor(Color.YELLOW);
bd2.SetDefaultColor(Color.YELLOW);
bd3.SetDefaultColor(Color.YELLOW);
bd4.SetDefaultColor(Color.YELLOW);
bd5.SetDefaultColor(Color.YELLOW);
bd6.SetDefaultColor(Color.YELLOW);
bd7.SetDefaultColor(Color.YELLOW);
bd8.SetDefaultColor(Color.YELLOW);
bd9.SetDefaultColor(Color.YELLOW);
bd10.SetDefaultColor(Color.YELLOW);

bd1.HideBubble();
bd2.HideBubble();
bd3.HideBubble();
bd4.HideBubble();
bd5.HideBubble();
bd6.HideBubble();
bd7.HideBubble();
bd8.HideBubble();
bd9.HideBubble();
bd10.HideBubble();

AddCloud(ORL2, ORH2, color.green, color.green);
#def aggregation = if getAggregationPeriod() == (AggregationPeriod.MIN * 5) or (AggregationPeriod.MIN * 10) or (AggregationPeriod.MIN * 15) then 1 else 0 ;
def aggregation = 1;

def breakout = close crosses above ORH2;
def breakdown = close crosses below ORL2;

AddChartBubble(breakout, low, "B", Color.light_green, no);
AddChartBubble(breakdown, high, "S", Color.light_red, no);
 
sometimes the target zones do not appear... for example today on 5 min NQ ... the zones did not appear till later in the day... any idea how we can fix this?
 
sometimes the target zones do not appear... for example today on 5 min NQ ... the zones did not appear till later in the day... any idea how we can fix this?
I have same problem. Only only 1-3 minute chart everything shows . 5 minutes and up there is nothing
 
some days it shows... i think when you have a candle below ORH and a candle above then you see targets... if you have both candles after the range start on 5 min above the ORH then no targets are shown... wierd
 
edit: solved
answer: add today to the end of def
eg: def ORendBar = if !ORActive and ORActive[1] and today
new problem: how to make the code not use so much ram?
is there a replacement for highestall() because I believe that is what causes a lot of lag on TOS when market is open.\\
my code thus far (removed highlight of open range areas(i prefer to see more of chart and price action), removed risk targets(it was an arbitararily chosen risk area +/-2pts so larger price or smaller price stocks would have same risk doesn't make sense) and removed dots because excessive)
Code:
declare Once_per_bar;

input Mopen  = 0930; # Begin
input M5min  = 0935; #hint End of first 5 min bar
input OREnd    = 1000; #hint OrEnd: End Period of Opening Range Breakout.
input lengthAtr = 4;  #hint Lenght for the ATR Risk Target Lines.
input AtrMult = 2.0; #hint ATRmult: Multiplier for the ATR calculations.

def min5Active = if secondsTillTime(m5min) > 0 and secondsFromTime(mopen) >= 0 then 1 else 0;
def today = if GetAggregationPeriod() <= AggregationPeriod.fifteen_MIN and getDay() == getLastDay() and secondsFromTime(mopen) >= 0 then 1 else 0;

def m5High = if m5High[1] == 0
               or min5Active[1] == 0 and
                  min5Active == 1
               then high
               else if min5Active and
                       high > m5High[1]
               then high
               else m5High[1];
  def m5Low = if m5Low[1] == 0
              or min5Active[1] == 0 and
                 min5Active == 1
              then low
              else if min5Active and
                      low < m5Low[1]
              then low
              else m5Low[1];
  def m5Width = m5High - m5Low;
 
  def m5HighAct = if min5Active
             or today < 1
             then double.NaN
             else m5High;
  def m5LowAct = if min5Active
             or today < 1
             then double.NaN
             else m5Low;
  def min5mid = m5HighAct - Round(((m5HighAct - m5LowAct) / 2) / TickSize(), 0) * TickSize();
  def ORActive = if secondsTillTime(OREnd) > 0 and
                     secondsFromTime(mopen) >= 0
                  then 1
                  else 0;
  def ORHigh = if ORHigh[1] == 0
                  or ORActive[1] == 0 and
                     ORActive == 1
                then high
                else if ORActive and
                        high > ORHigh[1]
                then high
                else ORHigh[1];
  def ORLow = if ORLow[1] == 0
                or ORActive[1] == 0 and
                   ORActive == 1
               then low
               else if ORActive and
                       low < ORLow[1]
               then low
               else ORLow[1];
  def ORWidth = ORHigh - ORLow;
  def ORendTime = if secondsTillTime(OREnd) == 0
                 then 1
                 else 0;
  def min5meanBar = if !min5Active and min5Active[1] and today
                  then barNumber()
                  else min5meanBar[1];
  def ORendBar = if !ORActive and ORActive[1] and today
                 then barNumber()
                 else ORendBar[1];
  def Mopenm = if (min5mid == 0 , double.NaN, min5mid);

plot OpenMidp =   if barNumber() >= highestall(min5meanBar) then Highestall(if isNaN(close[-1]) then Mopenm[1] else double.nan) else double.nan;
     OpenMidp.SetDefaultColor(color.Yellow);
     OpenMidp.SetStyle(curve.medium_DASH);
     OpenMidp.SetLineWeight(1);
     OpenMidp.HideTitle();

  def ORHi = if ORActive
             or today < 1
             then double.NaN
             else ORHigh;


plot ORHighP = if barNumber() >= highestAll(ORendBar)
               then HighestAll(if isNaN(close[-1])
                               then ORHi[1]
                               else double.nan)
               else double.nan;
     ORHighP.SetDefaultColor(color.dark_red);
     ORHighP.SetStyle(curve.Long_DASH);
     ORHighP.SetLineWeight(1);
     ORHighP.HideTitle();
  def ORLo = if ORActive
               or today < 1
             then double.NaN
             else ORLow;
plot ORLowP = if barNumber() >= highestAll(ORendBar)
               then HighestAll(if isNaN(close[-1])
                               then ORLo[1]
                               else double.nan)
               else double.nan;
     ORLowP.SetDefaultColor(color.dark_green);
     ORLowP.SetStyle(curve.medium_DASH);
     ORLowP.SetLineWeight(1);
     ORLowP.HideTitle();
 
# Begin Risk Algorithm
# First Breakout or Breakdown bars
  def Bubbleloc1 = isNaN(close[-1]);
  def BreakoutBar = if min5Active
                    then double.nan
                    else if !min5Active and close crosses above ORHi
                         then barnumber()
                         else if !isNaN(BreakoutBar[1]) and close crosses ORHi
                              then BreakoutBar[1]
                    else BreakoutBar[1];
  def ATR = if ORActive
  then Round((Average(TrueRange(high, close, low), lengthATR)) / TickSize(), 0) * TickSize()
  else ATR[1];
 def cond1 =  if high > ORHi and
                  high[1] <= ORHi
               then Round((ORHi  + (ATR * AtrMult)) / TickSize(), 0) * TickSize()
               else cond1[1];
# High Targets
plot Htarget = if barnumber() >= BreakoutBar
               then cond1
               else double.nan;
     Htarget.SetPaintingStrategy(paintingStrategy.Squares);
     Htarget.SetLineWeight(1);
     Htarget.SetDefaultColor(Color.White);
     Htarget.HideTitle();
AddChartBubble(BubbleLoc1, Htarget, "RO", color.white, if close > Htarget then no else yes);
  def condHtarget2 = if close crosses above cond1
  then Round((cond1 + (ATR * AtrMult)) / TickSize(), 0) * TickSize()
  else condHtarget2[1];
plot Htarget2 = if barnumber() >= BreakoutBar
                then  condHtarget2
                else double.nan;
     Htarget2.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget2.SetLineWeight(1);
     Htarget2.SetDefaultColor(Color.Plum);
     Htarget2.HideTitle();
AddChartBubble(BubbleLoc1, Htarget2, "2nd T", color.plum, if close > Htarget2
                                                          then no
                                                          else yes);
  def condHtarget3 = if close crosses above condHtarget2
  then Round((condHtarget2 + (ATR * AtrMult)) / TickSize(), 0) * TickSize()
  else condHtarget3[1];
plot Htarget3 = if barnumber() >= BreakoutBar
                then condHtarget3
                else double.nan;
     Htarget3.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget3.SetLineWeight(1);
     Htarget3.SetDefaultColor(Color.Plum);
     Htarget3.HideTitle();
AddChartBubble(isNaN(close[-1]), Htarget3, "3rd T", color.plum, if close > Htarget3 then no else yes);
  def condHtarget4 = if close crosses above condHtarget3
  then Round((condHtarget3 + (ATR * AtrMult)) / TickSize(), 0) * TickSize()
  else condHtarget4[1];
plot Htarget4 = if barnumber() >= HighestAll(BreakoutBar)
                then condHtarget4
                else double.nan;
     Htarget4.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget4.SetLineWeight(1);
     Htarget4.SetDefaultColor(Color.Plum);
     Htarget4.HideTitle();
AddChartBubble(BubbleLoc1, Htarget4, "4th T", color.plum, if close > Htarget4 then no else yes);
  def condHtarget5 = if close crosses above condHtarget4
  then Round((condHtarget4 + (ATR * AtrMult)) / TickSize(), 0) * TickSize()
  else condHtarget5[1];
plot Htarget5 = if barnumber() >= BreakoutBar
                then condHtarget5
                else double.nan;
     Htarget5.SetPaintingStrategy(PaintingStrategy.Squares);
     Htarget5.SetLineWeight(1);
     Htarget5.SetDefaultColor(Color.Plum);
     Htarget5.HideTitle();
AddChartBubble(BubbleLoc1, Htarget5, "5th T", color.plum, if close > Htarget5 then no else yes);
# Low Targets
  def cond2 = if low < ORLo and
                 low[1] >= ORLo
              then Round((ORLo  - (AtrMult * ATR)) / TickSize(), 0) * TickSize()
              else cond2[1];
plot Ltarget =  if barnumber() >= HighestAll(OREndBar)
                then highestAll(if isNaN(close[-1])
                                then cond2
                                else double.nan)
                else double.nan;
     Ltarget.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget.SetLineWeight(1);
     Ltarget.SetDefaultColor(Color.White);
     Ltarget.HideTitle();
AddChartBubble(BubbleLoc1, cond2, "RO", color.white, if close < Ltarget
                                                     then yes
                                                     else no);
  def condLtarget2 = if close crosses below cond2
  then Round((cond2 - (AtrMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget2[1];
plot Ltarget2 =  if barnumber() >= HighestAll(OREndBar)
                 then highestAll(if isNaN(close[-1])
                                 then condLtarget2
                                 else double.nan)
                 else double.nan;
     Ltarget2.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget2.SetLineWeight(1);
     Ltarget2.SetDefaultColor(Color.Plum);
     Ltarget2.HideTitle();
AddChartBubble(BubbleLoc1, condLtarget2, "2nd T", color.plum, if close < condLtarget2
                                                              then yes
                                                              else no);
  def condLtarget3 = if close crosses below condLtarget2
  then Round((condLtarget2 - (AtrMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget3[1];
plot Ltarget3 = if barnumber() >= HighestAll(OREndBar)
                then highestAll(if isNaN(close[-1])
                                then condLtarget3
                                else double.nan)
                else double.nan;
     Ltarget3.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget3.SetLineWeight(1);
     Ltarget3.SetDefaultColor(Color.Plum);
     Ltarget3.HideTitle();
AddChartBubble(BubbleLoc1, condLtarget3, "3rd T", color.plum, if close < Ltarget3
                                                              then yes
                                                              else no);
  def condLtarget4 = if close crosses condLtarget3
  then Round((condLtarget3 - (AtrMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget4[1];
plot Ltarget4 = if barnumber() >= HighestAll(OREndBar)
                then highestAll(if isNaN(close[-1])
                                then condLtarget4
                                else double.nan)
                else double.nan;
     Ltarget4.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget4.SetLineWeight(1);
     Ltarget4.SetDefaultColor(Color.Plum);
     Ltarget4.HideTitle();
AddChartBubble(BubbleLoc1, condLtarget4, "4th T", color.plum, if close < Ltarget4
                                                              then yes
                                                              else no);
  def condLtarget5 = if close crosses condLtarget4
  then Round((condLtarget4 - (AtrMult * ATR)) / TickSize(), 0) * TickSize()
  else condLtarget5[1];
plot Ltarget5 = if barnumber() >= HighestAll(OREndBar)
                then highestAll(if isNaN(close[-1])
                                then condLtarget5
                                else double.nan)
                else double.nan;
     Ltarget5.SetPaintingStrategy(PaintingStrategy.Squares);
     Ltarget5.SetLineWeight(1);
     Ltarget5.SetDefaultColor(Color.Plum);
     Ltarget5.HideTitle();
AddChartBubble(BubbleLoc1, condLtarget5, "5th T", color.plum, if close < Ltarget5
                                                              then yes
                                                              else no);

ok i understand the code a bit more after some studying and editing;
if barNumber() >= highestAll(ORendBar)
(means if the CURRENT BAR in the time frame is greater than (or equal to) the 5 minute bar then the following has to be plotted)
if i delete this part of the code then the plot goes across the whole time frame (REGARDLESS of expansion or no expansion) instead of starting to plot after 5min only.

then HighestAll(if isNaN(c[-1]) then ORH2[1]else double.nan)
removing every part and leaving ORH2[1] won't plot the midpoint with expansion
(so it doesn't fix the expansion problem but what is interesting is that without expansion the plot moves to 945 which isn't a criteria for the plot anywhere)


This part of the ORB code is suppose to plot the midpoint of the of the first 5 minutes from 9:30-935.

Code:
plot ORH2ext = if barNumber() >= highestAll(ORendBar)
               then HighestAll(if isNaN(c[-1])
                               then ORH2[1]
                               else double.nan)

I'm editing the ORB code and trying to see if I can make it less complex.

The highestall function and double.nan is confusing as heck to me. Why does the coder use highestall in:

if barNumber() >= highestAll(ORendBar)

isn't highestall pointless when ORendBar already has a def barnumber() which is the first 5mins when it was active?!

so of course the next bar will be greater than (>=) it so why highestall?

and I can't make any sense of why:

then HighestAll(if isNaN(c[-1])
then ORH2[1]
else double.nan)

like what purpose does this fulfill???? my general understanding of double.nan and isNan is that if you want to plot something that does not have a number value then you use isnan such as in expansion. BUT since other posts have problem with using expansion and having the midpoint, open range high, and low, lines move to expansion area....then shouldn't we not use the isnan function?!
 
Status
Not open for further replies.

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
311 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