Conversion d’un code pour PRT
Forums › ProRealTime forum Français › Support ProBuilder › Conversion d’un code pour PRT
- This topic has 5 replies, 3 voices, and was last updated 4 weeks ago by Poupouille.
-
-
12/30/2024 at 6:27 PM #241972
Bjr, serait-il possible de convertir le code ci-dessous pour pouvoir utiliser cet indicateur sur PRT ?
L’indicateur se trouve ici => https://www.tradingview.com/script/3O0jn6h9-Dynamic-Trading-Strategy-with-Key-Levels-Entry-Exit-Management/
Voici le code :Dynamic Trading Strategy with Key Levels, Entry/Exit Management
//@version=5
indicator(“Dynamic Trading Strategy with Key Levels, Entry/Exit Management”, overlay=true)// Input Parameters
lookbackPeriod = input.int(20, “Lookback Period for Key Levels”)
atrPeriod = input.int(14, “ATR Period”)
atrMultiplierSL = input.float(1.5, “SL ATR Multiplier”)
atrMultiplierTP1 = input.float(1.5, “TP1 ATR Multiplier”)
atrMultiplierTP2 = input.float(2.0, “TP2 ATR Multiplier”)
rewardToRisk = input.float(2.0, “Reward to Risk Ratio”)// ATR and Volume Calculation
atr = ta.atr(atrPeriod)
volumeSMA = ta.sma(volume, atrPeriod)// Key Levels Identification (Support & Resistance Zones)
support = ta.lowest(low, lookbackPeriod)
resistance = ta.highest(high, lookbackPeriod)
supportBuffer = support – atr * 0.5
resistanceBuffer = resistance + atr * 0.5// Define Bullish and Bearish Scenario Entry Ranges (Visualized with Boxes)
var box bullishBox = na
var box bearishBox = na// Bullish Scenario
isBullishEntry = (close > supportBuffer) and (low <= support) and (volume > volumeSMA)
if isBullishEntry
if na(bullishBox)
bullishBox := box.new(left=bar_index – 10, top=support + atr * 0.5, right=bar_index + 10, bottom=support – atr * 0.5, border_color=color.green, bgcolor=color.new(color.green, 85))
else
box.set_left(bullishBox, bar_index – 10)
box.set_right(bullishBox, bar_index + 10)
box.set_top(bullishBox, support + atr * 0.5)
box.set_bottom(bullishBox, support – atr * 0.5)// Bearish Scenario
isBearishEntry = (close < resistanceBuffer) and (high >= resistance) and (volume > volumeSMA)
if isBearishEntry
if na(bearishBox)
bearishBox := box.new(left=bar_index – 10, top=resistance + atr * 0.5, right=bar_index + 10, bottom=resistance – atr * 0.5, border_color=color.red, bgcolor=color.new(color.red, 85))
else
box.set_left(bearishBox, bar_index – 10)
box.set_right(bearishBox, bar_index + 10)
box.set_top(bearishBox, resistance + atr * 0.5)
box.set_bottom(bearishBox, resistance – atr * 0.5)// Stop Loss and Take Profit Calculations for Bullish and Bearish Scenarios
bullishSL = support – atr * atrMultiplierSL
bullishTP1 = support + atr * rewardToRisk * atrMultiplierTP1
bullishTP2 = support + atr * rewardToRisk * atrMultiplierTP2bearishSL = resistance + atr * atrMultiplierSL
bearishTP1 = resistance – atr * rewardToRisk * atrMultiplierTP1
bearishTP2 = resistance – atr * rewardToRisk * atrMultiplierTP2// Visualization for Bullish Scenario (TP1, TP2, SL Lines with Labels)
var line bullishTP1Line = na
var line bullishTP2Line = na
var line bullishSLLine = na
var label bullishTP1Label = na
var label bullishTP2Label = na
var label bullishSLLabel = naif isBullishEntry
if na(bullishTP1Line)
bullishTP1Line := line.new(bar_index – 10, bullishTP1, bar_index + 10, bullishTP1, color=color.green, width=2)
else
line.set_xy1(bullishTP1Line, bar_index – 10, bullishTP1)
line.set_xy2(bullishTP1Line, bar_index + 10, bullishTP1)if na(bullishTP1Label)
bullishTP1Label := label.new(bar_index + 10, bullishTP1, “TP1”, color=color.green, textcolor=color.white, yloc=yloc.price, style=label.style_label_right)
else
label.set_xy(bullishTP1Label, bar_index + 10, bullishTP1)if na(bullishTP2Line)
bullishTP2Line := line.new(bar_index – 10, bullishTP2, bar_index + 10, bullishTP2, color=color.green, width=2)
else
line.set_xy1(bullishTP2Line, bar_index – 10, bullishTP2)
line.set_xy2(bullishTP2Line, bar_index + 10, bullishTP2)if na(bullishTP2Label)
bullishTP2Label := label.new(bar_index + 10, bullishTP2, “TP2”, color=color.green, textcolor=color.white, yloc=yloc.price, style=label.style_label_right)
else
label.set_xy(bullishTP2Label, bar_index + 10, bullishTP2)if na(bullishSLLine)
bullishSLLine := line.new(bar_index – 10, bullishSL, bar_index + 10, bullishSL, color=color.red, width=2)
else
line.set_xy1(bullishSLLine, bar_index – 10, bullishSL)
line.set_xy2(bullishSLLine, bar_index + 10, bullishSL)if na(bullishSLLabel)
bullishSLLabel := label.new(bar_index + 10, bullishSL, “SL”, color=color.red, textcolor=color.white, yloc=yloc.price, style=label.style_label_right)
else
label.set_xy(bullishSLLabel, bar_index + 10, bullishSL)// Visualization for Bearish Scenario (TP1, TP2, SL Lines with Labels)
var line bearishTP1Line = na
var line bearishTP2Line = na
var line bearishSLLine = na
var label bearishTP1Label = na
var label bearishTP2Label = na
var label bearishSLLabel = naif isBearishEntry
if na(bearishTP1Line)
bearishTP1Line := line.new(bar_index – 10, bearishTP1, bar_index + 10, bearishTP1, color=color.red, width=2)
else
line.set_xy1(bearishTP1Line, bar_index – 10, bearishTP1)
line.set_xy2(bearishTP1Line, bar_index + 10, bearishTP1)if na(bearishTP1Label)
bearishTP1Label := label.new(bar_index + 10, bearishTP1, “TP1”, color=color.red, textcolor=color.white, yloc=yloc.price, style=label.style_label_right)
else
label.set_xy(bearishTP1Label, bar_index + 10, bearishTP1)if na(bearishTP2Line)
bearishTP2Line := line.new(bar_index – 10, bearishTP2, bar_index + 10, bearishTP2, color=color.red, width=2)
else
line.set_xy1(bearishTP2Line, bar_index – 10, bearishTP2)
line.set_xy2(bearishTP2Line, bar_index + 10, bearishTP2)if na(bearishTP2Label)
bearishTP2Label := label.new(bar_index + 10, bearishTP2, “TP2”, color=color.red, textcolor=color.white, yloc=yloc.price, style=label.style_label_right)
else
label.set_xy(bearishTP2Label, bar_index + 10, bearishTP2)if na(bearishSLLine)
bearishSLLine := line.new(bar_index – 10, bearishSL, bar_index + 10, bearishSL, color=color.green, width=2)
else
line.set_xy1(bearishSLLine, bar_index – 10, bearishSL)
line.set_xy2(bearishSLLine, bar_index + 10, bearishSL)if na(bearishSLLabel)
bearishSLLabel := label.new(bar_index + 10, bearishSL, “SL”, color=color.green, textcolor=color.white, yloc=yloc.price, style=label.style_label_right)
else
label.set_xy(bearishSLLabel, bar_index + 10, bearishSL)12/30/2024 at 6:28 PM #241973Je vous remercie d’avance
01/08/2025 at 5:07 PM #242318bonnes tardes. Ici, tu es :
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283//----------------------------------------------------------////PRC_Dynamic Strategy with Key Levels//version = 0//08.01.2025//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//----------------------------------------------------------//// inputs//----------------------------------------------------------//defparam drawonlastbaronly=truelookbackperiod=20atrperiod=14atrmulSL=1.5atrmulTP1=1.5atrmulTP2=2rewardtorisk=2//----------------------------------------------------------//// atr and volume calculation//----------------------------------------------------------//atr=averagetruerange[atrperiod](close)volumeSMA=average[atrperiod](volume)//----------------------------------------------------------//// key levels identification (support and resistance zones)//----------------------------------------------------------//support=lowest[lookbackperiod](low)resistance=highest[lookbackperiod](high)supportBuffer=support-atr*0.5resistanceBuffer=resistance+atr*0.5//----------------------------------------------------------//// Define Bullish and Bearish scenario entry ranges//----------------------------------------------------------////Bullish scenarioisBullishEntry=close>supportBuffer and low<=support and volume>volumeSMAif isBullishEntry then$suppx1[n+1]=barindex-10$suppx2[n+1]=barindex+10$suppy1[n+1]=support-atr*0.5$suppy2[n+1]=support+atr*0.5$bullishSL[n+1]=support-atr*atrmulSL$bullishTP1[n+1]=support+atr*rewardtorisk*atrmulTP1$bullishTP2[n+1]=support+atr*rewardtorisk*atrmulTP2n=n+1endif//Bearish scenarioisBearishEntry=close<resistanceBuffer and high>=resistance and volume>volumeSMAif isBearishEntry then$resx1[t+1]=barindex-10$resx2[t+1]=barindex+10$resy1[t+1]=resistance-atr*0.5$resy2[t+1]=resistance+atr*0.5$bearishSL[t+1]=resistance+atr*atrmulSL$bearishTP1[t+1]=resistance-atr*rewardtorisk*atrmulTP1$bearishTP2[t+1]=resistance-atr*rewardtorisk*atrmulTP2t=t+1endif//----------------------------------------------------------//// Draw last support and resistance//----------------------------------------------------------//if islastbarupdate then//Supportdrawrectangle($suppx1[n],$suppy1[n],$suppx2[n],$suppy2[n])coloured("green")fillcolor("green",40)//Key Levels longdrawsegment($suppx1[n],$bullishSL[n],$suppx2[n],$bullishSL[n])coloured("red")style(line,2)drawtext("SL",$suppx2[n],$bullishSL[n]+0.15*atr)coloured("red")drawsegment($suppx1[n],$bullishTP1[n],$suppx2[n],$bullishTP1[n])coloured("green")style(line,2)drawtext("TP1",$suppx2[n],$bullishTP1[n]+0.15*atr)coloured("green")drawsegment($suppx1[n],$bullishTP2[n],$suppx2[n],$bullishTP2[n])coloured("green")style(line,2)drawtext("TP2",$suppx2[n],$bullishTP2[n]+0.15*atr)coloured("green")//Resistancedrawrectangle($resx1[t],$resy1[t],$resx2[t],$resy2[t])coloured("red")fillcolor("red",40)//Key Levels shortdrawsegment($resx1[t],$bearishSL[t],$resx2[t],$bearishSL[t])coloured("red")style(line,2)drawtext("SL",$resx2[t],$bearishSL[t]+0.15*atr)coloured("red")drawsegment($resx1[t],$bearishTP1[t],$resx2[t],$bearishTP1[t])coloured("green")style(line,2)drawtext("TP1",$resx2[t],$bearishTP1[t]+0.15*atr)coloured("green")drawsegment($resx1[t],$bearishTP2[t],$resx2[t],$bearishTP2[t])coloured("green")style(line,2)drawtext("TP2",$resx2[t],$bearishTP2[t]+0.15*atr)coloured("green")endif//----------------------------------------------------------//return01/08/2025 at 5:42 PM #242321Merci beaucoup, ça fonctionne, top.
Bonne soirée01/08/2025 at 5:48 PM #242323Vous n’êtes que deux, merci de ne pas citer si ce n’est pas vraiment difficile de dire qui a écrit quoi.
Cela aidera à garder les sujets plus courts et plus lisibles.
Merci 🙂01/08/2025 at 5:54 PM #242324 -
AuthorPosts
Find exclusive trading pro-tools on