Stratégies & Codes

Dans cette rubrique dédiée à la "Stratégies et codes", nous avons l'intention de dévoiler un trésor d'informations pour tous les traders, qu'ils soient novices ou aguerris. L'univers du trading est vaste et complexe, mais avec les bons outils et les bonnes combinaisons, naviguer dans ce monde devient nettement plus clair et efficace.
Nous sommes ravis d'annoncer que nous allons partager plusieurs combinaisons d'indicateurs intégrées dans un unique script Pine. Ces combinaisons ont été conçues pour fournir des analyses multidimensionnelles, augmentant ainsi vos chances de décrypter les mouvements du marché avec une précision accrue.  Et sans plus tarder, voici le premier de cette longue liste de combinaisons d'indicateurs. Attachez vos ceintures, chers traders, car ce voyage à travers les techniques et stratégies de trading ne fait que commencer !
Bon trading ! 📈

Présentation de l'Indicateur Technique Combiné : Pivot Point SuperTrend + EMA (25 & 50) + Ichimoku Cloud en Pine Script
L'analyse technique, au cœur du trading moderne, repose sur l'idée que les mouvements passés des prix peuvent aider à prédire les mouvements futurs. Plusieurs outils et indicateurs sont utilisés à cette fin. Parmi les nombreux indicateurs disponibles, certains se sont démarqués par leur efficacité et leur popularité. Dans ce contexte, nous avons combiné certains des indicateurs les plus efficaces en un seul script Pine Script: le Pivot Point SuperTrend, deux EMA (25 & 50) et le nuage Ichimoku (Ichimoku Cloud).

1. Pivot Point SuperTrend :
Le SuperTrend est basé sur le Pivot Point. Il donne des signaux d'achat et de vente en fonction de la direction du marché. C'est un excellent outil pour identifier les tendances et leurs inversions.

2. EMA (25 & 50) :
Les Moyennes Mobiles Exponentielles (EMA) sont largement utilisées en analyse technique pour lisser les fluctuations de prix et mettre en évidence les tendances à long terme. Dans ce script, nous utilisons deux EMA : une à court terme (25 jours) et une à moyen terme (50 jours). Le croisement de ces deux EMA peut souvent être un signal d'achat ou de vente.

3. Nuage Ichimoku (Ichimoku Cloud) :
L'Ichimoku Kinko Hyo, souvent appelé nuage Ichimoku, est un indicateur qui donne la direction du marché et vous indique lors des swings du nuage les zones de range . Il est composé de la Senkou Span A, Senkou Span B qui fournissent diverses informations sur les niveaux de support et de résistance, ainsi que sur la dynamique du marché.

Backtesting et Personnalisation :
Il est impératif de backtester différentes stratégies basées sur cette combinaison d'indicateurs avant de les appliquer en trading réel. Les signaux d'achat ou de vente générés par cette combinaison doivent être évalués sur des données historiques pour déterminer leur fiabilité et leur pertinence. De plus, selon votre style de trading et vos préférences, vous pouvez moduler et changer les paramètres des indicateurs, ainsi que leurs couleurs, pour mieux adapter l'outil à vos besoins.

Code Pine Script (simplifié) :code pine à copier et à coller dans l'éditeur pine de votre logiciel Trading View.

Code Pine Script (simplifié) :

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TRADER'S JOURNAL

//@version=5
indicator('Pivot Point SuperTrend ema25/50 cloud ', overlay=true)
prd = input.int(defval=2, title='Pivot Point Period', minval=1, maxval=50)
Factor = input.float(defval=3, title='ATR Factor', minval=1, step=0.1)
Pd = input.int(defval=10, title='ATR Period', minval=1)
showpivot = input(defval=false, title='Show Pivot Points')
showlabel = input(defval=true, title='Show Buy/Sell Labels')
showcl = input(defval=false, title='Show PP Center Line')
showsr = input(defval=false, title='Show Support/Resistance')

// get Pivot High/Low
float ph = ta.pivothigh(prd, prd)
float pl = ta.pivotlow(prd, prd)

// drawl Pivot Points if "showpivot" is enabled
plotshape(ph and showpivot, text='H', style=shape.labeldown, color=na, textcolor=color.new(color.red, 0), location=location.abovebar, offset=-prd, transp=0)
plotshape(pl and showpivot, text='L', style=shape.labeldown, color=na, textcolor=color.new(#000fe6, 0), location=location.belowbar, offset=-prd, transp=0)

// calculate the Center line using pivot points
var float center = na
float lastpp = ph ? ph : pl ? pl : na
if lastpp
if na(center)
center := lastpp
center
else
//weighted calculation
center := (center * 2 + lastpp) / 3
center

// upper/lower bands calculation
Up = center - Factor * ta.atr(Pd)
Dn = center + Factor * ta.atr(Pd)

// get the trend
float TUp = na
float TDown = na
Trend = 0
TUp := close[1] > TUp[1] ? math.max(Up, TUp[1]) : Up
TDown := close[1] < TDown[1] ? math.min(Dn, TDown[1]) : Dn
Trend := close > TDown[1] ? 1 : close < TUp[1] ? -1 : nz(Trend[1], 1)
Trailingsl = Trend == 1 ? TUp : TDown

// plot the trend
linecolor = Trend == 1 and nz(Trend[1]) == 1 ? color.rgb(0, 8, 230) : Trend == -1 and nz(Trend[1]) == -1 ? color.red : na
plot(Trailingsl, color=linecolor, linewidth=2, title='PP SuperTrend')

plot(showcl ? center : na, color=showcl ? center < hl2 ? #113cff : color.red : na)

// check and plot the signals
bsignal = Trend == 1 and Trend[1] == -1
ssignal = Trend == -1 and Trend[1] == 1
plotshape(bsignal and showlabel ? Trailingsl : na, title='Buy', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(#002ae6, 0), textcolor=color.new(#fdfdfd, 0))
plotshape(ssignal and showlabel ? Trailingsl : na, title='Sell', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 0), textcolor=color.new(color.white, 0))

//get S/R levels using Pivot Points
float resistance = na
float support = na
support := pl ? pl : support[1]
resistance := ph ? ph : resistance[1]

// if enabled then show S/R levels
plot(showsr and support ? support : na, color=showsr and support ? #003de6 : na, style=plot.style_circles, offset=-prd)
plot(showsr and resistance ? resistance : na, color=showsr and resistance ? color.red : na, style=plot.style_circles, offset=-prd)

// alerts
alertcondition(Trend == 1 and Trend[1] == -1, title='Buy Signal', message='Buy Signal')
alertcondition(Trend == -1 and Trend[1] == 1, title='Sell Signal', message='Sell Signal')
alertcondition(ta.change(Trend), title='Trend Changed', message='Trend Changed')
/////////////////////////////////////////////////////////EMA 25 COLORED ALERT///////////////////////////////////////////////////////////////////
ema1Length = input.int(title='EMA Length', defval=25, minval=0)
ema1rsiSource = input(close, title='EMA+RSI Source')
cond1Source = input(high, title='Long+Short Condition Source')
ema1Val = ta.ema(ema1rsiSource, ema1Length)
rsiLength = input.int(title='RSI Length', defval=21, minval=1)
rsiVal = ta.rsi(ema1rsiSource, rsiLength)

// Conditions
shortCond1 = ta.crossover(ema1Val, cond1Source)
longCond1 = ta.crossunder(ema1Val, cond1Source)

// Plots Colors
colors = ema1rsiSource > ema1Val and rsiVal > 9 ? color.rgb(5, 22, 255) : color.rgb(255, 0, 0)
ema1ColorSource = input(close, title='Line Color Source')
ema1BSource = input(close, title='Line Color B Source')

// Plots
plot(ema1Val, color=ema1ColorSource[1] > ema1Val and ema1BSource > ema1Val ? color.rgb(13, 0, 255) : color.rgb(255, 0, 0), linewidth=3)
plotcandle(open, high, low, close, color=colors)
plotshape(series=shortCond1, location=location.abovebar, style=shape.labeldown, color=color.new(#ff0000, 0), size=size.tiny, text='S', textcolor=color.new(color.white, 0))
plotshape(series=longCond1, location=location.belowbar, style=shape.labelup, color=color.new(#3700ff, 0), size=size.tiny, text='L', textcolor=color.new(color.white, 0))

// Alert Conditions
alertcondition(longCond1, title='Long', message='Go Long')
alertcondition(shortCond1, title='Short', message='Go Short')

///////////////////////////////////////////////////////////////EMA 50///////////////////////////////////////////////


ema3Length = input.int(title='EMA Length', defval=50, minval=0)
ema3rsiSource = input(close, title='EMA+RSI Source')
cond3Source = input(high, title='Long+Short Condition Source')
ema3Val = ta.ema(ema3rsiSource, ema3Length)

rsi1Val = ta.rsi(ema3rsiSource, rsiLength)

// Conditions
shortCond3 = ta.crossover(ema3Val, cond3Source)
longCond3 = ta.crossunder(ema3Val, cond3Source)

// Plots Colors
colors3 = ema3rsiSource > ema3Val and rsi1Val > 9 ? color.rgb(42, 7, 107) : color.rgb(255, 0, 0)
ema3ColorSource = input(close, title='Line Color Source')
ema3BSource = input(close, title='Line Color B Source')

// Plots
plot(ema3Val, color=ema3ColorSource[1] > ema3Val and ema3BSource > ema3Val ? color.rgb(46, 3, 146) : color.rgb(255, 0, 0), linewidth=3)
plotcandle(open, high, low, close, color=colors)
plotshape(series=shortCond3, location=location.abovebar, style=shape.labeldown, color=color.new(#ff0000, 0), size=size.tiny, text='S', textcolor=color.new(color.white, 0))
plotshape(series=longCond3, location=location.belowbar, style=shape.labelup, color=color.rgb(42, 2, 107), size=size.tiny, text='L', textcolor=color.new(color.white, 0))

// Alert Conditions
alertcondition(longCond3, title='Long', message='Go Long')
alertcondition(shortCond3, title='Short', message='Go Short')

///////////////////////////////////////////////////////CLOUD ICHIMOKU//////////////////////////////////////////////////////////////////


conversionPeriods = input.int(9, minval=1, title='Conversion Line Periods')
basePeriods = input.int(26, minval=1, title='Base Line Periods')
laggingSpan2Periods = input.int(52, minval=1, title='Lagging Span 2 Periods')
displacement = input.int(26, minval=1, title='Displacement')

donchian(len) =>
math.avg(ta.lowest(len), ta.highest(len))

conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = math.avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)

//plot(conversionLine, color=#0496ff, title="Conversion Line")
//plot(baseLine, color=#991515, title="Base Line")
//plot(close, offset = -displacement, color=#459915, title="Lagging Span")

p1 = plot(leadLine1, offset=displacement, color=color.rgb(175, 197, 238, 50), title='Lead 1')
p2 = plot(leadLine2, offset=displacement, color=#f3c5c5a3, title='Lead 2')
fill(p1, p2, color=leadLine1 > leadLine2 ? color.rgb(215, 225, 247, 33) : color.rgb(247, 210, 210, 53), transp=90)