Conversion Maximiseur de profit PMax TW

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #223770 quote
    BatesonBateson
    Participant
    Junior

    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: @KivancOzbilgic

    study(“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)
    ma

    if mav == “EMA”
    ma := ema(src, length)
    ma

    if mav == “WMA”
    ma := wma(src, length)
    ma

    if mav == “TMA”
    ma := sma(sma(src, ceil(length / 2)), floor(length / 2) + 1)
    ma

    if mav == “VAR”
    ma := VAR
    ma

    if mav == “WWMA”
    ma := WWMA
    ma

    if mav == “ZLEMA”
    ma := ZLEMA
    ma

    if mav == “TSF”
    ma := TSF
    ma
    ma

    MAvg=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 ? 1 : dir == 1 and MAvg PMax ? color.green : na) : na
    shortFillColor = highlighting ? (MAvg<PMax ? color.red : na) : na
    fill(mPlot, pALL, title="UpTrend Highligter", color=longFillColor)
    fill(mPlot, pALL, title="DownTrend Highligter", color=shortFillColor)

    #230097 quote
    Iván GonzálezIván González
    Moderator
    Legend

    Hola Ici, vous avez le code traduit :

    //PRC_PMAX indicator
    //version = 0
    //20.03.24
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //---------Inputs---------------------------------------//
    src = customclose
    periods = 10 //ATR Length
    Multiplier = 3 //decimal
    mav = 1 //Moving average type
    length = 10 //Moving average length
    changeATR = 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 then
    atr=averagetruerange[periods](close)
    else
    atr=atr2
    endif
    //-----------Moving average definition-------------------//
    Mavg=average[length,mav](src)
    //-----------Trail Stop definition-----------------------//
    if normalize then
    longstop = mavg-multiplier*atr/close
    shortStop = MAvg + Multiplier*atr/close
    else
    longstop = mavg-multiplier*atr
    shortStop = MAvg + Multiplier*atr
    endif
    
    longstopprev = longstop[1]
    shortStopPrev = shortStop[1]
    
    if barindex < length then
    Pmax = mavg
    else
    if mavg > longstopprev then
    longStop = max(longStop, longStopPrev)
    else
    longStop = longStop
    endif
    
    if mavg < shortStopPrev then
    shortStop = min(shortStop, shortStopPrev)
    else
    shortStop = shortStop
    endif
    
    once dir = 1
    if dir = -1 and MAvg > shortStopPrev then
    dir = 1
    elsif dir = 1 and MAvg < longStopPrev then
    dir = -1
    else
    dir = dir
    endif
    
    if dir = 1 then
    Pmax = longstop
    else
    Pmax = shortstop
    endif
    endif
    //---------Buy & Sell Signals------------------------------//
    buysignalk = Mavg crosses over Pmax
    sellSignallk = Mavg crosses under Pmax
    buySignalc = src crosses over Pmax
    sellSignallc = src crosses under Pmax
    
    if showsignalsk and buysignalk then
    drawtext("▲",barindex,Pmax-0.1*tr)coloured("green")
    drawtext("BUY",barindex,Pmax-0.35*tr)coloured("green")
    elsif showsignalsk and sellSignallk then
    drawtext("▼",barindex,Pmax+0.1*tr)coloured("red")
    drawtext("SELL",barindex,Pmax+0.35*tr)coloured("red")
    elsif showsgnalsc and buySignalc then
    drawtext("▲",barindex,Pmax-0.1*tr)coloured("blue")
    drawtext("BUY",barindex,Pmax-0.35*tr)coloured("blue")
    elsif showsgnalsc and sellSignallc then
    drawtext("▼",barindex,Pmax+0.1*tr)coloured("purple")
    drawtext("SELL",barindex,Pmax+0.35*tr)coloured("purple")
    endif
    //---------------------------------------------------------//
    //----------------Highlighting-----------------------------//
    ohlc = (open+close+high+low)/4
    if Mavg > Pmax then
    r=0
    g=255
    else
    r=255
    g=0
    endif
    if barindex > length and highlighting then
    colorbetween(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)
    
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Conversion Maximiseur de profit PMax TW


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
Bateson @bateson Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Iván GonzálezIván González
2 years, 6 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 11/15/2023
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...