draw line and mark price for High,Low,Open and Close

Billscript

New member
Friends,

Looking a for a script to draw lines and mark price for High, Low, Open and Close for 3 aggregation periods.

Previous Month, Previous Week and Previous Day.

Appreciate the help.
 
Solution
@Billscript
quick and dirty
Probably need to uncheck 'fit studies' on your price axis settings.

Ruby:
def MonthHigh = high(period=aggregationPeriod.MONTH)[1];
def MonthLow = low(period=aggregationPeriod.MONTH)[1];
def MonthOpen = open(period=aggregationPeriod.MONTH)[1];
def MonthClose = close(period=aggregationPeriod.MONTH)[1];

def WeekHigh = high(period=aggregationPeriod.WEEK)[1];
def WeekLow = low(period=aggregationPeriod.WEEK)[1];
def WeekOpen = open(period=aggregationPeriod.WEEK)[1];
def WeekClose = close(period=aggregationPeriod.WEEK)[1];

def DayHigh = high(period=aggregationPeriod.DAY)[1];
def DayLow = low(period=aggregationPeriod.DAY)[1];
def DayOpen = open(period=aggregationPeriod.DAY)[1];
def DayClose =...
@Billscript
quick and dirty
Probably need to uncheck 'fit studies' on your price axis settings.

Ruby:
def MonthHigh = high(period=aggregationPeriod.MONTH)[1];
def MonthLow = low(period=aggregationPeriod.MONTH)[1];
def MonthOpen = open(period=aggregationPeriod.MONTH)[1];
def MonthClose = close(period=aggregationPeriod.MONTH)[1];

def WeekHigh = high(period=aggregationPeriod.WEEK)[1];
def WeekLow = low(period=aggregationPeriod.WEEK)[1];
def WeekOpen = open(period=aggregationPeriod.WEEK)[1];
def WeekClose = close(period=aggregationPeriod.WEEK)[1];

def DayHigh = high(period=aggregationPeriod.DAY)[1];
def DayLow = low(period=aggregationPeriod.DAY)[1];
def DayOpen = open(period=aggregationPeriod.DAY)[1];
def DayClose = close(period=aggregationPeriod.DAY)[1];

def Today = SecondsFromTime(0430)>=0 and SecondsTillTime(1700)>=0;


plot MHigh = if Today and !isnan(close) then MonthHigh else double.nan;
MHigh.SetStyle(Curve.SHORT_DASH);
plot MLow = if Today and !isnan(close) then MonthLow else double.nan;
MLow.SetStyle(Curve.SHORT_DASH);
plot MOpen = if Today and !isnan(close) then MonthOpen else double.nan;
MOpen.SetStyle(Curve.SHORT_DASH);
plot MClose = if Today and !isnan(close) then MonthClose else double.nan;
MClose.SetStyle(Curve.SHORT_DASH);

plot WHigh = if Today and !isnan(close) then WeekHigh else double.nan;
WHigh.SetStyle(Curve.SHORT_DASH);
plot WLow = if Today and !isnan(close) then WeekLow else double.nan;
WLow.SetStyle(Curve.SHORT_DASH);
plot WOpen = if Today and !isnan(close) then WeekOpen else double.nan;
WOpen.SetStyle(Curve.SHORT_DASH);
plot WClose = if Today and !isnan(close) then WeekClose else double.nan;
WClose.SetStyle(Curve.SHORT_DASH);

plot DHigh = if Today and !isnan(close) then DayHigh else double.nan;
DHigh.SetStyle(Curve.SHORT_DASH);
plot DLow = if Today and !isnan(close) then DayLow else double.nan;
DLow.SetStyle(Curve.SHORT_DASH);
plot DOpen = if Today and !isnan(close) then DayOpen else double.nan;
DOpen.SetStyle(Curve.SHORT_DASH);
plot DClose = if Today and !isnan(close) then DayClose else double.nan;
DClose.SetStyle(Curve.SHORT_DASH);

addchartbubble(!isnan(MHigh[1]) and isnan(MHigh),Mhigh[1],"Previous Month High "+Mhigh[1],color.white);
addchartbubble(!isnan(MLow[1]) and isnan(MLow),MLow[1],"Previous Month Low "+MLow[1],color.white);
addchartbubble(!isnan(MOpen[1]) and isnan(MOpen),MOpen[1],"Previous Month Open "+MOpen[1],color.white);
addchartbubble(!isnan(MClose[1]) and isnan(MClose),MClose[1],"Previous Month Close "+MClose[1],color.white);

addchartbubble(!isnan(WHigh[1]) and isnan(WHigh),WHigh[1],"Previous Week High "+WHigh[1],color.white);
addchartbubble(!isnan(WLow[1]) and isnan(WLow),WLow[1],"Previous Week Low "+WLow[1],color.white);
addchartbubble(!isnan(WOpen[1]) and isnan(WOpen),WOpen[1],"Previous Week Open "+WOpen[1],color.white);
addchartbubble(!isnan(WClose[1]) and isnan(WClose),WClose[1],"Previous Week Close "+WClose[1],color.white);

addchartbubble(!isnan(DHigh[1]) and isnan(DHigh),DHigh[1],"Previous Day High "+DHigh[1],color.white);
addchartbubble(!isnan(DLow[1]) and isnan(DLow),DLow[1],"Previous Day Low "+DLow[1],color.white);
addchartbubble(!isnan(DOpen[1]) and isnan(DOpen),DOpen[1],"Previous Day Open "+DOpen[1],color.white);
addchartbubble(!isnan(DClose[1]) and isnan(DClose),DClose[1],"Previous Day Close "+DClose[1],color.white);
 
Solution

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