
La stratégie est un système de trading intégré combinant plusieurs outils d’analyse technique, qui utilise principalement la ligne de bi-parité (EMA cyclique 20⁄50), les niveaux de rétroaction de Fibonacci et les niveaux de résistance de soutien des axes pour déterminer les signaux de négociation. La stratégie utilise une méthode de suivi de la tendance combinée à la rétroaction des prix pour améliorer la précision des transactions grâce à la confirmation multiple.
La logique fondamentale de la stratégie repose sur les éléments clés suivants :
La stratégie a construit un système de négociation relativement complet en intégrant plusieurs outils d’analyse technique classiques. Bien qu’il y ait un certain retard, la fiabilité des transactions a été améliorée grâce à un mécanisme de confirmation multiple. Grâce à la mise en œuvre des recommandations d’optimisation, la stratégie devrait obtenir de meilleures performances dans les transactions sur le marché réel.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-09 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Forex Strategy with EMA, Pivot, Fibonacci and Signals", overlay=true)
// Input for EMAs and Pivot Points
emaShortPeriod = input.int(20, title="Short EMA Period", minval=1)
emaLongPeriod = input.int(50, title="Long EMA Period", minval=1)
fibRetraceLevel1 = input.float(0.236, title="Fibonacci 23.6% Level")
fibRetraceLevel2 = input.float(0.382, title="Fibonacci 38.2% Level")
fibRetraceLevel3 = input.float(0.5, title="Fibonacci 50% Level")
fibRetraceLevel4 = input.float(0.618, title="Fibonacci 61.8% Level")
// Function to calculate Pivot Points and Levels
pivot(high, low, close) =>
pp = (high + low + close) / 3
r1 = 2 * pp - low
s1 = 2 * pp - high
r2 = pp + (high - low)
s2 = pp - (high - low)
[pp, r1, s1, r2, s2]
// Calculate Pivot Points
[pp, r1, s1, r2, s2] = pivot(high, low, close)
// Calculate 20 EMA and 50 EMA
emaShort = ta.ema(close, emaShortPeriod)
emaLong = ta.ema(close, emaLongPeriod)
// Plot the EMAs
plot(emaShort, color=color.blue, title="20 EMA", linewidth=2)
plot(emaLong, color=color.red, title="50 EMA", linewidth=2)
// Fibonacci Levels (manually drawn between the most recent high and low)
var float fibHigh = na
var float fibLow = na
if (not na(high[1]) and high > high[1]) // Check if new high is formed
fibHigh := high
if (not na(low[1]) and low < low[1]) // Check if new low is formed
fibLow := low
fib23_6 = fibLow + (fibHigh - fibLow) * fibRetraceLevel1
fib38_2 = fibLow + (fibHigh - fibLow) * fibRetraceLevel2
fib50 = fibLow + (fibHigh - fibLow) * fibRetraceLevel3
fib61_8 = fibLow + (fibHigh - fibLow) * fibRetraceLevel4
plot(fib23_6, color=color.green, linewidth=1, title="Fibonacci 23.6%")
plot(fib38_2, color=color.green, linewidth=1, title="Fibonacci 38.2%")
plot(fib50, color=color.green, linewidth=1, title="Fibonacci 50%")
plot(fib61_8, color=color.green, linewidth=1, title="Fibonacci 61.8%")
// Entry conditions (Crossovers)
longCondition = ta.crossover(emaShort, emaLong) and close > fib23_6 and close > s1
shortCondition = ta.crossunder(emaShort, emaLong) and close < fib23_6 and close < r1
// Exit conditions (Stop Loss and Take Profit)
stopLossPips = 30 * syminfo.mintick // 30 pips Stop Loss
takeProfitPips = 60 * syminfo.mintick // 60 pips Take Profit
if (longCondition)
strategy.entry("Buy", strategy.long, stop=stopLossPips, limit=takeProfitPips)
if (shortCondition)
strategy.entry("Sell", strategy.short, stop=stopLossPips, limit=takeProfitPips)
// Plot Pivot Points for visual reference
plot(pp, color=color.yellow, linewidth=2, title="Pivot Point")
plot(r1, color=color.purple, linewidth=1, title="Resistance 1")
plot(s1, color=color.purple, linewidth=1, title="Support 1")
plot(r2, color=color.purple, linewidth=1, title="Resistance 2")
plot(s2, color=color.purple, linewidth=1, title="Support 2")
// Adding Buy and Sell Signals
plotshape(longCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY", textcolor=color.white, size=size.small)
plotshape(shortCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL", textcolor=color.white, size=size.small)