Pine Script (TradingView)
هذا مثال استراتيجية Pine Script على TradingView لمفهوم هذه الصفحة. الصقه في Pine Editor داخل TradingView، اضفه الى الرسم البياني، ثم شغله في Strategy Tester.
//@version=6
strategy("Price Action Strategy", overlay=true)
// Detects pin bars and engulfing candles at key levels
atrLen = input.int(14, "ATR Length")
lookback = input.int(20, "Swing Lookback")
atr = ta.atr(atrLen)
swingHigh = ta.highest(high, lookback)
swingLow = ta.lowest(low, lookback)
// Bullish pin bar: long lower wick, close near high, forms at/near swing low
lowerWick = open - low
upperWick = high - close
bodySize = math.abs(close - open)
bullishPin = lowerWick > 2 * bodySize and lowerWick > upperWick and low <= swingLow * 1.002
// Bearish engulfing at swing high
bearEngulf = close < open and close < open[1] and open > close[1] and high >= swingHigh * 0.998
if bullishPin
strategy.entry("PABuy", strategy.long, stop=low - atr * 0.5)
if bearEngulf
strategy.close("PABuy")
plotshape(bullishPin, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, title="Pin Bar")
plotshape(bearEngulf, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, title="Bearish Engulf")