OPEN-SOURCE SCRIPT

Daily Trend with ATR Strategy

//version=5
strategy("Daily Trend with ATR Strategy", overlay=true)

// تنظیمات
atrLength = input.int(22, title="ATR Length (Daily)")
atrMultiplier = input.float(3.0, title="ATR Multiplier")
atrH1Length = input.int(24, title="ATR Length (Hourly)")
tolerance = input.float(0.05, title="Tolerance")

// محاسبه ATR روزانه
dailyATR = request.security(syminfo.tickerid, "D", ta.atr(atrLength))

// محاسبه معیار حرکت
moveCriterion = (dailyATR * atrMultiplier) * 0.66

// تعیین روند دیلی
dailyTrendUp = request.security(syminfo.tickerid, "D", close[0] - close[2] >= moveCriterion and ta.change(close[1]) == ta.change(close[2]) and ta.change(close[1]) == ta.change(close[0]))
dailyTrendDown = request.security(syminfo.tickerid, "D", close[0] - close[2] <= -moveCriterion and ta.change(close[1]) == ta.change(close[2]) and ta.change(close[1]) == ta.change(close[0]))

// تعیین ناحیه حمایت و مقاومت
resistanceZone = moveCriterion * 0.5
supportZone = moveCriterion * 0.66

// محاسبه ATR ساعتی
hourlyATR = ta.atr(atrH1Length)

// تعیین برخوردها
cond1 = ta.crossover(close, resistanceZone)
cond2 = ta.crossover(close, supportZone)
cond3 = ta.crossunder(close, supportZone)
cond4 = ta.crossunder(close, resistanceZone)

// شناسایی برخوردها با ناحیه
zoneTouches = (cond1 or cond2 or cond3 or cond4)

// بررسی نسبت ATR برخوردها
validTouch = close - open > hourlyATR * (1 + tolerance) or close - open < -hourlyATR * (1 - tolerance)

// شرایط ورود به معامله
longCondition = dailyTrendUp and zoneTouches and validTouch
shortCondition = dailyTrendDown and zoneTouches and validTouch

// ورود به معامله
if (longCondition)
strategy.entry("Buy", strategy.long)
if (shortCondition)
strategy.entry("Sell", strategy.short)

// تنظیم استاپ لاس و تیک پرافیت
stopLoss = hourlyATR
takeProfit = stopLoss * 2

strategy.exit("Exit Buy", from_entry="Buy", loss=stopLoss, profit=takeProfit)
strategy.exit("Exit Sell", from_entry="Sell", loss=stopLoss, profit=takeProfit)
Candlestick analysisChart patternsCycles

Script open-source

In pieno spirito TradingView, l'autore di questo script lo ha pubblicato open-source, in modo che i trader possano comprenderlo e verificarlo. Un saluto all'autore! È possibile utilizzarlo gratuitamente, ma il riutilizzo di questo codice in una pubblicazione è regolato dal nostro Regolamento. Per aggiungerlo al grafico, mettilo tra i preferiti.

Vuoi usare questo script sui tuoi grafici?

Declinazione di responsabilità