Traduction Code pine tradingwiew
Forums › ProRealTime forum Français › Support ProBuilder › Traduction Code pine tradingwiew
- This topic has 5 replies, 2 voices, and was last updated 1 day ago by larouedegann.
-
-
12/29/2024 at 1:05 AM #241867
bonjour,
est ce quelqu’un pourrait m’aider à traduire ce code pine tradinwiew
merci
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © AlgoAlpha//@version=5indicator(title="Momentum Bias Index [AlgoAlpha]", timeframe="", timeframe_gaps=false)source = input(close, title="Source")momentumLength = input.int(10, minval=1, title="Momentum Length")biasLength = input.int(5, minval=1, title="Bias Length")smoothLength = input.int(10, minval=1, title="Smooth Length")impulseBoundaryLength = input.int(30, minval=1, title="Impulse Boundary Length")stdDevMultiplier = input.float(3.0, minval=1, title="Standard Deviation Multiplier")smoothIndicator = input.bool(true, "Smooth Indicator")overlayMode = input.bool(false, "Overlay Mode")colorUp = input.color(#00ffbb, "Up Color")colorSecondaryUp = input.color(#008461, "Secondary Up Color")colorDown = input.color(#ff1100, "Down Color")colorSecondaryDown = input.color(#840900, "Secondary Down Color")momentum = source - source[momentumLength]stdDev = momentum / (ta.ema(high - low, momentumLength)) * 100momentumUp = math.max(stdDev, 0)momentumDown = math.min(stdDev, 0)momentumUpBias = smoothIndicator ? math.max(ta.hma(math.sum(momentumUp, biasLength), smoothLength), 0) : math.sum(momentumUp, biasLength)momentumDownBias = smoothIndicator ? math.max(ta.hma(-math.sum(momentumDown, biasLength), smoothLength), 0) : -math.sum(momentumDown, biasLength)averageBias = math.avg(momentumDownBias, momentumUpBias)chg1 = momentumUpBias*0.80chg2 = momentumUpBias*0.60chg3 = momentumUpBias*0.40chg4 = momentumUpBias*0.20chg1a = momentumDownBias*0.80chg2a = momentumDownBias*0.60chg3a = momentumDownBias*0.40chg4a = momentumDownBias*0.20boundary = ta.ema(averageBias, impulseBoundaryLength) + ta.stdev(averageBias, impulseBoundaryLength) * stdDevMultiplierbullishSignal = ta.crossunder(momentumDownBias, momentumDownBias[1]) and momentumDownBias > boundary and momentumDownBias > momentumUpBiasbearishSignal = ta.crossunder(momentumUpBias, momentumUpBias[1]) and momentumUpBias > boundary and momentumUpBias > momentumDownBiascandleColor = overlayMode ? (momentumUpBias > momentumDownBias ? colorUp : momentumUpBias < momentumDownBias ? colorDown : color.gray) : natransp = 20plot(momentumUpBias > momentumUpBias[1] ? momentumUpBias : na, color = momentumUpBias > momentumUpBias[1] ? colorUp : colorSecondaryUp, style = plot.style_columns, display = not overlayMode ? display.all : display.none)plot(momentumDownBias > momentumDownBias[1] ? momentumDownBias : na, color = momentumDownBias > momentumDownBias[1] ? colorDown : colorSecondaryDown, style = plot.style_columns, display = not overlayMode ? display.all : display.none)plot(momentumUpBias < momentumUpBias[1] ? momentumUpBias : na, color = color.new(colorSecondaryUp, transp+60), style = plot.style_columns, linewidth = 4, display = not overlayMode ? display.all : display.none)plot(momentumUpBias < momentumUpBias[1] ? chg1 : na, color = color.new(colorSecondaryUp, transp+55), style = plot.style_columns, linewidth = 4, display = not overlayMode ? display.all : display.none)plot(momentumUpBias < momentumUpBias[1] ? chg2 : na, color = color.new(colorSecondaryUp, transp+45), style = plot.style_columns, linewidth = 4, display = not overlayMode ? display.all : display.none)plot(momentumUpBias < momentumUpBias[1] ? chg3 : na, color = color.new(colorSecondaryUp, transp+30), style = plot.style_columns, linewidth = 4, display = not overlayMode ? display.all : display.none)plot(momentumUpBias < momentumUpBias[1] ? chg4 : na, color = color.new(colorSecondaryUp, transp+25), style = plot.style_columns, linewidth = 4, display = not overlayMode ? display.all : display.none)plot(momentumUpBias < momentumUpBias[1] ? momentumUpBias : na, color = color.new(colorUp, transp), style = plot.style_linebr, display = not overlayMode ? display.all : display.none)plot(momentumDownBias < momentumDownBias[1] ? momentumDownBias : na, color = color.new(colorSecondaryDown, transp+60), style = plot.style_columns, linewidth = 4, display = not overlayMode ? display.all : display.none)plot(momentumDownBias < momentumDownBias[1] ? chg1a : na, color = color.new(colorSecondaryDown, transp+55), style = plot.style_columns, linewidth = 4, display = not overlayMode ? display.all : display.none)plot(momentumDownBias < momentumDownBias[1] ? chg2a : na, color = color.new(colorSecondaryDown, transp+45), style = plot.style_columns, linewidth = 4, display = not overlayMode ? display.all : display.none)plot(momentumDownBias < momentumDownBias[1] ? chg3a : na, color = color.new(colorSecondaryDown, transp+30), style = plot.style_columns, linewidth = 4, display = not overlayMode ? display.all : display.none)plot(momentumDownBias < momentumDownBias[1] ? chg4a : na, color = color.new(colorSecondaryDown, transp+25), style = plot.style_columns, linewidth = 4, display = not overlayMode ? display.all : display.none)plot(momentumDownBias < momentumDownBias[1] ? momentumDownBias : na, color = color.new(colorDown, transp), style = plot.style_linebr, display = not overlayMode ? display.all : display.none)plot(boundary, style = plot.style_circles, color = color.gray, display = not overlayMode ? display.all : display.none)plotshape(bullishSignal ? momentumDownBias * 1.2 : na, title = "Bullish TP Signal", color = color.new(colorUp, 30), textcolor = color.rgb(255, 255, 255), text = "TP", style = shape.labelup, location = location.belowbar, size = size.tiny, display = overlayMode ? display.all : display.none)plotshape(bearishSignal ? momentumUpBias * 1.2 : na, title = "Bearish TP Signal", color = color.new(colorDown, 30), textcolor = color.rgb(255, 255, 255), text = "TP", style = shape.labeldown, location = location.abovebar, size = size.tiny, display = overlayMode ? display.all : display.none)plotchar(bullishSignal ? momentumDownBias * 1.2 : na, "Bullish TP Signal", "X", location.absolute, color = color.new(colorUp, 30), size = size.tiny, display = not overlayMode ? display.all : display.none)plotchar(bearishSignal ? momentumUpBias * 1.2 : na, "Bearish TP Signal", "X", location.absolute, color = color.new(colorDown, 30), size = size.tiny, display = not overlayMode ? display.all : display.none)plotcandle(open, high, low, close, "Candle Color", candleColor, candleColor, bordercolor = candleColor, display = overlayMode ? display.all : display.none)12/29/2024 at 5:55 PM #241901Bonjour
par exemple :
momentumLength = 10
biasLength = 5
smoothLength = 10
impulseBoundaryLength = 30
stdDevMultiplier = 3.0
smoothIndicator =1
// Calcul de Momentum et Déviation Standard
moment = close – close[momentumLength]
stdDev = moment / ExponentialAverage[momentumLength](high – low) * 100
momentumUp = max(stdDev, 0)
momentumDown = min(stdDev, 0)// Calcul des sommes avec une boucle
sumMomentumUp = 0
sumMomentumDown = 0
FOR i = 0 TO biasLength – 1 DO
sumMomentumUp = sumMomentumUp + momentumUp[i]
sumMomentumDown = sumMomentumDown + momentumDown[i]
NEXT
// Lissage et calcul des biais
IF smoothIndicator=1 THEN
smoothedMomentumUp = HullAverage[smoothLength](momentumUp)
smoothedMomentumDown = HullAverage[smoothLength](momentumDown)
momentumUpBias = max(smoothedMomentumUp, 0)
momentumDownBias = max(-smoothedMomentumDown, 0)
ELSE
momentumUpBias = max(sumMomentumUp, 0)
momentumDownBias = max(-sumMomentumDown, 0)
ENDIF
// Moyenne des biais
averageBias = (momentumDownBias + momentumUpBias) / 2
// Calcul de la limite (boundary)
boundary = ExponentialAverage[impulseBoundaryLength](averageBias) + STD[impulseBoundaryLength](averageBias) * stdDevMultiplier
// Affichage des signaux
bullishSignal = momentumDownBias < momentumDownBias[1] AND momentumDownBias > boundary AND momentumDownBias > momentumUpBias
bearishSignal = momentumUpBias < momentumUpBias[1] AND momentumUpBias > boundary AND momentumUpBias > momentumDownBias
IF bullishSignal and not bullishSignal[1] THEN
DRAWTEXT(“X”, barindex, momentumDownBias + 0.2 * momentumDownBias, dialog, bold, 14) coloured(0, 175, 0)
ENDIF
IF bearishSignal and not bearishSignal[1] THEN
DRAWTEXT(“X”, barindex, momentumUpBias + 0.2 * momentumUpBias, dialog, bold, 14) coloured(150, 0, 0)
ENDIF
if momentumUpBias > momentumUpBias[1] then
r = 0
g = 150
b = 0
endif
if momentumUpBias < momentumUpBias[1] then
r =0
g =255
b =0
endif
if momentumDownBias > momentumDownBias[1] then
r =150
g = 0
b = 0
endif
if momentumDownBias < momentumDownBias[1] then
r =255
g = 0
b =0
endif
RETURN boundary as “boundary”, momentumUpBias coloured(r, g, b) style(histogram, 1) as “momentumUp”, momentumDownBias coloured(r,g,b) style(histogram, 1) as “momentumDown”12/30/2024 at 7:24 PM #241977bravo et merci pour ton travail que j’aurai été incapable de faire.
Toujours dans l’esprit de faire bien il y a quelques discordances dans les couleurs.
ci-joint 2 mêmes graphiques PRT et tradingview ou l’on s’aperçoit
- si les barres plus foncés pourraient etre en premier puis les barres plus claires (vert ou rouge)
- il y a des barres rouges qui n’ont rien à faire dans le trend haussier (voir graphique)
Peut etre avec le boudary mais je ne sais pas ?
merci
12/30/2024 at 7:43 PM #241980bonjour
ok pour les couleurs claires en 1er :
momentumLength = 10
biasLength = 5
smoothLength = 10
impulseBoundaryLength = 30
stdDevMultiplier = 3.0
smoothIndicator =1
// Calcul de Momentum et Déviation Standard
moment = close – close[momentumLength]
stdDev = moment / ExponentialAverage[momentumLength](high – low) * 100
momentumUp = max(stdDev, 0)
momentumDown = min(stdDev, 0)// Calcul des sommes avec une boucle
sumMomentumUp = 0
sumMomentumDown = 0
FOR i = 0 TO biasLength – 1 DO
sumMomentumUp = sumMomentumUp + momentumUp[i]
sumMomentumDown = sumMomentumDown + momentumDown[i]
NEXT
// Lissage et calcul des biais
IF smoothIndicator=1 THEN
smoothedMomentumUp = HullAverage[smoothLength](momentumUp)
smoothedMomentumDown = HullAverage[smoothLength](momentumDown)
momentumUpBias = max(smoothedMomentumUp, 0)
momentumDownBias = max(-smoothedMomentumDown, 0)
ELSE
momentumUpBias = max(sumMomentumUp, 0)
momentumDownBias = max(-sumMomentumDown, 0)
ENDIF
// Moyenne des biais
averageBias = (momentumDownBias + momentumUpBias) / 2
// Calcul de la limite (boundary)
boundary = ExponentialAverage[impulseBoundaryLength](averageBias) + STD[impulseBoundaryLength](averageBias) * stdDevMultiplier
// Affichage des signaux
bullishSignal = momentumDownBias < momentumDownBias[1] AND momentumDownBias > boundary AND momentumDownBias > momentumUpBias
bearishSignal = momentumUpBias < momentumUpBias[1] AND momentumUpBias > boundary AND momentumUpBias > momentumDownBias
IF bullishSignal and not bullishSignal[1] THEN
DRAWTEXT(“X”, barindex, momentumDownBias + 0.2 * momentumDownBias, dialog, bold, 14) coloured(0, 175, 0)
ENDIF
IF bearishSignal and not bearishSignal[1] THEN
DRAWTEXT(“X”, barindex, momentumUpBias + 0.2 * momentumUpBias, dialog, bold, 14) coloured(150, 0, 0)
ENDIF
if momentumUpBias > momentumUpBias[1] then
r = 0
g = 255
b = 0
endif
if momentumUpBias < momentumUpBias[1] then
r =0
g =150
b =0
endif
if momentumDownBias > momentumDownBias[1] then
r =255
g = 0
b = 0
endif
if momentumDownBias < momentumDownBias[1] then
r =150
g = 0
b =0
endif
RETURN boundary as “boundary”, momentumUpBias coloured(r, g, b) style(histogram, 1) as “momentumUp”, momentumDownBias coloured(r,g,b) style(histogram, 1) as “momentumDown”12/30/2024 at 8:00 PM #241981pour le deuxième problème ( barres rouges qui n’ont rien à faire dans le trend haussier ) indicateur à tester avec ajout de la suppression des conflits de couleurs dans les tendances :
momentumLength = 10
biasLength = 5
smoothLength = 10
impulseBoundaryLength = 30
stdDevMultiplier = 3.0
smoothIndicator =1
// Calcul de Momentum et Déviation Standard
moment = close – close[momentumLength]
stdDev = moment / ExponentialAverage[momentumLength](high – low) * 100
momentumUp = max(stdDev, 0)
momentumDown = min(stdDev, 0)
// Calcul des sommes avec une boucle
sumMomentumUp = 0
sumMomentumDown = 0
FOR i = 0 TO biasLength – 1 DO
sumMomentumUp = sumMomentumUp + momentumUp[i]
sumMomentumDown = sumMomentumDown + momentumDown[i]
NEXT
// Lissage et calcul des biais
IF smoothIndicator=1 THEN
smoothedMomentumUp = HullAverage[smoothLength](momentumUp)
smoothedMomentumDown = HullAverage[smoothLength](momentumDown)
momentumUpBias = max(smoothedMomentumUp, 0)
momentumDownBias = max(-smoothedMomentumDown, 0)
ELSE
momentumUpBias = max(sumMomentumUp, 0)
momentumDownBias = max(-sumMomentumDown, 0)
ENDIF
// Moyenne des biais
averageBias = (momentumDownBias + momentumUpBias) / 2
// Calcul de la limite (boundary)
boundary = ExponentialAverage[impulseBoundaryLength](averageBias) + STD[impulseBoundaryLength](averageBias) * stdDevMultiplier
// Affichage des signaux
bullishSignal = momentumDownBias < momentumDownBias[1] AND momentumDownBias > boundary AND momentumDownBias > momentumUpBias
bearishSignal = momentumUpBias < momentumUpBias[1] AND momentumUpBias > boundary AND momentumUpBias > momentumDownBias
IF bullishSignal and not bullishSignal[1] THEN
DRAWTEXT(“X”, barindex, momentumDownBias + 0.2 * momentumDownBias, dialog, bold, 14) coloured(0, 175, 0)
ENDIF
IF bearishSignal and not bearishSignal[1] THEN
DRAWTEXT(“X”, barindex, momentumUpBias + 0.2 * momentumUpBias, dialog, bold, 14) coloured(150, 0, 0)
ENDIF
if momentumUpBias > momentumUpBias[1] then
r = 0
g = 255
b = 0
elsif momentumUpBias < momentumUpBias[1] then
r = 0
g = 150
b = 0
endif
if momentumDownBias > momentumDownBias[1] then
r = 255
g = 0
b = 0
elsif momentumDownBias < momentumDownBias[1] then
r = 150
g = 0
b = 0
endif// Suppression des conflits de couleurs dans les tendances :
if trend = 1 then
// État haussier – bars rouges interdites
r = 0
g = max(g, 150) // Force le vert
elsif trend = -1 then
// État baissier – bars vertes interdites
r = max(r, 150)
g = 0
endifRETURN boundary as “boundary”, momentumUpBias coloured(r, g, b) style(histogram, 1) as “momentumUp”, momentumDownBias coloured(r,g,b) style(histogram, 1) as “momentumDown”
12/30/2024 at 8:46 PM #241983Merci pour les couleurs
par contre le deuxième probleme doit etre plus complexe
car il peut exister des barres vertes dans un trend baissier et inversement .
-
AuthorPosts