PivotHigh — Pivot High
תוכן זה אינו זמין עדיין בשפה שלך.
A local high with equal numbers of lower highs on each side. It arrives late by construction: the confirmation needs the bars to the right, so the flag fires half a window after the pivot bar itself. That is the honest version — it does not repaint.
Signature
PivotHigh(window, on=<source>)| Argument | Type | Required | Notes |
|---|---|---|---|
window |
int Param or literal | Yes | Total bars in the window; use an odd number. Default 5 (two bars either side), bounds 3–101. |
on= |
symbol | No | Source symbol. Defaults to the trade symbol. Reads the high. |
Formula
The centre bar of the window is strictly higher than every other bar in it.
Warmup
window bars; 0 until then.
Reading the value
ph.valueph > 0The flag refers to the bar (window − 1) / 2 bars ago, not the current bar.
Example
class PivotResistance(Strategy): """Enter on a close above the most recent confirmed pivot high.""" trade = Symbol() sizing = FixedCapital()
def execute(self): ph = PivotHigh(5, on=self.trade) dh = DonchianHighTrue(20, on=self.trade) if ph.value > 0 and self.trade.close >= dh.value_at(1) and self.trade.is_flat: self.buy(self.trade, reason="Break above a confirmed pivot") if self.trade.close < dh.value * 0.95 and self.trade.is_long: self.sell(self.trade, self.trade.position, reason="Stop")Notes
- The lag is the whole caveat. With
window = 5the signal is two bars late. A version without the lag would have to look at future bars, which is what makes most published pivot indicators repaint. - Uses strict inequality, so a tie anywhere in the window suppresses the pivot.
- Proven by an assert-via-trade run on SPY daily (matched a strategy-side five-bar reference exactly on every bar; zero alarm trades).