• Get $40 off VIP by signing up for a free account! Sign Up

daily, weekly and monthly OHLC lines

Solution
Hey
I've been trying to look all over for an indicator that draws daily, weekly and monthly OHLC lines but all the way to the right and not like the usual on the very day or week section could one of the guru here right a code like this?
https://usethinkscript.com/threads/auto-significant-price-levels-for-thinkorswim.4867/

like 5 days back and weeks and months
thank you to you all

This has 3 scripts (D, W and M) that were used to plot Today and 5 days back of Opens, Highs, Lows and Closes to the right edge of the chart.
You can modify the colors of the price's lines at the input screen
Make sure you have enough days in your chart to lookback to the longest aggregation.

Hey
I've been trying to look all over for an indicator that draws daily, weekly and monthly OHLC lines but all the way to the right and not like the usual on the very day or week section could one of the guru here right a code like this?
https://usethinkscript.com/threads/auto-significant-price-levels-for-thinkorswim.4867/

like 5 days back and weeks and months
thank you to you all

This has 3 scripts (D, W and M) that were used to plot Today and 5 days back of Opens, Highs, Lows and Closes to the right edge of the chart.
You can modify the colors of the price's lines at the input screen
Make sure you have enough days in your chart to lookback to the longest aggregation.

Screenshot 2024-05-23 085448.png
Code:
#OHLC_DayWeekMonth_Lookback_Extended_RightEdge

script D {
input lookback = 0;
input price    = FundamentalType.OPEN;
def na         = Double.NaN;
def ymd        = GetYYYYMMDD();
def countday   = if !IsNaN(close) and ymd != ymd[1] then countday[1] + 1 else countday[1];
def condday    = HighestAll(countday) - countday;
def dayprice   = if condday == lookback then Fundamental(price, period = AggregationPeriod.DAY) else na;
plot day_price = if condday <= lookback then HighestAll(dayprice) else na;
}

plot DOpen0 = D(0).day_price;
plot DOpen1 = D(1).day_price;
plot DOpen2 = D(2).day_price;
plot DOpen3 = D(3).day_price;
plot DOpen4 = D(4).day_price;
plot DOpen5 = D(5).day_price;

plot DHigh0 = D(0,"High").day_price;
plot DHigh1 = D(1,"High").day_price;
plot DHigh2 = D(2,"High").day_price;
plot DHigh3 = D(3,"High").day_price;
plot DHigh4 = D(4,"High").day_price;
plot DHigh5 = D(5,"High").day_price;

plot DLow0 = D(0,"Low").day_price;
plot DLow1 = D(1,"Low").day_price;
plot DLow2 = D(2,"Low").day_price;
plot DLow3 = D(3,"Low").day_price;
plot DLow4 = D(4,"Low").day_price;
plot DLow5 = D(5,"Low").day_price;

plot DClose0 = D(0,"Close").day_price;
plot DClose1 = D(1,"Close").day_price;
plot DClose2 = D(2,"Close").day_price;
plot DClose3 = D(3,"Close").day_price;
plot DClose4 = D(4,"Close").day_price;
plot DClose5 = D(5,"Close").day_price;

defineglobalColor("O", color.white);
defineglobalColor("H", color.green);
defineglobalColor("L", color.red);
defineglobalColor("C", color.yellow);

DOpen0.assignValueColor(globalcolor("O"));
DOpen1.assignValueColor(globalcolor("O"));
DOpen2.assignValueColor(globalcolor("O"));
DOpen3.assignValueColor(globalcolor("O"));
DOpen4.assignValueColor(globalcolor("O"));
DOpen5.assignValueColor(globalcolor("O"));

DHigh0.assignValueColor(globalcolor("H"));
DHigh1.assignValueColor(globalcolor("H"));
DHigh2.assignValueColor(globalcolor("H"));
DHigh3.assignValueColor(globalcolor("H"));
DHigh4.assignValueColor(globalcolor("H"));
DHigh5.assignValueColor(globalcolor("H"));

DLow0.assignValueColor(globalcolor("L"));
DLow1.assignValueColor(globalcolor("L"));
DLow2.assignValueColor(globalcolor("L"));
DLow3.assignValueColor(globalcolor("L"));
DLow4.assignValueColor(globalcolor("L"));
DLow5.assignValueColor(globalcolor("L"));

DClose0.assignValueColor(globalcolor("C"));
DClose1.assignValueColor(globalcolor("C"));
DClose2.assignValueColor(globalcolor("C"));
DClose3.assignValueColor(globalcolor("C"));
DClose4.assignValueColor(globalcolor("C"));
DClose5.assignValueColor(globalcolor("C"));

script W {
input lookback = 0;
input price    = FundamentalType.OPEN;
def na         = Double.NaN;
def ymd        = Getweek();
def countweek  = if !IsNaN(close) and ymd != ymd[1] then countweek[1] + 1 else countweek[1];
def condweek   = HighestAll(countweek) - countweek;
def weekprice  = if condweek == lookback then Fundamental(price, period = AggregationPeriod.week) else na;
plot weel_price = if condweek <= lookback then HighestAll(weekprice) else na;
}

plot WOpen0 = W(0).week_price;
plot wOpen1 = W(1).week_price;
plot WOpen2 = W(2).week_price;
plot WOpen3 = W(3).week_price;
plot WOpen4 = W(4).week_price;
plot WOpen5 = W(5).week_price;

plot WHigh0 = W(0,"High").week_price;
plot WHigh1 = W(1,"High").week_price;
plot WHigh2 = W(2,"High").week_price;
plot WHigh3 = W(3,"High").week_price;
plot WHigh4 = W(4,"High").week_price;
plot WHigh5 = W(5,"High").week_price;

plot WLow0 = W(0,"Low").week_price;
plot WLow1 = W(1,"Low").week_price;
plot WLow2 = W(2,"Low").week_price;
plot WLow3 = W(3,"Low").week_price;
plot WLow4 = W(4,"Low").week_price;
plot WLow5 = W(5,"Low").week_price;

plot WClose0 = W(0,"Close").week_price;
plot WClose1 = W(1,"Close").week_price;
plot WClose2 = W(2,"Close").week_price;
plot WClose3 = W(3,"Close").week_price;
plot WClose4 = W(4,"Close").week_price;
plot WClose5 = W(5,"Close").week_price;


WOpen0.assignValueColor(globalcolor("O"));
WOpen1.assignValueColor(globalcolor("O"));
WOpen2.assignValueColor(globalcolor("O"));
WOpen3.assignValueColor(globalcolor("O"));
WOpen4.assignValueColor(globalcolor("O"));
WOpen5.assignValueColor(globalcolor("O"));

WHigh0.assignValueColor(globalcolor("H"));
WHigh1.assignValueColor(globalcolor("H"));
WHigh2.assignValueColor(globalcolor("H"));
WHigh3.assignValueColor(globalcolor("H"));
WHigh4.assignValueColor(globalcolor("H"));
WHigh5.assignValueColor(globalcolor("H"));

WLow0.assignValueColor(globalcolor("L"));
WLow1.assignValueColor(globalcolor("L"));
WLow2.assignValueColor(globalcolor("L"));
WLow3.assignValueColor(globalcolor("L"));
WLow4.assignValueColor(globalcolor("L"));
WLow5.assignValueColor(globalcolor("L"));

WClose0.assignValueColor(globalcolor("C"));
WClose1.assignValueColor(globalcolor("C"));
WClose2.assignValueColor(globalcolor("C"));
WClose3.assignValueColor(globalcolor("C"));
WClose4.assignValueColor(globalcolor("C"));
WClose5.assignValueColor(globalcolor("C"));

script M {
input lookback = 0;
input price    = FundamentalType.OPEN;
def na         = Double.NaN;
def ymd        = Getmonth();
def countmon   = if !IsNaN(close) and ymd != ymd[1] then countmon[1] + 1 else countmon[1];
def condmon    = HighestAll(countmon) - countmon;
def monprice   = if condmon == lookback then Fundamental(price, period = AggregationPeriod.month) else na;
plot mon_price = if condmon <= lookback then HighestAll(monprice) else na;
}

plot MOpen0 = M(0).mon_price;
plot MOpen1 = M(1).mon_price;
plot MOpen2 = M(2).mon_price;
plot MOpen3 = M(3).mon_price;
plot MOpen4 = M(4).mon_price;
plot MOpen5 = M(5).mon_price;

plot MHigh0 = M(0,"High").mon_price;
plot MHigh1 = M(1,"High").mon_price;
plot MHigh2 = M(2,"High").mon_price;
plot MHigh3 = M(3,"High").mon_price;
plot MHigh4 = M(4,"High").mon_price;
plot MHigh5 = M(5,"High").mon_price;

plot MLow0 = M(0,"Low").mon_price;
plot MLow1 = M(1,"Low").mon_price;
plot MLow2 = M(2,"Low").mon_price;
plot MLow3 = M(3,"Low").mon_price;
plot MLow4 = M(4,"Low").mon_price;
plot MLow5 = M(5,"Low").mon_price;

plot MClose0 = M(0,"Close").mon_price;
plot MClose1 = M(1,"Close").mon_price;
plot MClose2 = M(2,"Close").mon_price;
plot MClose3 = M(3,"Close").mon_price;
plot MClose4 = M(4,"Close").mon_price;
plot MClose5 = M(5,"Close").mon_price;

MOpen0.assignValueColor(globalcolor("O"));
MOpen1.assignValueColor(globalcolor("O"));
MOpen2.assignValueColor(globalcolor("O"));
MOpen3.assignValueColor(globalcolor("O"));
MOpen4.assignValueColor(globalcolor("O"));
MOpen5.assignValueColor(globalcolor("O"));

MHigh0.assignValueColor(globalcolor("H"));
MHigh1.assignValueColor(globalcolor("H"));
MHigh2.assignValueColor(globalcolor("H"));
MHigh3.assignValueColor(globalcolor("H"));
MHigh4.assignValueColor(globalcolor("H"));
MHigh5.assignValueColor(globalcolor("H"));

MLow0.assignValueColor(globalcolor("L"));
MLow1.assignValueColor(globalcolor("L"));
MLow2.assignValueColor(globalcolor("L"));
MLow3.assignValueColor(globalcolor("L"));
MLow4.assignValueColor(globalcolor("L"));
MLow5.assignValueColor(globalcolor("L"));

MClose0.assignValueColor(globalcolor("C"));
MClose1.assignValueColor(globalcolor("C"));
MClose2.assignValueColor(globalcolor("C"));
MClose3.assignValueColor(globalcolor("C"));
MClose4.assignValueColor(globalcolor("C"));
MClose5.assignValueColor(globalcolor("C"));
 
Solution
This has 3 scripts (D, W and M) that were used to plot Today and 5 days back of Opens, Highs, Lows and Closes to the right edge of the chart.
You can modify the colors of the price's lines at the input screen
Make sure you have enough days in your chart to lookback to the longest aggregation.
Thank you so much for this, you are a genius.
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
462 Online
Create Post

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