Files
QuanTAlib/lib/reversals/ttm_scalper/ttmscalper.pine
T
Miha Kralj 24e86d762a Add documentation links for various volatility indicators and channels
- Updated BBWN, BBWP, CCV, CV, CVI, EWMA, GKV, HLV, HV, Jvolty, JVOLTYN, MASSI, NATR, RSV, RV, RVI, TR, UI, VOV, VR, YZV indicators with documentation links.
- Added documentation links for Aberration, Acceleration Bands, Andrews' Pitchfork, Adaptive Price Zone, ATR Bands, Bollinger Bands, Center of Gravity, Donchian Channels, Decay Min-Max Channel, Detrended Synthetic Price, EACP, EBSW, HOMOD, Jurik Volatility Bands, Keltner Channel, MA Envelope, Min-Max Channel, Price Channel, Regression Channels, Standard Deviation Channel, Stoller Average Range Channel, Super Trend Bands, Ultimate Bands, Ultimate Channel, VWAP Bands, and VWAP with Standard Deviation Bands.
2026-02-18 11:55:48 -08:00

41 lines
1.8 KiB
Plaintext

// The MIT License (MIT)
// © mihakralj
//@version=6
indicator("TTM Scalper Alert", "TTM_SCALPER", overlay=true)
//@function Detects 3-bar pivot patterns for scalping entry signals
//@param use_closes Use close prices instead of high/low for pivot detection
//@returns [pivot_high_price, pivot_low_price] Pivot values (na if no pivot)
ttmscalper(bool use_closes = false) =>
bool is_pivot_high = false
bool is_pivot_low = false
if bar_index >= 2
if use_closes
is_pivot_high := close[1] > close[2] and close[1] > close[0]
is_pivot_low := close[1] < close[2] and close[1] < close[0]
else
is_pivot_high := high[1] > high[2] and high[1] > high[0]
is_pivot_low := low[1] < low[2] and low[1] < low[0]
float pivot_high_price = is_pivot_high ? (use_closes ? close[1] : high[1]) : na
float pivot_low_price = is_pivot_low ? (use_closes ? close[1] : low[1]) : na
[pivot_high_price, pivot_low_price]
// ---------- Main loop ----------
// Inputs
i_use_closes = input.bool(false, "Use Closes", tooltip="Use close prices instead of high/low for pivot detection")
i_show_high = input.bool(true, "Show Pivot Highs", tooltip="Display bearish pivot markers")
i_show_low = input.bool(true, "Show Pivot Lows", tooltip="Display bullish pivot markers")
i_color_high = input.color(color.red, "Pivot High Color")
i_color_low = input.color(color.green, "Pivot Low Color")
// Calculation
[pivot_high, pivot_low] = ttmscalper(i_use_closes)
// Plot pivot markers
plotshape(i_show_high and not na(pivot_high) ? pivot_high : na, "Pivot High", style=shape.triangledown, location=location.absolute, color=i_color_high, size=size.small, offset=-1)
plotshape(i_show_low and not na(pivot_low) ? pivot_low : na, "Pivot Low", style=shape.triangleup, location=location.absolute, color=i_color_low, size=size.small, offset=-1)