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
 
@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);
 
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.
 
@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.
 
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:
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/)
 
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
 
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.
What would I need to add so once the most current OHLC are confirmed and moved ahead all the remaining past OHLC are not visible?
 

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