Reputation: 37
Tradingview displays the price points of a security over a certain time period, for instance in 1 min interval, 5 min interval, 15 min interval etc.
I want to be able to use certain multiples of the time interval of the "current chart."
So I were to be working with a min chart, but want to import the 5 min, 15 min, 30 min interval charts into it, I can use the following
//@version=3
study(title="5 15 30 min triple plot", overlay=true)
my_m = security(tickerid, '5', close)
my_h = security(tickerid, '15', close)
my_fh = security(tickerid, '30', close)
plot(my_m, color=blue)
plot(my_h, color=red)
plot(my_fh, color=purple)
That will do it, but if I were to work with higher time frames, like 1 hr, 2hrs, 4 hrs etc, the code above won't work, and I have to change it every time.
What will help tremendously is if I can somehow import the current time frame, for instance 1 hr and multiply it by a certain number.
There is a function or variable or something called period which refers to the current period or the time frame. There is also interval which appears to be the same thing(?)
But doing the following doesn't work.
adt1 = 5*period
adt2 = 10*period
adt3 = 30*period
my_m = security(tickerid, 'adt1', close)
my_h = security(tickerid, 'adt2', close)
my_fh = security(tickerid, 'adt3', close)
plot(my_m, color=blue)
plot(my_h, color=red)
plot(my_fh, color=purple)
It throws the following error
Add to Chart operation failed, reason: line 13: Cannot call operator *
with arguments (literal integer, string); available overloads: *(integer, integer) => integer; *(float, float) => float; *(const integer, const integer) => const integer; *(const float, const float) => const float; *(integer, series[integer]) => series[integer]; *(series[integer], integer) => series[integer]; *(series[integer], series[integer]) => series[integer]; *(float, series) => series; *(series, float) => series; *(series, series) => series;
Any tips on how to make combine higher time frames with lower frame charts based on the current chart's time frame and given multiples? (This will be loaded as an indicator into the chart window. )
Upvotes: 0
Views: 647
Reputation: 11
Requesting data of "1h" or "1H" resolution would result in an error. Use "60" instead.
Upvotes: 1