I want to write an indicator for tradingview that should draw a vertical line on a specific level depending on the active time frame, e.g. on the 5-minute-chart the indicator should draw the line at a different level than on the 60-minute-chart.
I have allready tried "resolution". Here is a snippet of the code:
x = (resolution == "5") ? 10 : (resolution == "60") ? 20 : 30
plot(x)
So this should draw a line at level 10, if the chart is on the 5-minute-time-frame, at level 20 on the 60-minute-time-frame and at level 30 for all other time frames.
But it allways draws at level 30, so the code has to be incorrect. I allready researched that "resolution" is a constant of the "input"-function, so it seems that it cannot be used outside of this function.
So my question is: What is the right code? Thank you!
For Pine Script v4 the variable you are looking for is called timeframe.period
.
E.g. '60' - 60 minutes, 'D' - daily, 'W' - weekly, 'M' - monthly, '5D' - 5 days, '12M' - one year, '3M' - one quarter
Pine reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With