Premium/discount

Whether price sits in the upper (premium) or lower (discount) half of the last swing.

From the last confirmed swing leg (the last pivot high H and pivot low L; swing params as swing): equilibrium = (H + L) ÷ 2; in_premium while equilibrium < close ≤ H, in_discount while L ≤ close < equilibrium; outside the leg both are 0.

Premium/discount is a structure detector: it marks price structure on the chart and counts against the plan's detector limit.

Settings

SettingDefaultRangeWhat it does
atr_period141 to 500ATR length (Wilder) for every buffer.
swing_k20.1 to 20Swing reversal in ATRs: a pivot is confirmed when a close moves this far back.
swing_min_pct0.10 to 10Smallest swing reversal, % of the close.

What it gives

OutputWhat it is
EquilibriumMiddle of the last swing leg: (swing high + swing low) ÷ 2.
In premiumTrue while the close is in the upper half of the last swing leg.
In discountTrue while the close is in the lower half of the last swing leg.

What it reads

It reads the whole candle (open, high, low, close and volume).

Warm-up

With its default settings, Premium/discount needs 241 closed candles before its first value. A backtest loads them before its start date, so the first trade can already use it.

Test it

Copy this sentence into the Algonney chat to backtest it:

Backtest a strategy on BTC that uses Premium/discount with its default settings