Conversion Maximiseur de profit PMax TW
Forums › ProRealTime forum Français › Support ProBuilder › Conversion Maximiseur de profit PMax TW
- This topic has 1 reply, 2 voices, and was last updated 9 months ago by Iván.
-
-
11/15/2023 at 11:37 PM #223770
Bonjour,
Serait-il possible de traduire le code ci dessous trouvé sut TW ?
Lien, description et code ici :https://fr.tradingview.com/script/sU9molfV/
Une des particularités qui m’interesse est de pouvoit choisir ld typd de moyennes mobiles.
Merci beaucoup !//@version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © KivancOzbilgic
//developer: @KivancOzbilgic
//author: @KivancOzbilgicstudy(“Profit Maximizer”,”PMax”, overlay=true, format=format.price, precision=2, resolution=””)
src = input(hl2, title=”Source”)
Periods = input(title=”ATR Length”, type=input.integer, defval=10)
Multiplier = input(title=”ATR Multiplier”, type=input.float, step=0.1, defval=3.0)
mav = input(title=”Moving Average Type”, defval=”EMA”, options=[“SMA”, “EMA”, “WMA”, “TMA”, “VAR”, “WWMA”, “ZLEMA”, “TSF”])
length =input(10, “Moving Average Length”, minval=1)
changeATR= input(title=”Change ATR Calculation Method ?”, type=input.bool, defval=true)
Normalize= input(title=”Normalize ATR ?”, type=input.bool, defval=false)
showsupport = input(title=”Show Moving Average?”, type=input.bool, defval=true)
showsignalsk = input(title=”Show Crossing Signals?”, type=input.bool, defval=true)
showsignalsc = input(title=”Show Price/Pmax Crossing Signals?”, type=input.bool, defval=false)
highlighting = input(title=”Highlighter On/Off ?”, type=input.bool, defval=true)
atr2 = sma(tr, Periods)
atr= changeATR ? atr(Periods) : atr2
valpha=2/(length+1)
vud1=src>src[1] ? src-src[1] : 0
vdd1=src
ma = 0.0
if mav == “SMA”
ma := sma(src, length)
maif mav == “EMA”
ma := ema(src, length)
maif mav == “WMA”
ma := wma(src, length)
maif mav == “TMA”
ma := sma(sma(src, ceil(length / 2)), floor(length / 2) + 1)
maif mav == “VAR”
ma := VAR
maif mav == “WWMA”
ma := WWMA
maif mav == “ZLEMA”
ma := ZLEMA
maif mav == “TSF”
ma := TSF
ma
maMAvg=getMA(src, length)
longStop = Normalize ? MAvg – Multiplier*atr/close : MAvg – Multiplier*atr
longStopPrev = nz(longStop[1], longStop)
longStop := MAvg > longStopPrev ? max(longStop, longStopPrev) : longStop
shortStop = Normalize ? MAvg + Multiplier*atr/close : MAvg + Multiplier*atr
shortStopPrev = nz(shortStop[1], shortStop)
shortStop := MAvg < shortStopPrev ? min(shortStop, shortStopPrev) : shortStop dir = 1 dir := nz(dir[1], dir) dir := dir == -1 and MAvg > shortStopPrev ? 1 : dir == 1 and MAvg < longStopPrev ? -1 : dir PMax = dir==1 ? longStop: shortStop plot(showsupport ? MAvg : na, color=#0585E1, linewidth=2, title="Moving Avg Line") pALL=plot(PMax, color=color.red, linewidth=2, title="PMax", transp=0) alertcondition(cross(MAvg, PMax), title="Cross Alert", message="PMax - Moving Avg Crossing!") alertcondition(crossover(MAvg, PMax), title="Crossover Alarm", message="Moving Avg BUY SIGNAL!") alertcondition(crossunder(MAvg, PMax), title="Crossunder Alarm", message="Moving Avg SELL SIGNAL!") alertcondition(cross(src, PMax), title="Price Cross Alert", message="PMax - Price Crossing!") alertcondition(crossover(src, PMax), title="Price Crossover Alarm", message="PRICE OVER PMax - BUY SIGNAL!") alertcondition(crossunder(src, PMax), title="Price Crossunder Alarm", message="PRICE UNDER PMax - SELL SIGNAL!") buySignalk = crossover(MAvg, PMax) plotshape(buySignalk and showsignalsk ? PMax*0.995 : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0) sellSignallk = crossunder(MAvg, PMax) plotshape(sellSignallk and showsignalsk ? PMax*1.005 : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0) buySignalc = crossover(src, PMax) plotshape(buySignalc and showsignalsc ? PMax*0.995 : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=#0F18BF, textcolor=color.white, transp=0) sellSignallc = crossunder(src, PMax) plotshape(sellSignallc and showsignalsc ? PMax*1.005 : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=#0F18BF, textcolor=color.white, transp=0) mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0,display=display.none) longFillColor = highlighting ? (MAvg>PMax ? color.green : na) : na
shortFillColor = highlighting ? (MAvg03/20/2024 at 12:00 PM #230097Hola Ici, vous avez le code traduit :
Indicateur PRC_PMAX123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102//PRC_PMAX indicator//version = 0//20.03.24//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//---------Inputs---------------------------------------//src = customcloseperiods = 10 //ATR LengthMultiplier = 3 //decimalmav = 1 //Moving average typelength = 10 //Moving average lengthchangeATR = 1 //Change ATR calculation method?Normalize = 0 //Normalize ATR?showsignalsk = 1 //Show crossing signals?showsgnalsc = 0 //Show price/Pmax crossing signals?highlighting = 1 //highlighter On/off?//------------------------------------------------------////-----------ATR definition-----------------------------//atr2 = average[Periods](tr)if changeatr thenatr=averagetruerange[periods](close)elseatr=atr2endif//-----------Moving average definition-------------------//Mavg=average[length,mav](src)//-----------Trail Stop definition-----------------------//if normalize thenlongstop = mavg-multiplier*atr/closeshortStop = MAvg + Multiplier*atr/closeelselongstop = mavg-multiplier*atrshortStop = MAvg + Multiplier*atrendiflongstopprev = longstop[1]shortStopPrev = shortStop[1]if barindex < length thenPmax = mavgelseif mavg > longstopprev thenlongStop = max(longStop, longStopPrev)elselongStop = longStopendifif mavg < shortStopPrev thenshortStop = min(shortStop, shortStopPrev)elseshortStop = shortStopendifonce dir = 1if dir = -1 and MAvg > shortStopPrev thendir = 1elsif dir = 1 and MAvg < longStopPrev thendir = -1elsedir = direndifif dir = 1 thenPmax = longstopelsePmax = shortstopendifendif//---------Buy & Sell Signals------------------------------//buysignalk = Mavg crosses over PmaxsellSignallk = Mavg crosses under PmaxbuySignalc = src crosses over PmaxsellSignallc = src crosses under Pmaxif showsignalsk and buysignalk thendrawtext("▲",barindex,Pmax-0.1*tr)coloured("green")drawtext("BUY",barindex,Pmax-0.35*tr)coloured("green")elsif showsignalsk and sellSignallk thendrawtext("▼",barindex,Pmax+0.1*tr)coloured("red")drawtext("SELL",barindex,Pmax+0.35*tr)coloured("red")elsif showsgnalsc and buySignalc thendrawtext("▲",barindex,Pmax-0.1*tr)coloured("blue")drawtext("BUY",barindex,Pmax-0.35*tr)coloured("blue")elsif showsgnalsc and sellSignallc thendrawtext("▼",barindex,Pmax+0.1*tr)coloured("purple")drawtext("SELL",barindex,Pmax+0.35*tr)coloured("purple")endif//---------------------------------------------------------////----------------Highlighting-----------------------------//ohlc = (open+close+high+low)/4if Mavg > Pmax thenr=0g=255elser=255g=0endifif barindex > length and highlighting thencolorbetween(ohlc,Pmax,r,g,0,70)endif//----------------------------------------------------------//return Mavg as "Moving avg line"coloured("blue")style(line,2),Pmax as "Pmax"coloured("red")style(line,2) -
AuthorPosts
Find exclusive trading pro-tools on