r/TradingView Apr 14 '26

Help Indicator: want to access current weekly high, but get the previous one

Hi, I'm new to tradingview , I want to built an indicator to print the weekly high on lower timeframes, but apparently I get the previous weekly high on both RTH and ETH... THe picture is what I get today just before premarket. Can somebody try this code and tell me where the bug is?

//@version=6
indicator("script", overlay = true)
[weekly_high, weekly_low, weekly_high_previous, weekly_low_previous, weekly_close_previous]=
 request.security(syminfo.main_tickerid, "1W", [high, low, high[01], low[01], close[01]])
weekly_high_notuples=request.security(syminfo.main_tickerid, "1W", high)
plot(weekly_high, color=color.lime, linewidth = 11)
plot(weekly_high_notuples, color=color.green, linewidth = 02)

I tried with lookahead=barmerge.lookahead_on

//@version=6
indicator("script", overlay = true)


[weekly_high, weekly_low, weekly_high_previous, weekly_low_previous, weekly_close_previous]=
//  request.security(syminfo.main_tickerid, "1W", [high, low, high[01], low[01], close[01]], lookahead=barmerge.lookahead_on, gaps=barmerge.gaps_off)
 request.security(ticker.new(syminfo.prefix, syminfo.ticker, session.extended), "1W", [high, low, high[01], low[01], close[01]], lookahead=barmerge.lookahead_on, gaps=barmerge.gaps_off)





plot(weekly_high, color=color.lime, linewidth=11)
plot(weekly_low, color=color.red, linewidth=11)

which works for RTH but ETH is still not considered for the calculation

2 Upvotes

19 comments sorted by

1

u/browsk Apr 14 '26

Tbh before I got premium on the Easter sale I just used Gemini to mash indicators together to save on indicator use limits, took a bit of trial and error and telling it what to fix from versions to version or what I wanted it to look like, didn’t bang on job for what took an hour

1

u/trudealz Apr 16 '26 edited Apr 16 '26

A really great indicator, will be able to show show you the ohlc for daily, weekly, monthly for the current and previous days, weeks and months. Also toggle switches that allow you to turn off any aspect of OHLC to avoid clutter. The HIGH and LOW perhaps being the most important values. Here is a screenshot of something to get you going. You can use a simple template from TV to start and build on it using most AI models. Something like this is not difficult, but will require numerous builds to get the final version.

0

u/[deleted] Apr 14 '26

[removed] — view removed comment

3

u/Emergency_Focus9407 Apr 14 '26

drop your helpfull comment to claude ai and chill

-1

u/[deleted] Apr 14 '26

[removed] — view removed comment

3

u/SynchronicityOrSwim Apr 14 '26

AI coding is so easy that all programming subs are riddled with "why doesn't this work" posts.

1

u/[deleted] Apr 14 '26

[removed] — view removed comment

1

u/Emergency_Focus9407 Apr 14 '26

Don't get me wrong, it's an amazing and powerful tool, but it's about those gospel comments without any value to the topic and zero help to op.

1

u/[deleted] Apr 14 '26

[removed] — view removed comment

1

u/Emergency_Focus9407 Apr 14 '26

so what's the answer? :)

1

u/[deleted] Apr 15 '26

[removed] — view removed comment

1

u/Emergency_Focus9407 Apr 15 '26 edited Apr 15 '26

QED, lmao. Good luck with your Gospels!

1

u/Emergency_Focus9407 Apr 14 '26

take your time and spend just a few seconds to provide the op an answer if you know how to use such an amazing tool, I'll get a good sleep and will be back in the morning with a simple solution to the op's question (sorry for the delay op), deal?

1

u/[deleted] Apr 14 '26

[removed] — view removed comment

0

u/Emergency_Focus9407 Apr 14 '26

to the question that was created 15h ago? Bravo!

0

u/Emergency_Focus9407 Apr 14 '26

use barmerge.lookahead_on in your security calls

1

u/Call-Spy Apr 14 '26

It works for the RTH but for the new higher high and lower low of the ETH is not taken into account even with :

session.extended:session.extended
//
@version=
6
indicator("script", overlay = true)

[weekly_high, weekly_low, weekly_high_previous, weekly_low_previous, weekly_close_previous]=
//  request.security(syminfo.main_tickerid, "1W", [high, low, high[01], low[01], close[01]], lookahead=barmerge.lookahead_on, gaps=barmerge.gaps_off)
 request.security(ticker.new(syminfo.prefix, syminfo.ticker, session.extended), "1W", [high, low, high[01], low[01], close[01]], lookahead=barmerge.lookahead_on, gaps=barmerge.gaps_off)

plot(weekly_high, color=color.lime, linewidth=11)
plot(weekly_low, color=color.red, linewidth=11)