
Cette stratégie est un système de trading complet qui combine plusieurs indicateurs techniques, notamment Ichimoku, RSI, MACD, divergence HTF, etc. Croisement de moyenne mobile exponentielle (EMA) et autres méthodes d’analyse multidimensionnelle. La stratégie améliore la précision des transactions grâce à de multiples confirmations de signaux, tout en utilisant les informations de marché de différentes périodes pour capturer des opportunités de trading plus fiables.
Le principe de base de la stratégie est de confirmer les signaux de trading grâce à une analyse complète d’indicateurs techniques multicouches. Tout d’abord, utilisez le composant graphique en nuage de l’Ichimoku Kinko Hyo pour déterminer la tendance générale du marché, combinez l’indicateur RSI pour déterminer l’état de surachat ou de survente du marché, utilisez l’indicateur MACD pour identifier les changements d’énergie cinétique de la tendance et capturez Tendances potentielles à travers la divergence du RSI et du MACD dans la période de temps élevée. Signal de retournement. En outre, la stratégie introduit également la confirmation croisée de l’EMA50 et de l’EMA100, ainsi que de l’EMA200 comme filtre de tendance principal, construisant ainsi un système de confirmation de transaction à plusieurs niveaux.
Cette stratégie construit un système de trading relativement complet grâce à la coopération coordonnée de plusieurs indicateurs techniques. L’avantage de la stratégie réside dans son mécanisme de confirmation du signal multidimensionnel, mais elle est également confrontée à des défis en matière d’optimisation des paramètres et d’adaptabilité du marché. Grâce à l’orientation d’optimisation proposée, la stratégie devrait encore améliorer ses performances dans différents environnements de marché tout en maintenant sa robustesse.
/*backtest
start: 2024-01-17 00:00:00
end: 2025-01-16 00:00:00
period: 3h
basePeriod: 3h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}]
*/
//@version=6
strategy("Ichimoku + RSI + MACD + HTF Divergence + EMA Cross Strategy", overlay=true)
// تنظیمات تایمفریم بالاتر
htf_timeframe = input.timeframe("D", title="تایمفریم بالاتر")
// تنظیمات پارامترهای ایچیموکو
tenkan_period = input(9, title="Tenkan Sen Period")
kijun_period = input(26, title="Kijun Sen Period")
senkou_span_b_period = input(52, title="Senkou Span B Period")
displacement = input(26, title="Displacement")
// محاسبه خطوط ایچیموکو
tenkan_sen = (ta.highest(high, tenkan_period) + ta.lowest(low, tenkan_period)) / 2
kijun_sen = (ta.highest(high, kijun_period) + ta.lowest(low, kijun_period)) / 2
senkou_span_a = (tenkan_sen + kijun_sen) / 2
senkou_span_b = (ta.highest(high, senkou_span_b_period) + ta.lowest(low, senkou_span_b_period)) / 2
chikou_span = close // قیمت بسته شدن فعلی
// رسم خطوط ایچیموکو
plot(tenkan_sen, color=color.blue, title="Tenkan Sen")
plot(kijun_sen, color=color.red, title="Kijun Sen")
plot(senkou_span_a, offset=displacement, color=color.green, title="Senkou Span A")
plot(senkou_span_b, offset=displacement, color=color.orange, title="Senkou Span B")
plot(chikou_span, offset=-displacement, color=color.purple, title="Chikou Span")
// رنگآمیزی ابر ایچیموکو
fill(plot(senkou_span_a, offset=displacement, color=color.green, title="Senkou Span A"), plot(senkou_span_b, offset=displacement, color=color.orange, title="Senkou Span B"), color=senkou_span_a > senkou_span_b ? color.new(color.green, 90) : color.new(color.red, 90), title="Cloud")
// تنظیمات RSI
rsi_length = input(14, title="RSI Length")
rsi_overbought = input(70, title="RSI Overbought Level")
rsi_oversold = input(30, title="RSI Oversold Level")
// محاسبه RSI
rsi_value = ta.rsi(close, rsi_length)
// تنظیمات MACD
fast_length = input(12, title="MACD Fast Length")
slow_length = input(26, title="MACD Slow Length")
signal_smoothing = input(9, title="MACD Signal Smoothing")
// محاسبه MACD
[macd_line, signal_line, hist_line] = ta.macd(close, fast_length, slow_length, signal_smoothing)
// شناسایی واگراییها در تایمفریم بالاتر
f_find_divergence(src, lower, upper) =>
var int divergence = na // تعریف نوع متغیر بهصورت صریح
if (src >= upper and src[1] < upper)
divergence := 1 // واگرایی نزولی
else if (src <= lower and src[1] > lower)
divergence := -1 // واگرایی صعودی
divergence
// محاسبه RSI و MACD در تایمفریم بالاتر
htf_rsi_value = request.security(syminfo.tickerid, htf_timeframe, rsi_value)
htf_macd_line = request.security(syminfo.tickerid, htf_timeframe, macd_line)
// شناسایی واگراییها در تایمفریم بالاتر
htf_rsi_divergence = f_find_divergence(htf_rsi_value, rsi_oversold, rsi_overbought)
htf_macd_divergence = f_find_divergence(htf_macd_line, 0, 0)
// فیلتر روند با EMA 200
ema_200 = ta.ema(close, 200)
// اضافه کردن EMA 50 و 100
ema_50 = ta.ema(close, 50)
ema_100 = ta.ema(close, 100)
// کراسهای EMA
ema_cross_up = ta.crossover(ema_50, ema_100) // کراس صعودی EMA 50 و 100
ema_cross_down = ta.crossunder(ema_50, ema_100) // کراس نزولی EMA 50 و 100
// شرایط ورود و خروج
long_condition = (close > senkou_span_a and close > senkou_span_b) and // قیمت بالای ابر
(rsi_value > 50) and // RSI بالای 50
(macd_line > signal_line) and // MACD خط سیگنال را قطع کرده
(htf_rsi_divergence == -1 or htf_macd_divergence == -1) and // واگرایی صعودی در تایمفریم بالاتر
(close > ema_200) and // قیمت بالای EMA 200
(ema_cross_up) // کراس صعودی EMA 50 و 100
short_condition = (close < senkou_span_a and close < senkou_span_b) and // قیمت زیر ابر
(rsi_value < 50) and // RSI زیر 50
(macd_line < signal_line) and // MACD خط سیگنال را قطع کرده
(htf_rsi_divergence == 1 or htf_macd_divergence == 1) and // واگرایی نزولی در تایمفریم بالاتر
(close < ema_200) and // قیمت زیر EMA 200
(ema_cross_down) // کراس نزولی EMA 50 و 100
// نمایش نقاط ورود در چارت
plotshape(series=long_condition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY", size=size.small)
plotshape(series=short_condition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL", size=size.small)
// اجرای استراتژی
if (long_condition)
strategy.entry("Long", strategy.long)
if (short_condition)
strategy.entry("Short", strategy.short)