Simple Scalper using Pivots from last Higher timeframe candleHTF Pivot Levels – Proper Alignment
Version: 1.0
Pine Script Version: 5
Overlay: Yes
Author: Ammar Hasan
Description
This is very rudimentary beginner friendly indicator to help scalpers scalp level to level using previous higher timeframe pivot points.
This indicator draws pivot levels based on Higher Timeframe (HTF) candles on a lower timeframe chart. It calculates Pivot, Support (S1–S3), and Resistance (R1–R3) levels from the last closed HTF candle and draws them precisely on the lower timeframe bars corresponding to that candle.
Key Features:
Works on any lower timeframe chart (e.g., 1m, 5m) using higher timeframe inputs (e.g., 15m, 1h).
Draws 7 levels per HTF candle: Pivot (yellow), S1–S3 (red), R1–R3 (green).
Only shows the last maxBars HTF candles to keep the chart clean.
Fully aligned with the actual closed HTF candle, avoiding forward shifts.
No labels, repainting, or multi-line statements.
Inputs
Name Type Default Description
Higher Timeframe Timeframe "10" HTF to base pivot calculations on.
Max HTF Bars to Keep Integer (1–50) 7 Number of HTF candles to display at once.
Calculations
Pivot Level:
Pivot = (High + Low + Close) / 3
Support Levels:
S1 = 2 × Pivot − High
S2 = Pivot − (High − Low)
S3 = Low − 2 × (High − Pivot)
Resistance Levels:
R1 = 2 × Pivot − Low
R2 = Pivot + (High − Low)
R3 = High + 2 × (Pivot − Low)
Where High, Low, Close are from the last closed HTF candle.
Drawing Logic
Lower TF bars per HTF candle is calculated as:
LowerBarsPerHTF = HTF_seconds / LowerTF_seconds
Lines are drawn from x1 to x2:
x1 = (htf_count − 2) × LowerBarsPerHTF
x2 = x1 + LowerBarsPerHTF − 1
This ensures lines are aligned exactly with the lower TF bars corresponding to the HTF candle.
Lines are deleted once maxBars is exceeded to keep the chart clean.
Colors
Level Color
Pivot Yellow
S1–S3 Red
R1–R3 Green
Notes
Repainting: The indicator only uses closed HTF candles (lookahead=barmerge.lookahead_off) to prevent repainting.
Chart Compatibility: Works on any lower timeframe chart; HTF input can be any valid TradingView timeframe.
Scalping Use: Useful for seeing higher timeframe support/resistance levels on intraday charts.
Penunjuk Pine Script®






















