Highlight previous 15 mins candle OHLC

Lees

New member
I have code to highlight previous day Open High Low Close. I need a help to draw horizontal line or highlight previous 15 mins candle open high low close. Is there any code snippet available for that?

Thanks,
Syed
 

Pensar

Well-known member
VIP
@Lees See if this works.

Code:
#Fifteen Minute OHLC

plot o = open(period = aggregationperiod.FIFTEEN_MIN)[1];
     o.setpaintingstrategy(paintingstrategy.horizontal);
     o.setdefaultcolor(color.orange);
plot h = high(period = aggregationperiod.FIFTEEN_MIN)[1];
     h.setpaintingstrategy(paintingstrategy.horizontal);
     h.setdefaultcolor(color.green);
plot l = low(period = aggregationperiod.FIFTEEN_MIN)[1];
     l.setpaintingstrategy(paintingstrategy.horizontal);
     l.setdefaultcolor(color.red);
plot c = close(period = aggregationperiod.FIFTEEN_MIN)[1];
     c.setpaintingstrategy(paintingstrategy.horizontal);
     c.setdefaultcolor(color.yellow);
 

Lees

New member
Thanks for the repsponse @Pensar. I am seeing horizontal lines on all 15 mins candles. I want horizontal line only on Previous 15 min candle OHCL when current 15 mins candle is developing. Once current 15 mins completes horizontal line has to be moved here while new 15 mins candle developing.
 

ICE_Cold

New member
@Lees See if this works.

Code:
#Fifteen Minute OHLC

plot o = open(period = aggregationperiod.FIFTEEN_MIN)[1];
     o.setpaintingstrategy(paintingstrategy.horizontal);
     o.setdefaultcolor(color.orange);
plot h = high(period = aggregationperiod.FIFTEEN_MIN)[1];
     h.setpaintingstrategy(paintingstrategy.horizontal);
     h.setdefaultcolor(color.green);
plot l = low(period = aggregationperiod.FIFTEEN_MIN)[1];
     l.setpaintingstrategy(paintingstrategy.horizontal);
     l.setdefaultcolor(color.red);
plot c = close(period = aggregationperiod.FIFTEEN_MIN)[1];
     c.setpaintingstrategy(paintingstrategy.horizontal);
     c.setdefaultcolor(color.yellow);
Hello Pensar, is it possible to get these lines to extend to the left and to the right over a 2 day period to include premarket and post market candle data, as well as to show the price values? Thanks.
 

tripletrades

New member
i just joined and am looking for something similar in my last post, except for the daily time frame, not 15 min. I've got it so only the previous day has extended lines. if that's what you're looking for feel free to copy my code!

EDIT:
#
input aggregationPeriod = AggregationPeriod.day;
input length = 1;
input displace = -1;
input showLastPeriod = no;
plot PrevDayClose;
if showLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) { PrevDayClose = Double.NaN;
} else { PrevDayClose = Highest(close(period = aggregationPeriod)[-displace], length);
}
PrevDayClose.SetDefaultColor(GetColor(9));
PrevDayClose.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

i just found this while trying to fix my issue, hope this helps!
 
Last edited:

ICE_Cold

New member
i just joined and am looking for something similar in my last post, except for the daily time frame, not 15 min. I've got it so only the previous day has extended lines. if that's what you're looking for feel free to copy my code!

EDIT:
#
input aggregationPeriod = AggregationPeriod.day;
input length = 1;
input displace = -1;
input showLastPeriod = no;
plot PrevDayClose;
if showLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) { PrevDayClose = Double.NaN;
} else { PrevDayClose = Highest(close(period = aggregationPeriod)[-displace], length);
}
PrevDayClose.SetDefaultColor(GetColor(9));
PrevDayClose.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

i just found this while trying to fix my issue, hope this helps!
Welcome to the Forum, and Thanks. I'll check it out.

Just to give to a head start, the attached link has some interesting resources. The link I got from this Forum.

https://onedrive.live.com/redir?res...02.13.|30461c4b-420e-4b83-b56f-55faf5d1461b/)
 

SleepyZ

Active member
Hello Pensar, is it possible to get these lines to extend to the left and to the right over a 2 day period to include premarket and post market candle data, as well as to show the price values? Thanks.
See if this helps
Code:
#Usethinkscript request - Prior Bar OHLC extended right and 2 days to the left with price displayed
def lastbar  = if IsNaN(close[-1]) and !IsNaN(close) then BarNumber() else Double.NaN;
def dayCount = CompoundValue(1, if GetYYYYMMDD() != GetYYYYMMDD()[1] then dayCount[1] + 1 else dayCount[1], 0);
def thisDay  = (HighestAll(dayCount) - dayCount) ;

input bars_back      = 1;
input days_displayed = 2;

def v_priorbarclose  = HighestAll(if BarNumber() == HighestAll(lastbar - bars_back) then close else Double.NaN);
plot p_priorbarclose = if thisDay < days_displayed + 1 then v_priorbarclose else Double.NaN;
AddChartBubble(BarNumber() == HighestAll(BarNumber()),
                              p_priorbarclose,
                              "C:" + Astext(v_priorbarclose), Color.WHITE);

def v_priorbaropen   = HighestAll(if BarNumber() == HighestAll(lastbar - bars_back) then open else Double.NaN);
plot p_priorbaropen  = if thisDay < days_displayed + 1 then v_priorbaropen else Double.NaN;
AddChartBubble(BarNumber() == HighestAll(BarNumber()),
                              p_priorbaropen,
                              "O:" + Astext(v_priorbaropen), Color.WHITE);

def v_priorbarhigh  = HighestAll(if BarNumber() == HighestAll(lastbar - bars_back) then high else Double.NaN);
plot p_priorbarhigh  = if thisDay < days_displayed + 1 then v_priorbarhigh else Double.NaN;
AddChartBubble(BarNumber() == HighestAll(BarNumber()),
                              p_priorbarhigh,
                              "H:" + Astext(v_priorbarhigh), Color.WHITE);

def v_priorbarlow   = HighestAll(if BarNumber() == HighestAll(lastbar - bars_back) then low else Double.NaN);
plot p_priorbarlow  = if thisDay < days_displayed + 1 then v_priorbarlow else Double.NaN;
AddChartBubble(BarNumber() == HighestAll(BarNumber()),
                              p_priorbarlow,
                              "L:" + Astext(v_priorbarlow), Color.WHITE, no);
Capture.jpg
 

tripletrades

New member

Similar threads

Top