Help with plotting levels

ziongotoptions

Active member
Hello im working on a code and im running into an issue , im unable to plot different levels can you look at the code and see what i am missing?

Ruby:
input Colored_candles=yes;
def today_=yes;
def today=today_ and GetDay() == GetLastDay();
input show_labels=yes;
input pre_market_high_=yes;
input pre_market_low_=yes;
input previous_high=yes;
input previous_low=yes;
input previous_close=yes;
input two_days_ago_close=yes;
input two_days_ago_high=yes;
input two_days_ago_low=yes;
input pivot_point=yes;
input support_1=yes;
input support_2=yes;
input support_3=yes;
input resistance_1=yes;
input resistance_2=yes;
input resistance_3=yes;



#def corr=pct/100;

def tw=SecondsFromTime(400)>=0 and SecondsFromTime(2000)<0;
def yhigh=if GetDay()!=GetDay()[1] and GetDay()!=GetLastDay() then 0 else if tw and high>yhigh[1] then high else yhigh[1];
def yhigh2=if GetDay()!=GetDay()[1] then yhigh[1] else yhigh2[1];
def ylow=if GetDay()==GetLastDay() then ylow[1] else if GetDay()!=GetDay()[1] and GetDay()!=GetLastDay() then 0 else if tw and ylow[1]==0 then low else if tw and low<ylow[1] then low else ylow[1];
def yclose=if GetDay()==GetLastDay() then yclose[1] else if GetDay()!=GetDay()[1] and GetDay()!=GetLastDay() then 0 else if tw then close else yhigh[1];
def ylow2=if GetDay()!=GetDay()[1] then ylow[1] else ylow2[1];
def yclose2=if GetDay()!=GetDay()[1] then yclose[1] else yclose2[1];
def close1=if SecondsFromTime(1600)<0 then close else close1[1];
def yclose3=if GetDay()!=GetDay()[1] then close1[1] else yclose3[1];
plot pp=if pivot_point then (yhigh2 + ylow2 + yclose2)/3 else Double.NaN;

plot s1=if support_1 then (pp * 2) - yhigh2 else Double.NaN;
plot s2=if support_2 then pp - (yhigh2 - ylow2) else Double.NaN;
plot s3=if support_3 then s2 - yhigh2 + ylow2 else Double.NaN;
plot r1=if resistance_1 then (pp * 2) - ylow2 else Double.NaN;
plot r2=if resistance_2 then pp + (yhigh2 - ylow2) else Double.NaN;
plot r3=if resistance_3 then r2 + yhigh2 - ylow2 else Double.NaN;

plot closey=if yclose3>0 and previous_close then yclose3 else Double.NaN;
AssignPriceColor(if close>closey and Colored_candles then Color.GREEN else if close<=closey and Colored_candles then Color.RED else Color.CURRENT);
#plot buyzone=if 1 and tw then pp*(1-corr) else double.NaN;

pp.SetDefaultColor(Color.YELLOW);
#buyzone.setdefaultcolor(color.white);
pp.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
s1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
s2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
s3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
r1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
r2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
r3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);



#buyzone.setPaintingStrategy(paintingStrategy.dashes);

AddCloud(pp, closey, Color.WHITE, Color.WHITE);

def yhighplot=if GetDay()!= GetDay()[1] then 0 else if SecondsFromTime(930)>=0 and SecondsFromTime(1600)<0 and high>yhighplot[1] then high else yhighplot[1];
def yesthigh=if GetDay()!=GetDay()[1] then yhighplot[1] else yesthigh[1];
def ylowplot=if GetDay()!= GetDay()[1] then 10000 else if SecondsFromTime(930)>=0 and SecondsFromTime(1600)<0 and low<ylowplot[1] then low else ylowplot[1];
def yestlow=if GetDay()!=GetDay()[1] then ylowplot[1] else yestlow[1];
def pmhigh=if GetDay()!=GetDay()[1] then high else if SecondsFromTime(930)<0 and high>pmhigh[1] then high else pmhigh[1];
def pmlow=if GetDay()!=GetDay()[1] then low else if SecondsFromTime(930)<0 and low<pmlow[1] then low else pmlow;

def daysago2=CountTradingDays(20200101,GetYYYYMMDD())==(CountTradingDays(20200101,HighestAll(GetYYYYMMDD()))-2);
def high2=if today then high2[1] else if daysago2 and SecondsFromTime(930)>=0 and SecondsFromTime(1600)<0 then close else high2[1];
def high2r=if today then high2r[1] else if daysago2 and SecondsFromTime(930)>=0 and SecondsFromTime(1600)<0 and high>high2r[1] then high else high2r[1];
def low2=if today then low2[1] else if daysago2 and low2[1]==0 and SecondsFromTime(930)>=0 and SecondsFromTime(1600)<0 then low else if daysago2 and SecondsFromTime(930)>=0 and SecondsFromTime(1600)<0 and low<low2[1] then low else low2[1];
#plot y=yhighplot;


plot premarket_high=if today and pre_market_high_ then pmhigh else Double.NaN;
plot premarket_low=if today and pre_market_low_ then pmlow else Double.NaN;
plot prevhigh=if today and previous_high then yesthigh else Double.NaN;
plot prevlow=if today and previous_low then yestlow else Double.NaN;
plot preprevclose=if today and two_days_ago_close and GetDay() == GetLastDay() then high2 else Double.NaN;
plot preprevhigh=if today and two_days_ago_high and GetDay() == GetLastDay() then high2r else Double.NaN;
plot preprevlow=if today and two_days_ago_low and GetDay() == GetLastDay() then low2 else Double.NaN;

premarket_high.DefineColor("Premarket High Color", Color.GREEN);
premarket_low.DefineColor("Premarket Low Color", Color.RED);
prevhigh.DefineColor("Prev Day's High Color", Color.CYAN);
prevlow.DefineColor("Prev Day's Low Color", Color.WHITE);
preprevclose.DefineColor("2 Days Ago Close Color", Color.GRAY);
preprevhigh.DefineColor("2 Days Ago High Color", Color.GRAY);
preprevlow.DefineColor("2 Days Ago Low Color", Color.GRAY);

premarket_high.AssignValueColor(premarket_high.Color("Premarket High Color"));
premarket_low.AssignValueColor(premarket_low.Color("Premarket Low Color"));
prevlow.AssignValueColor(prevlow.Color("Prev Day's Low Color"));
prevhigh.AssignValueColor(prevhigh.Color("Prev Day's High Color"));
preprevclose.AssignValueColor(preprevclose.Color("2 Days Ago Close Color"));
preprevhigh.AssignValueColor(preprevhigh.Color("2 Days Ago High Color"));
preprevlow.AssignValueColor(preprevlow.Color("2 Days Ago Low Color"));
 
Hello im working on a code and im running into an issue , im unable to plot different levels can you look at the code and see what i am missing?
Try replacing this line

Ruby:
def pmlow=if GetDay()!=GetDay()[1] then low else if SecondsFromTime(930)<0 and low<pmlow[1] then low else pmlow[1];
 

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