#### ziongotoptions

##### Active member

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"));
```