add pervious day close and current premarket high and low, and open

CashMoney

Member
VIP
Hi,

Can someone please double check and see if it looks correct or help make it better. Thank you

I would also like to add pervious day close and current premarket high and low, and open. Also bubbles of fib value to the right .

#Auto_FibPrevDay_plots_previous_day_and_flips_fib_levels_including_intraday_timeframes
input ShowTodayOnly = { default "No", "Yes"};
input showbubbles = yes;
input aggperiod = {"1 MIN", "2 MIN", "3 MIN", "5 MIN", "10 MIN", "15 MIN", "30 MIN", "1 HOUR", default "DAY", "WEEK", "MONTH", "YEAR"};
input displace = 1;

def period;
def yyyymmdd = GetYYYYMMDD();
def seconds = SecondsFromTime(0);
def month = GetYear() * 12 + GetMonth();
def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd));
def dom = GetDayOfMonth(yyyymmdd);
def dow = GetDayOfWeek(yyyymmdd - dom + 1);

switch (aggperiod) {
case "1 MIN":
period = Floor(seconds / 60 + day_number * 24 * 60);
case "2 MIN":
period = Floor(seconds / 120 + day_number * 24);
case "3 MIN":
period = Floor(seconds / 180 + day_number * 24);
case "5 MIN":
period = Floor(seconds / 300 + day_number * 24);
case "10 MIN":
period = Floor(seconds / 600 + day_number * 24);
case "15 MIN":
period = Floor(seconds / 900 + day_number * 24);
case "30 MIN":
period = Floor(seconds / 1800 + day_number * 24);
case "1 HOUR":
period = Floor(seconds / 3600 + day_number * 24);
case "DAY":
period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
case "WEEK":
period = Floor(day_number / 7);
case "MONTH":
period = Floor(month - First(month));
case "YEAR":
period = GetYear();
}

plot ORH = if ShowTodayOnly and !IsNaN(close(period = aggperiod)[-1]) then Double.NaN else high(period = aggperiod)[displace];
plot ORL = if ShowTodayOnly and !IsNaN(close(period = aggperiod)[-1]) then Double.NaN else low(period = aggperiod)[displace];

ORH.SetDefaultColor(Color.WHITE);
ORH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ORH.SetLineWeight(2);

ORL.SetDefaultColor(Color.WHITE);
ORL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ORL.SetLineWeight(2);

def bn = BarNumber();
def hbar = if high == high(period = aggperiod) then bn else hbar[1];
def lbar = if low == low(period = aggperiod) then bn else lbar[1];

input F1 = -1.00;
input F2 = -0.62;
input F3 = -0.27;
input F4 = 0.236;
input F5 = 0.382;
input F6 = 0.500;
input F7 = 0.618;
input F8 = 0.786;
input F10 = 1.272;
input f11 = 1.414;
input F12 = 1.618;
input F13 = 2.00;
input f14 = 2.272;
input f15 = 2.414;
input F16 = 2.618;
input f17 = 3;
input F18 = 3.272;
input F19 = 3.414;
input f20 = 3.618;
input f21 = 4;
input f22 = 4.236;
input F23 = 4.272;
input F24 = 4.414;
input f25 = 4.618;
input f26 = 4.764;
input f27 = 5;

input F28 = -1.272;
input f29 = -1.414;
input F30 = -1.618;
input F31 = -2.00;
input f32 = -2.272;
input f33 = -2.414;
input F34 = -2.618;
input f35 = -3;
input F36 = -3.272;
input F37 = -3.414;
input f38 = -3.618;
input f39 = -4;
input f40 = -4.236;
input F41 = -4.272;
input F42 = -4.414;
input f43 = -4.618;
input f44 = -4.764;
input f45 = -5;


def rHi = ORH;
def rLo = ORL;

# Assign values
def range = rHi - rLo;
plot FF1 = rLo + (range * F1);
plot FF2 = rLo + (range * F2);
plot FF3 = rLo + (range * F3);
plot FF4 = rLo + (range * F4);
plot FF5 = rLo + (range * F5);
plot FF6 = rLo + (range * F6);
plot FF7 = rLo + (range * F7);
plot FF8 = rLo + (range * F8);
plot FF10 = rLo + (range * F10);
plot FF11 = rLo + (range * f11);
plot FF12 = rLo + (range * F12);
plot FF13 = rLo + (range * f13);
plot FF14 = rLo + (range * f14);
plot FF15 = rLo + (range * F15);
plot FF16 = rLo + (range * f16);
plot FF17 = rLo + (range * F17);
plot FF18 = rLo + (range * F18);
plot FF19 = rLo + (range * f19);
plot FF20 = rLo + (range * f20);
plot FF21 = rLo + (range * f21);
plot FF22 = rLo + (range * F22);
plot FF23 = rLo + (range * F23);
plot FF24 = rLo + (range * f24);
plot FF25 = rLo + (range * f25);
plot FF26 = rLo + (range * f26);

plot FF27 = rLo + (range * f27);
plot FF28 = rLo + (range * f28);
plot FF29 = rLo + (range * f29);
plot FF30 = rLo + (range * f30);
plot FF31 = rLo + (range * f31);
plot FF32 = rLo + (range * f32);
plot FF33 = rLo + (range * f33);
plot FF34 = rLo + (range * f34);
plot FF35 = rLo + (range * f35);
plot FF36 = rLo + (range * f36);
plot FF37 = rLo + (range * f37);
plot FF38 = rLo + (range * f38);
plot FF39 = rLo + (range * f39);
plot FF40 = rLo + (range * f40);
plot FF41 = rLo + (range * f41);
plot FF42 = rLo + (range * f42);
plot FF43 = rLo + (range * f43);
plot FF44 = rLo + (range * f44);
plot FF45 = rLo + (range * f45);

# Assign colors
FF1.SetDefaultColor(Color.GREEN);
FF1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF1.SetLineWeight(1);

def counth = if IsNaN(FF1) and !IsNaN(FF1[1]) then 1 else counth[1] + 1;
plot FF1text = if IsNaN(FF1) then GetValue(FF1, counth) else Double.NaN;
FF1text.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF1text.SetDefaultColor(Color.GREEN);

FF2.SetDefaultColor(Color.GREEN);
FF2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF2.SetLineWeight(1);

FF3.SetDefaultColor(Color.GREEN);
FF3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF3.SetLineWeight(1);

FF4.SetDefaultColor(Color.CYAN);
FF4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF4.SetLineWeight(1);

FF5.SetDefaultColor(Color.YELLOW);
FF5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF5.SetLineWeight(1);

FF6.SetDefaultColor(Color.WHITE);
FF6.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF6.SetLineWeight(1);

FF7.SetDefaultColor(Color.YELLOW);
FF7.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF7.SetLineWeight(1);

FF8.SetDefaultColor(Color.CYAN);
FF8.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF8.SetLineWeight(1);

FF10.SetDefaultColor(Color.GREEN);
FF10.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF10.SetLineWeight(1);

FF11.SetDefaultColor(Color.GREEN);
FF11.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF11.SetLineWeight(1);

FF12.SetDefaultColor(Color.GREEN);
FF12.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF12.SetLineWeight(1);

FF13.SetDefaultColor(Color.GREEN);
FF13.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF13.SetLineWeight(1);

FF14.SetDefaultColor(Color.GREEN);
FF14.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF14.SetLineWeight(1);

FF15.SetDefaultColor(Color.GREEN);
FF15.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF15.SetLineWeight(1);

FF16.SetDefaultColor(Color.GREEN);
FF16.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF16.SetLineWeight(1);

FF17.SetDefaultColor(Color.GREEN);
FF17.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF17.SetLineWeight(1);

FF18.SetDefaultColor(Color.GREEN);
FF18.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF18.SetLineWeight(1);

FF19.SetDefaultColor(Color.GREEN);
FF19.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF19.SetLineWeight(1);

FF19.SetDefaultColor(Color.GREEN);
FF19.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF19.SetLineWeight(1);

FF20.SetDefaultColor(Color.GREEN);
FF20.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF20.SetLineWeight(1);

FF21.SetDefaultColor(Color.GREEN);
FF21.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF21.SetLineWeight(1);

FF22.SetDefaultColor(Color.GREEN);
FF22.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF22.SetLineWeight(1);

FF23.SetDefaultColor(Color.GREEN);
FF23.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF23.SetLineWeight(1);

FF24.SetDefaultColor(Color.GREEN);
FF24.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF24.SetLineWeight(1);

FF25.SetDefaultColor(Color.GREEN);
FF25.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF25.SetLineWeight(1);

FF26.SetDefaultColor(Color.GREEN);
FF26.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF26.SetLineWeight(1);

FF27.SetDefaultColor(Color.GREEN);
FF27.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF27.SetLineWeight(1);

FF28.SetDefaultColor(Color.GREEN);
FF28.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF28.SetLineWeight(1);

FF29.SetDefaultColor(Color.GREEN);
FF29.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF29.SetLineWeight(1);

FF30.SetDefaultColor(Color.GREEN);
FF30.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF30.SetLineWeight(1);

FF31.SetDefaultColor(Color.GREEN);
FF31.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF31.SetLineWeight(1);

FF32.SetDefaultColor(Color.GREEN);
FF32.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF32.SetLineWeight(1);

FF33.SetDefaultColor(Color.GREEN);
FF33.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF33.SetLineWeight(1);

FF34.SetDefaultColor(Color.GREEN);
FF34.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF34.SetLineWeight(1);

FF35.SetDefaultColor(Color.GREEN);
FF35.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF35.SetLineWeight(1);

FF36.SetDefaultColor(Color.GREEN);
FF36.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF36.SetLineWeight(1);

FF37.SetDefaultColor(Color.GREEN);
FF37.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF37.SetLineWeight(1);

FF38.SetDefaultColor(Color.GREEN);
FF38.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF38.SetLineWeight(1);

FF39.SetDefaultColor(Color.GREEN);
FF39.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF39.SetLineWeight(1);

FF40.SetDefaultColor(Color.GREEN);
FF40.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF40.SetLineWeight(1);


FF41.SetDefaultColor(Color.GREEN);
FF41.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF41.SetLineWeight(1);


FF42.SetDefaultColor(Color.GREEN);
FF42.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF42.SetLineWeight(1);

FF43.SetDefaultColor(Color.GREEN);
FF43.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF43.SetLineWeight(1);

FF44.SetDefaultColor(Color.GREEN);
FF44.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF44.SetLineWeight(1);

FF45.SetDefaultColor(Color.GREEN);
FF45.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF45.SetLineWeight(1);


def basis;
def lowbar;
def highbar;
switch (aggperiod) {
case "1 MIN":
basis = period != period[1];
lowbar = lbar[1];
highbar = hbar[1];
case "2 MIN":
basis = period != period[1];
lowbar = lbar[1];
highbar = hbar[1];
case "3 MIN":
basis = period != period[1];
lowbar = lbar[1];
highbar = hbar[1];
case "5 MIN":
basis = period != period[1];
lowbar = lbar[1];
highbar = hbar[1];
case "10 MIN":
basis = period != period[1];
lowbar = lbar[1];
highbar = hbar[1];
case "15 MIN":
basis = period != period[1];
lowbar = lbar[1];
highbar = hbar[1];
case "30 MIN":
basis = period != period[1];
lowbar = lbar[1];
highbar = hbar[1];
case "1 HOUR":
basis = period != period[1];
lowbar = lbar[1];
highbar = hbar[1];
case "DAY":
basis = GetDay() != GetDay()[1];
lowbar = lbar;
highbar = hbar;
case "WEEK":
basis = GetWeek() != GetWeek()[1];
lowbar = lbar;
highbar = hbar;
case "MONTH":
basis = GetMonth() != GetMonth()[1];
lowbar = lbar;
highbar = hbar;
case "YEAR":
basis = GetYear() != GetYear()[1];
lowbar = lbar;
highbar = hbar;
}

AddChartBubble(showbubbles and basis, ORH, (if lowbar > highbar then 100 else 0), if lowbar > highbar then Color.GREEN else Color.RED);
AddChartBubble(showbubbles and basis, ORL, (if lowbar > highbar then 0 else 100), if lowbar > highbar then Color.RED else Color.GREEN, no);
AddChartBubble(showbubbles and basis, FF1, if lowbar > highbar then F1 else F12, FF1.TakeValueColor());
AddChartBubble(showbubbles and basis, FF2, if lowbar > highbar then F2 else f11, FF2.TakeValueColor());
AddChartBubble(showbubbles and basis, FF3, if lowbar > highbar then F3 else F10, FF3.TakeValueColor());
AddChartBubble(showbubbles and basis, FF4, if lowbar > highbar then F4 else F8, FF4.TakeValueColor());
AddChartBubble(showbubbles and basis, FF5, if lowbar > highbar then F5 else F7, FF5.TakeValueColor());
AddChartBubble(showbubbles and basis, FF6, if lowbar > highbar then F6 else F6, FF6.TakeValueColor());
AddChartBubble(showbubbles and basis, FF7, if lowbar > highbar then F7 else F5, FF7.TakeValueColor());
AddChartBubble(showbubbles and basis, FF8, if lowbar > highbar then F8 else F4, FF8.TakeValueColor());
AddChartBubble(showbubbles and basis, FF10, if lowbar > highbar then F10 else F3, FF10.TakeValueColor());
AddChartBubble(showbubbles and basis, FF11, if lowbar > highbar then f11 else F2, FF11.TakeValueColor());
AddChartBubble(showbubbles and basis, FF12, if lowbar > highbar then F12 else F1, FF12.TakeValueColor());
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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