doesn't show ONH and ONL previous days

TDAK

New member
Hi
I have this code that seems to work fine but it doesn't show ONH and ONL previous days
Is it possible to make it show all the previous days?
Thanks


Code:
input aggregationPeriod = AggregationPeriod.DAY;
input length = 1;
#input displace = -1;
input displace_amount = {default zero, negative_one};
input price = open;

def displacement;
switch (displace_amount) {
case zero:
displacement = 0;
case negative_one:
displacement = -1;}

input showOnlyLastPeriod = no;

plot PrevDayOpen;
plot PrevDayHigh;
plot PrevDayLow;
plot PrevDayClose;

if showOnlyLastPeriod and !IsNaN(open(period = aggregationPeriod)[-1]) and !IsNaN(high(period = aggregationPeriod)[-1]) and !IsNaN(low(period = aggregationPeriod)[-1]) and !IsNaN(close(period = aggregationPeriod)[-1]){
PrevDayOpen = Double.NaN;
PrevDayHigh = Double.NaN;
PrevDayLow = Double.NaN;
PrevDayClose = Double.NaN;}else{
PrevDayOpen = Highest(open(period = aggregationPeriod)[displace_amount], length);
PrevDayHigh = Highest(high(period = aggregationPeriod)[displace_amount], length);
PrevDayLow = Highest(low(period = aggregationPeriod)[displace_amount], length);
PrevDayClose = Highest(close(period = aggregationPeriod)[displace_amount], length);}
PrevDayOpen.SetDefaultColor(GetColor(4));
PrevDayOpen.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PrevDayHigh.SetDefaultColor(GetColor(4));
PrevDayHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PrevDayLow.SetDefaultColor(GetColor(4));
PrevDayLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PrevDayClose.SetDefaultColor(GetColor(4));
PrevDayClose.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

input PlotOverNightExtremes = yes;

def o = open;
def h = high;
def l = low;
def c = close;
def v = volume;

def bar = BarNumber();
def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());
def vol = if GlobeX and !Globex[1]
then v
else if GlobeX
then vol[1] + v
else Double.NaN;

def GlobeX_Volume = vol;
def ONhigh = if GlobeX and !Globex[1]
then h
else if Globex and
h > ONhigh[1]
then h
else ONhigh[1];
def ONhighBar = if GlobeX and h == ONhigh
then Bar
else double.nan;

def ONlow = if GlobeX and !GlobeX[1]
then l
else if GlobeX and
l < ONlow[1]
then l
else ONlow[1];

def ONlowBar = if GlobeX and l == ONlow
then Bar
else double.nan;
def OverNightHigh = if BarNumber() == HighestAll(ONhighBar)
then ONhigh
else OverNightHigh[1];
def OverNightLow = if BarNumber() == HighestAll(ONlowBar)

then ONlow
else OverNightLow[1];

plot ONH = if OverNightHigh > 0

then OverNightHigh
else Double.NaN;
ONH.SetHiding(!PlotOverNightExtremes);
ONH.SetPaintingStrategy(PaintingStrategy.SQUARES);
ONH.SetDefaultColor(Color.BLUE);
ONH.HideBubble();
ONH.HideTitle();

plot ONL = if OverNightLow > 0
then OverNightLow
else Double.NaN;

ONL.SetHiding(!PlotOverNightExtremes);
ONL.SetPaintingStrategy(PaintingStrategy.SQUARES);
ONL.SetDefaultColor(Color.LIGHT_GRAY);
ONL.HideBubble();
ONL.HideTitle();

def MaxBar = Max(HighestAll(ONhighBar), HighestAll(ONlowBar));

# End Code
 
Solution
Hi
I have this code that seems to work fine but it doesn't show ONH and ONL previous days
Is it possible to make it show all the previous days?
Thanks


Code:
input aggregationPeriod = AggregationPeriod.DAY;
input length = 1;
#input displace = -1;
input displace_amount = {default zero, negative_one};
input price = open;

def displacement;
switch (displace_amount) {
case zero:
displacement = 0;
case negative_one:
displacement = -1;}

input showOnlyLastPeriod = no;

plot PrevDayOpen;
plot PrevDayHigh;
plot PrevDayLow;
plot PrevDayClose;

if showOnlyLastPeriod and !IsNaN(open(period = aggregationPeriod)[-1]) and !IsNaN(high(period = aggregationPeriod)[-1]) and !IsNaN(low(period = aggregationPeriod)[-1]) and !IsNaN(close(period =...
Hi
I have this code that seems to work fine but it doesn't show ONH and ONL previous days
Is it possible to make it show all the previous days?
Thanks


Code:
input aggregationPeriod = AggregationPeriod.DAY;
input length = 1;
#input displace = -1;
input displace_amount = {default zero, negative_one};
input price = open;

def displacement;
switch (displace_amount) {
case zero:
displacement = 0;
case negative_one:
displacement = -1;}

input showOnlyLastPeriod = no;

plot PrevDayOpen;
plot PrevDayHigh;
plot PrevDayLow;
plot PrevDayClose;

if showOnlyLastPeriod and !IsNaN(open(period = aggregationPeriod)[-1]) and !IsNaN(high(period = aggregationPeriod)[-1]) and !IsNaN(low(period = aggregationPeriod)[-1]) and !IsNaN(close(period = aggregationPeriod)[-1]){
PrevDayOpen = Double.NaN;
PrevDayHigh = Double.NaN;
PrevDayLow = Double.NaN;
PrevDayClose = Double.NaN;}else{
PrevDayOpen = Highest(open(period = aggregationPeriod)[displace_amount], length);
PrevDayHigh = Highest(high(period = aggregationPeriod)[displace_amount], length);
PrevDayLow = Highest(low(period = aggregationPeriod)[displace_amount], length);
PrevDayClose = Highest(close(period = aggregationPeriod)[displace_amount], length);}
PrevDayOpen.SetDefaultColor(GetColor(4));
PrevDayOpen.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PrevDayHigh.SetDefaultColor(GetColor(4));
PrevDayHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PrevDayLow.SetDefaultColor(GetColor(4));
PrevDayLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PrevDayClose.SetDefaultColor(GetColor(4));
PrevDayClose.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

input PlotOverNightExtremes = yes;

def o = open;
def h = high;
def l = low;
def c = close;
def v = volume;

def bar = BarNumber();
def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());
def vol = if GlobeX and !Globex[1]
then v
else if GlobeX
then vol[1] + v
else Double.NaN;

def GlobeX_Volume = vol;
def ONhigh = if GlobeX and !Globex[1]
then h
else if Globex and
h > ONhigh[1]
then h
else ONhigh[1];
def ONhighBar = if GlobeX and h == ONhigh
then Bar
else double.nan;

def ONlow = if GlobeX and !GlobeX[1]
then l
else if GlobeX and
l < ONlow[1]
then l
else ONlow[1];

def ONlowBar = if GlobeX and l == ONlow
then Bar
else double.nan;
def OverNightHigh = if BarNumber() == HighestAll(ONhighBar)
then ONhigh
else OverNightHigh[1];
def OverNightLow = if BarNumber() == HighestAll(ONlowBar)

then ONlow
else OverNightLow[1];

plot ONH = if OverNightHigh > 0

then OverNightHigh
else Double.NaN;
ONH.SetHiding(!PlotOverNightExtremes);
ONH.SetPaintingStrategy(PaintingStrategy.SQUARES);
ONH.SetDefaultColor(Color.BLUE);
ONH.HideBubble();
ONH.HideTitle();

plot ONL = if OverNightLow > 0
then OverNightLow
else Double.NaN;

ONL.SetHiding(!PlotOverNightExtremes);
ONL.SetPaintingStrategy(PaintingStrategy.SQUARES);
ONL.SetDefaultColor(Color.LIGHT_GRAY);
ONL.HideBubble();
ONL.HideTitle();

def MaxBar = Max(HighestAll(ONhighBar), HighestAll(ONlowBar));

# End Code
?? the default settings does draw lines on every day.

try changing this to no
input showOnlyLastPeriod = no;
 
Solution

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
492 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