PROTECTED SOURCE SCRIPT

Darvas Box Short Squeeze Strategy

18
//version=5
strategy("Darvas Box Short Squeeze Strategy", overlay=true)

// Inputs for the Darvas Box
darvasLength = input(20, title="Darvas Box Length")
riskRewardRatio = input(3, title="Risk to Reward Ratio")
riskAmount = input(100, title="Risk Amount ($)")

// Calculate the highest high and lowest low for Darvas Box
var float highLevel = na
var float lowLevel = na
var float darvasHigh = na
var float darvasLow = na
var bool inBox = false

if (high >= ta.highest(high, darvasLength)[1])
highLevel := high
inBox := true

if (low <= ta.lowest(low, darvasLength)[1])
lowLevel := low
inBox := false

if (inBox)
darvasHigh := highLevel
darvasLow := lowLevel

// Short Squeeze Condition: Significant upward movement with high volume
shortSqueezeCondition = (close > darvasHigh and volume > ta.sma(volume, 20))

// Entry logic for shorting on resistance
if (shortSqueezeCondition and close >= darvasHigh)
strategy.entry("Short", strategy.short)

// Long entry on major support (if price breaches below darvasLow)
if (close <= darvasLow)
strategy.entry("Long", strategy.long)

// Risk and Reward Levels
var float longTakeProfit = na
var float longStopLoss = na
var float shortTakeProfit = na
var float shortStopLoss = na

if (strategy.position_size > 0) // For Long position
longTakeProfit := strategy.position_avg_price * (1 + riskRewardRatio / 1)
longStopLoss := strategy.position_avg_price - (riskAmount / strategy.position_size)

if (strategy.position_size < 0) // For Short position
shortTakeProfit := strategy.position_avg_price * (1 - riskRewardRatio / 1)
shortStopLoss := strategy.position_avg_price + (riskAmount / (strategy.position_size))

// Exit logic
if (strategy.position_size > 0)
strategy.exit("Take Profit Long", from_entry="Long", limit=longTakeProfit, stop=longStopLoss)

if (strategy.position_size < 0)
strategy.exit("Take Profit Short", from_entry="Short", limit=shortTakeProfit, stop=shortStopLoss)

// Plotting levels for visualization
plot(longTakeProfit, color=color.green, style=plot.style_cross, title="Long Take Profit")
plot(longStopLoss, color=color.red, style=plot.style_cross, title="Long Stop Loss")
plot(shortTakeProfit, color=color.green, style=plot.style_cross, title="Short Take Profit")
plot(shortStopLoss, color=color.red, style=plot.style_cross, title="Short Stop Loss")

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.