OPEN-SOURCE SCRIPT

Scalping Strategy - Liquidity, Volatility & Candlestick2

//version=5
strategy("Scalping Strategy - Liquidity, Volatility & Candlestick Patterns", overlay=true)

// --- Inputs ---
lengthATR = input.int(14, title="ATR Period")
multiplierATR = input.float(1.5, title="ATR Multiplier for Volatility")
lengthEMA = input.int(20, title="EMA Period")
lengthVolume = input.int(20, title="Volume Moving Average Period")
momentumThreshold = input.float(2.0, title="Momentum Threshold (News Catalysts)")

// --- Indicators ---
atr = ta.atr(lengthATR) // ATR for volatility
ema = ta.ema(close, lengthEMA) // EMA for trend
volMA = ta.sma(volume, lengthVolume) // Volume moving average

// --- Candlestick Pattern Detection (Manually Defined) ---
// Bullish Engulfing: Current close > current open and previous close < previous open and current close > previous open
bullishEngulfing = close > open and close[1] < open[1] and close > open[1] and open < close[1]

// Bearish Engulfing: Current close < current open and previous close > previous open and current close < previous open
bearishEngulfing = close < open and close[1] > open[1] and close < open[1] and open > close[1]

// Doji Pattern: Current close is within a small range of the open (doji condition)
doji = math.abs(close - open) < (high - low) * 0.1

// --- Trend Identification ---
uptrend = close > ema // Price above EMA = uptrend
downtrend = close < ema // Price below EMA = downtrend

// --- Volatility & Liquidity Analysis ---
highVolatility = atr * multiplierATR // Volatility condition
highVolume = volume > volMA * 1.5 // High volume for liquidity

// --- Triangle Pattern & Trendline Breakout (Simplified) ---
// Calculate recent highest and lowest closes for breakout detection
highestHigh = ta.highest(high, 3) // Highest high of the last 3 bars
lowestLow = ta.lowest(low, 3) // Lowest low of the last 3 bars

// Detect breakouts
triangleBreakoutUp = close > highestHigh // Breakout above the highest high
triangleBreakoutDown = close < lowestLow // Breakdown below the lowest low

// --- Momentum Catalysts (Simulated) ---
momentumBullish = highVolume and bullishEngulfing
momentumBearish = highVolume and bearishEngulfing

// --- Buy (Long Position) Conditions ---
longCondition = (uptrend and bullishEngulfing and highVolume and close > ema)
longMomentumCondition = (momentumBullish and highVolume and close > ema)

// --- Sell (Short Position) Conditions ---
shortCondition = (downtrend and bearishEngulfing and highVolume and close < ema)
shortMomentumCondition = (momentumBearish and highVolume and close < ema)

// --- Exit Conditions (Close Long and Short Positions) ---
sellLongCondition = (downtrend and bearishEngulfing and close < ema) // Exit long position
buyShortCondition = (uptrend and bullishEngulfing and close > ema) // Exit short position

// --- Plot Buy and Sell Signals ---
plotshape(series=longCondition, title="Long Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=shortCondition, title="Short Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")

// --- Strategy Execution (Enter and Exit Trades) ---

// Enter Long Position
if longCondition
strategy.entry("Long", strategy.long)

// Enter Short Position
if shortCondition
strategy.entry("Short", strategy.short)

// Close positions at market price when exit conditions are met
if sellLongCondition
strategy.close("Long")

if buyShortCondition
strategy.close("Short")

// --- Plot Indicators for Reference ---
plot(ema, title="EMA", color=color.orange, linewidth=2)
plot(atr, title="ATR", color=color.blue, linewidth=2)
plot(volMA, title="Volume MA", color=color.purple, linewidth=2)
arshBill Williams IndicatorsCandlestick analysisChart patterns

Açık kaynak kodlu komut dosyası

Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının yazarı komut dosyasını açık kaynak olarak yayınlamıştır, böylece yatırımcılar betiği anlayabilir ve doğrulayabilir. Yazar çok yaşa! Ücretsiz olarak kullanabilirsiniz, ancak bu kodun yayında yeniden kullanımı Ev kurallarına tabidir. Bir grafikte kullanmak için favorilere ekleyebilirsiniz.

Bu komut dosyasını bir grafikte kullanmak ister misiniz?

Feragatname