Could someone create an indicator for TOS that plots the previous day POC/High/Low/Close/DayMid (Middle of the Day) on a tick chart with the option of selecting and plotting it as an expansion on the chart if needed? Thanks in advance.
Ruby:input daysback = 1; input showonexpansion = no; def ymd = GetYYYYMMDD(); def candles = !IsNaN(close); def capture = candles and ymd != ymd[1]; def dayCount = CompoundValue(1, if capture then dayCount[1] + 1 else dayCount[1], 0); def thisDay = (HighestAll(dayCount) - dayCount) ; def poc = if thisDay == daysback then reference VolumeProfile("price per...
Hi Team,
Is it possible to plot a cloud in light_grey or color of preference between the close from previous day and the current day pivot indicators?
I'll appreciate the support.
input DaysBack = 1;
input DaysBack2 = 2;
input DaysBack3 = 3;
input DaysBack_Y1_POC = 1;
input DaysBack_Y2_POC = 2;
input DaysBack_Y3_POC = 3;
input ShowonExpansion = yes;
input AddCloud = yes;
def ymd = GetYYYYMMDD();
def candles = !IsNaN(close);
def capture = candles and ymd != ymd[1];
def dayCount = CompoundValue(1, if capture then dayCount[1] + 1 else dayCount[1], 0);
def thisDay = (HighestAll(dayCount) - dayCount) ;
def thisDay2 = (HighestAll(dayCount) - dayCount) ;
def thisDay3 = (HighestAll(dayCount) - dayCount) ;
def POC = if thisDay == DaysBack_Y1_POC then reference VolumeProfile("time per profile" = "DAY", "on expansion" = no, "price per row height mode" = "TICKSIZE") else POC[1];
def POC2 = if thisDay2 == DaysBack_Y2_POC then reference VolumeProfile("time per profile" = "DAY", "on expansion" = no, "price per row height mode" = "TICKSIZE") else POC2[2];
def POC3 = if thisDay3 == DaysBack_Y3_POC then reference VolumeProfile("time per profile" = "DAY", "on expansion" = no, "price per row height mode" = "TICKSIZE") else POC3[3];
def phigh = if thisDay == DaysBack then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).ProfileHigh else phigh[1];
def plow = if thisDay == DaysBack then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).ProfileLow else plow[1];
def dopen = if thisDay == 0 then open(period = AggregationPeriod.DAY) else dopen[1];
def popen = if thisDay == DaysBack then open(period = AggregationPeriod.DAY) else popen[1];
def pclose = if thisDay == DaysBack then close(period = AggregationPeriod.DAY) else pclose[1];
plot Y_High = if ShowonExpansion and !IsNaN(close) or thisDay > DaysBack then Double.NaN else phigh;
plot Y_Low = if ShowonExpansion and !IsNaN(close) or thisDay > DaysBack then Double.NaN else plow;
plot D_Open = if ShowonExpansion and !IsNaN(close) or thisDay > 0 then Double.NaN else dopen;
#plot Y_Open = if ShowonExpansion and !isnan(close) or thisday > DaysBack then double.nan else popen;
plot Y_Close = if ShowonExpansion and !IsNaN(close) or thisDay > DaysBack then Double.NaN else pclose;
plot Y_Mid = if ShowonExpansion and !IsNaN(close) or thisDay > DaysBack then Double.NaN else (phigh + plow) / 2;
Y_High.SetDefaultColor(Color.YELLOW);
Y_Low.SetDefaultColor(Color.BLUE);
D_Open.SetDefaultColor(Color.RED);
Y_Mid.SetDefaultColor(Color.BLUE);
###BubbleLabels
input bubblemover = 23;
input bubblemover2 = 1;
input showbubbles = yes;
input showbubbles2 = yes;
def b = bubblemover;
def b1 = b + 1;
def ba = bubblemover2;
def bb = ba + 1;
AddChartBubble(showbubbles2 and IsNaN(close) and !IsNaN(close[b1]), Y_Close, "PD (C" + ")", Y_Close.TakeValueColor());
AddChartBubble(showbubbles2 and IsNaN(close) and !IsNaN(close[b1]), Y_High, "PD (H" + ")", Color.CYAN);
AddChartBubble(showbubbles2 and IsNaN(close[ba]) and !IsNaN(close[b1]), Y_Mid, "PD (M" + ")", Color.CYAN);
AddChartBubble(showbubbles2 and IsNaN(close) and !IsNaN(close[b1]), Y_Low, "PD (L" + ")", Color.CYAN);
AddChartBubble(showbubbles and IsNaN(close[ba]) and !IsNaN(close[bb]), D_Open[ba], "CD (O" + ")", D_Open.TakeValueColor());
###PriceLine
def vClose = close;
def nan = Double.NaN;
def highestClose = HighestAll(if IsNaN(vClose[-1]) then vClose else nan);
plot PriceLine = highestClose;
PriceLine.SetPaintingStrategy(PaintingStrategy.DASHES);
PriceLine.SetDefaultColor(Color.ORANGE);
PriceLine.HideBubble();
PriceLine.HideTitle();
plot PriceValue = if IsNaN(close[-1]) then close else Double.NaN;
PriceValue.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
plot PriceData = if IsNaN(close[-1]) then close else Double.NaN;
PriceData.SetPaintingStrategy(PaintingStrategy.POINTS);
PriceData.SetDefaultColor(Color.WHITE);
PriceData.SetLineWeight(5);
plot PriceData1 = if IsNaN(close[-1]) then close else Double.NaN;
PriceData1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
PriceData1.SetDefaultColor(Color.MAGENTA);
PriceData1.SetLineWeight(5);
DefineGlobalColor("C", Color.LIGHT_GREEN);
plot xpoc = POC;
xpoc.SetHiding(yes);
AddCloud(Y_Close, xpoc, GlobalColor("C"), GlobalColor("C"));
Code:DefineGlobalColor("C", Color.LIGHT_GREEN); plot xpoc = POC; xpoc.SetHiding(yes); AddCloud(Y_Close, xpoc, GlobalColor("C"), GlobalColor("C"));
Code:input DaysBack = 1; input DaysBack2 = 2; input DaysBack3 = 3; input DaysBack_Y1_POC = 1; input DaysBack_Y2_POC = 2; input DaysBack_Y3_POC = 3; input ShowonExpansion = yes; input AddCloud = yes; def ymd = GetYYYYMMDD(); def candles = !IsNaN(close); def capture = candles and ymd != ymd[1]; def dayCount = CompoundValue(1, if capture then dayCount[1] + 1 else dayCount[1], 0); def thisDay = (HighestAll(dayCount) - dayCount) ; def thisDay2 = (HighestAll(dayCount) - dayCount) ; def thisDay3 = (HighestAll(dayCount) - dayCount) ; def POC = if thisDay == DaysBack_Y1_POC then reference VolumeProfile("time per profile" = "DAY", "on expansion" = no, "price per row height mode" = "TICKSIZE") else POC[1]; def POC2 = if thisDay2 == DaysBack_Y2_POC then reference VolumeProfile("time per profile" = "DAY", "on expansion" = no, "price per row height mode" = "TICKSIZE") else POC2[2]; def POC3 = if thisDay3 == DaysBack_Y3_POC then reference VolumeProfile("time per profile" = "DAY", "on expansion" = no, "price per row height mode" = "TICKSIZE") else POC3[3]; def phigh = if thisDay == DaysBack then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).ProfileHigh else phigh[1]; def plow = if thisDay == DaysBack then reference VolumeProfile("price per row height mode" = "TICKSIZE", "time per profile" = "DAY", "on expansion" = no).ProfileLow else plow[1]; def dopen = if thisDay == 0 then open(period = AggregationPeriod.DAY) else dopen[1]; def popen = if thisDay == DaysBack then open(period = AggregationPeriod.DAY) else popen[1]; def pclose = if thisDay == DaysBack then close(period = AggregationPeriod.DAY) else pclose[1]; plot Y_High = if ShowonExpansion and !IsNaN(close) or thisDay > DaysBack then Double.NaN else phigh; plot Y_Low = if ShowonExpansion and !IsNaN(close) or thisDay > DaysBack then Double.NaN else plow; plot D_Open = if ShowonExpansion and !IsNaN(close) or thisDay > 0 then Double.NaN else dopen; #plot Y_Open = if ShowonExpansion and !isnan(close) or thisday > DaysBack then double.nan else popen; plot Y_Close = if ShowonExpansion and !IsNaN(close) or thisDay > DaysBack then Double.NaN else pclose; plot Y_Mid = if ShowonExpansion and !IsNaN(close) or thisDay > DaysBack then Double.NaN else (phigh + plow) / 2; Y_High.SetDefaultColor(Color.YELLOW); Y_Low.SetDefaultColor(Color.BLUE); D_Open.SetDefaultColor(Color.RED); Y_Mid.SetDefaultColor(Color.BLUE); ###BubbleLabels input bubblemover = 10; input bubblemover2 = 1; input showbubbles = yes; input showbubbles2 = yes; def b = bubblemover; def b1 = b + 1; def ba = bubblemover2; def bb = ba + 1; AddChartBubble(showbubbles2 and IsNaN(close[b]) and !IsNaN(close[b1]), Y_Close[b], "PD (C" + ")", Y_Close.TakeValueColor()); AddChartBubble(showbubbles2 and IsNaN(close[b]) and !IsNaN(close[b1]), Y_High[b], "PD (H" + ")", Color.CYAN); AddChartBubble(showbubbles2 and IsNaN(close[b]) and !IsNaN(close[b1]), Y_Mid[b], "PD (M" + ")", Color.CYAN); AddChartBubble(showbubbles2 and IsNaN(close[b]) and !IsNaN(close[b1]), Y_Low[b], "PD (L" + ")", Color.CYAN); AddChartBubble(showbubbles and IsNaN(close[ba]) and !IsNaN(close[bb]), D_Open[ba], "CD (O" + ")", D_Open.TakeValueColor()); ###PriceLine def vClose = close; def nan = Double.NaN; def highestClose = HighestAll(if IsNaN(vClose[-1]) then vClose else nan); plot PriceLine = highestClose; PriceLine.SetPaintingStrategy(PaintingStrategy.DASHES); PriceLine.SetDefaultColor(Color.ORANGE); PriceLine.HideBubble(); PriceLine.HideTitle(); plot PriceValue = if IsNaN(close[-1]) then close else Double.NaN; PriceValue.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW); plot PriceData = if IsNaN(close[-1]) then close else Double.NaN; PriceData.SetPaintingStrategy(PaintingStrategy.POINTS); PriceData.SetDefaultColor(Color.WHITE); PriceData.SetLineWeight(5); plot PriceData1 = if IsNaN(close[-1]) then close else Double.NaN; PriceData1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS); PriceData1.SetDefaultColor(Color.MAGENTA); PriceData1.SetLineWeight(5); DefineGlobalColor("C", Color.LIGHT_GREEN); plot xpoc = POC; xpoc.SetHiding(yes); AddCloud(Y_Close, xpoc, GlobalColor("C"), GlobalColor("C"));
Good to hear from you again SleepyZ.Code:DefineGlobalColor("C", Color.LIGHT_GREEN); plot xpoc = POC; xpoc.SetHiding(yes); AddCloud(Y_Close, xpoc, GlobalColor("C"), GlobalColor("C"));
This will create a cloud between the previous day close and current day poc as an example as I wasn't sure what you meant these clouds to do.
The define global color will allow you to change the color at the input screen.
Since POC was not plotted, but a def, which cannot be used in addcloud, a hidden plot was used.
If you are wanting to create more clouds at current day 'pivots',, such as phigh, pclose, etc from the previous day close, these clouds will likely overlap. So if you need help, let me know specifically what you want, and if possible, including a chart mock up.
The above is in the following code. It also contains a fix to your bubbles so only one plots on a line.
Good to hear from you again SleepyZ.
I apologize for the confusion. I gave you the wrong script that contains an added current day pivot indicator. What you did is absolutely wright and it's what I needed.
the following in the below is the script that was missing so it can be added to complete this indicator.
Thanks for the ongoing excellence in support.
input AggregationPeriod = AggregationPeriod.DAY;
input show_CD_P_Bubble = yes;
input show_price = yes;
input show_coeff = yes;
input bubble_display = {default right, left, none};
input left_bubblemover = 0;
input CD_P_OnExpansion = yes;
def nan = Double.NaN;
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def afterEnd = GetTime() > RegularTradingEnd(GetYYYYMMDD());
def firstBarOfDay = if (beforeStart[1] == 1 and beforeStart == 0) or (isRollover and beforeStart == 0) then 1 else 0;
def lastBarOfDay = if
(afterEnd[-1] == 1 and afterEnd == 0) or
(isRollover[-1] and firstBarOfDay[-1])
then 1
else 0;
def pc = close(period = AggregationPeriod)[1];
def ph = high(period = AggregationPeriod)[1];
def pl = low(period = AggregationPeriod)[1];
def pcext = if IsNaN(close) then pcext[1] else pc;
def phext = if IsNaN(close) then phext[1] else ph;
def plext = if IsNaN(close) then plext[1] else pl;
def delta = if CD_P_OnExpansion then phext - plext else ph - pl;
def pp = if CD_P_OnExpansion then (pcext[1] + phext[1] + plext[1]) / 3 else if firstBarOfDay then (pc + ph + pl) / 3 else if lastBarOfDay or IsNaN(close) then nan else pp[1];
def bbb = left_bubblemover;
def bbb1 = bbb + 1;
plot CD_P = if CD_P_OnExpansion and !IsNaN(close) then Double.NaN else pp;
CD_P.SetDefaultColor(Color.ORANGE);
AddChartBubble(
(if show_CD_P_Bubble and !CD_P_OnExpansion then if bubble_display == bubble_display.left then if IsNaN(close) then Double.NaN else IsNaN(CD_P[bbb1]) and !IsNaN(CD_P[bbb]) else if bubble_display == bubble_display.right then if GetDay() == GetLastDay() and !CD_P_OnExpansion then IsNaN(CD_P[-1]) and !IsNaN(CD_P) else lastBarOfDay == 0 and lastBarOfDay[-1] == 1 else Double.NaN else if show_CD_P_Bubble and CD_P_OnExpansion then BarNumber() == HighestAll(BarNumber()) else Double.NaN), if bubble_display == bubble_display.right then CD_P else CD_P[bbb], (if show_CD_P_Bubble then "CD (P)" else "") + if show_price then " " + if bubble_display == bubble_display.right then AsText(CD_P) else AsText(CD_P[bbb]) else "", color.ORANGE);
Code:DefineGlobalColor("C", Color.LIGHT_GREEN); plot xpc = PC; xpc.SetHiding(yes); AddCloud(cd_p, xpc, GlobalColor("C"), GlobalColor("C"));
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
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.
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.