sk123
Pine Script Rookie
Pine Script Rookie
Posts: 1
Joined: December 7th, 2020

Referencing the chart's resolution inside of a conditional statement?

here is an example of what I am trying to do.

If chart's resolution is 15minutes, then use 0.1 value for an indicator.
If chart's resolution is 30 minutes, then use 0.2 value.
If charts resolution is 1h, then use xyz value...

etc.

User avatar
Matthew
Site Admin
Site Admin
Posts: 92
Joined: July 1st, 2020
Location: Australia
Contact: Website Facebook Twitter TradingView Profile

Re: Referencing the chart's resolution inside of a conditional statement?

Hi sk123! You need to use the inbuilt variable timeframe.period to do this.

Here's a script you might find interesting that uses a boatload of conditional statements with the chart resolution:

https://zenandtheartoftrading.com/indic ... l-by-time/

Return to “Pine Script Q&A”