Posts

Showing posts with the label Higher Timeframe

Handling Timeframes in Pine Script v6: timeframe.period and timeframe.multiplier Explained

Image
When building indicators or strategies that must behave differently depending on whether the user is viewing a 1-minute chart versus a daily chart, Pine Script v6 provides two essential built-in variables: timeframe.period and timeframe.multiplier . Understanding how these two variables work together allows you to write scripts that dynamically adapt their logic to any chart resolution without hardcoding timeframe assumptions. 1. What Are timeframe.period and timeframe.multiplier ? Pine Script v6 exposes several built-in timeframe.* variables that describe the chart's current resolution at runtime. The two most important for dynamic adaptation are: Variable Type Description Example (1H chart) timeframe.period simple string The full timeframe string of the current chart (e.g., "60", "D", "W") "60" ...

Pine Script v6: How to Use request.security to Fetch Higher-Timeframe Data

Image
When building multi-timeframe indicators in TradingView, one of the most common needs is to overlay a higher-timeframe signal — such as a daily moving average — onto a lower-timeframe chart like a 15-minute view. The request.security() function is the primary tool for this task in Pine Script v6, and understanding its parameters precisely is essential for writing accurate, non-repainting indicators and strategies. 1. What Is request.security() ? request.security() allows a Pine Script to fetch the value of any expression as it would be calculated on a different symbol or timeframe. The result is then mapped back onto the current chart's bar timeline. This is the foundation of multi-timeframe (MTF) analysis in Pine Script. For the full official signature, refer to the Reference Manual: request.security() — Pine Script v6 Reference . 2. Core Parameters Explained The following table describes the most critical parameters you will u...