newbie_coder
newbie_coder

Reputation: 3

How to collect data from two seperate timeframe under one indicator on Pinescript v5?

I want to copy my script, change the values and merge them under one indicator. I can do it by myself but I have one problem. If I start like this;

//@version=5
//First Indicator
indicator(title="First Indicator", shorttitle="First Indicator", format=format.price, timeframe="D", timeframe_gaps=true)

The second part of the indicator is effected as well.

I want the first part will plot ''daily'', and the second part will use ''weekly'' period to plot the line. Whatever timeframe I select, I want the the first indicator will use 'daily' info and second one will use 'weekly' info.

What should I add to the script. Can anyone help? ı tried this but I couldn't make it. timeFrame = request.security (symbol=syminfo.tickerid, timeframe = "D", expression = close)

Upvotes: 0

Views: 160

Answers (1)

Novelty Trade
Novelty Trade

Reputation: 106

indicator(title="First Indicator", overlay = true)

dayly_close = request.security(syminfo.tickerid, 'D', close)
weekly_close = request.security(syminfo.tickerid, 'W', close)

and then just use variables dayly_close and weekly_close at any timeframe

Upvotes: 1

Related Questions