convertir Un système de trading de la plateforme de tradingview

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #210682 quote
    gadchristian
    Participant
    New

    Bonjour,
    je vous serais éternellement reconnaissant de pouvoir me convertir Un système de trading de la plateforme de tradingview en système de trading automatique pour la plateforme prorealtime, donc vous trouverez en pièce jointe sur bloc note le code d’un système de trading ( SuperTrend STRATEGY de KivancOzbilgic ) de la plateforme trading View. Que je voudrais convertir en code pour la plateforme pro Real time.
    les réglages de périodes ATR 10 et multiplicateur de 0.5 il doit être utilisé avec les bougies heikin Hachi en 30 min .
    merci .

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

    //@version=4
    strategy(“SuperTrend STRATEGY”, overlay=true)
    Periods = input(title=”ATR Period”, type=input.integer, defval=10)
    src = input(hl2, title=”Source”)
    Multiplier = input(title=”ATR Multiplier”, type=input.float, step=0.1, defval=3.0)
    changeATR= input(title=”Change ATR Calculation Method ?”, type=input.bool, defval=true)
    showsignals = input(title=”Show Buy/Sell Signals ?”, type=input.bool, defval=false)
    highlighting = input(title=”Highlighter On/Off ?”, type=input.bool, defval=true)
    barcoloring = input(title=”Bar Coloring On/Off ?”, type=input.bool, defval=true)
    atr2 = sma(tr, Periods)
    atr= changeATR ? atr(Periods) : atr2
    up=src-(Multiplier*atr)
    up1 = nz(up[1],up)
    up := close[1] > up1 ? max(up,up1) : up
    dn=src+(Multiplier*atr)
    dn1 = nz(dn[1], dn)
    dn := close[1] < dn1 ? min(dn, dn1) : dn
    trend = 1
    trend := nz(trend[1], trend)
    trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
    upPlot = plot(trend == 1 ? up : na, title=”Up Trend”, style=plot.style_linebr, linewidth=2, color=color.green)
    buySignal = trend == 1 and trend[1] == -1
    plotshape(buySignal ? up : na, title=”UpTrend Begins”, location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0)
    plotshape(buySignal and showsignals ? up : na, title=”Buy”, text=”Buy”, location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)
    dnPlot = plot(trend == 1 ? na : dn, title=”Down Trend”, style=plot.style_linebr, linewidth=2, color=color.red)
    sellSignal = trend == -1 and trend[1] == 1
    plotshape(sellSignal ? dn : na, title=”DownTrend Begins”, location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0)
    plotshape(sellSignal and showsignals ? dn : na, title=”Sell”, text=”Sell”, location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)
    mPlot = plot(ohlc4, title=””, style=plot.style_circles, linewidth=0)
    longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.white
    shortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.white
    fill(mPlot, upPlot, title=”UpTrend Highligter”, color=longFillColor)
    fill(mPlot, dnPlot, title=”DownTrend Highligter”, color=shortFillColor)
    FromMonth = input(defval = 9, title = “From Month”, minval = 1, maxval = 12)
    FromDay = input(defval = 1, title = “From Day”, minval = 1, maxval = 31)
    FromYear = input(defval = 2018, title = “From Year”, minval = 999)
    ToMonth = input(defval = 1, title = “To Month”, minval = 1, maxval = 12)
    ToDay = input(defval = 1, title = “To Day”, minval = 1, maxval = 31)
    ToYear = input(defval = 9999, title = “To Year”, minval = 999)
    start = timestamp(FromYear, FromMonth, FromDay, 00, 00)
    finish = timestamp(ToYear, ToMonth, ToDay, 23, 59)
    window() => time >= start and time <= finish ? true : false
    longCondition = buySignal
    if (longCondition)
    strategy.entry(“BUY”, strategy.long, when = window())
    shortCondition = sellSignal
    if (shortCondition)
    strategy.entry(“SELL”, strategy.short, when = window())
    buy1= barssince(buySignal)
    sell1 = barssince(sellSignal)
    color1 = buy1[1] < sell1[1] ? color.green : buy1[1] > sell1[1] ? color.red : na
    barcolor(barcoloring ? color1 : na)

    strategie-supertrend.png strategie-supertrend.png
    #210835 quote
    Nicolas
    Keymaster
    Master

    Merci de ne pas double poster, j’ai supprimé l’autre sujet.

    Cette stratégie c’est un achat / vente sur Supertrend calculé avec le TotalPrice (soit le close d’une bougie HA).

    defparam cumulateorders=false 
    
    // Average True Range X
    ATRx = AverageTrueRange[10](totalprice) * 0.5
    
    IF close crosses over ATRts THEN
    trend=1
    ATRts = close - ATRx
    r=0
    g=255
    ELSIF close crosses under ATRts THEN
    trend=-1
    ATRts = close + ATRx
    r=255
    g=0
    ENDIF
    IF close > ATRts THEN
    ATRnew = close - ATRx
    IF ATRnew > ATRts THEN
    ATRts = ATRnew
    ENDIF
    ELSIF close < ATRts THEN
    ATRnew = close + ATRx
    IF ATRnew < ATRts THEN
    ATRts = ATRnew
    ENDIF
    ENDIF
    
    if not longonmarket and trend=1 and trend[1]<>1 then 
    buy at market 
    endif 
    
    if not shortonmarket and trend=-1 and trend[1]<>-1 then
    sellshort at market
    endif
    
    graphonprice atrts coloured(r,g,0)
    #210858 quote
    gadchristian
    Participant
    New

    bonjour

    le système que vous avez fait ne fonctione pas proorder me renvoi le message d’erreur suivant : l’instruction  ” GRAPH ” ne peut pas être utilise en trading automatique

    Remerciements

    #210860 quote
    gadchristian
    Participant
    New

    ps : je travaille à 0.5 en taille de contrat, vous avez entré 1 contrat sur le système, cela est-il un problème parce que j’ai essayé en supprimant la ligne 37 de l’erreur GRAPH et ça fonctionne pas

    #211052 quote
    Nicolas
    Keymaster
    Master

    Ci-dessous la version sans le graph et des lots à 0.5

    defparam cumulateorders=false 
    
    // Average True Range X
    ATRx = AverageTrueRange[10](totalprice) * 0.5
    
    IF close crosses over ATRts THEN
    trend=1
    ATRts = close - ATRx
    r=0
    g=255
    ELSIF close crosses under ATRts THEN
    trend=-1
    ATRts = close + ATRx
    r=255
    g=0
    ENDIF
    IF close > ATRts THEN
    ATRnew = close - ATRx
    IF ATRnew > ATRts THEN
    ATRts = ATRnew
    ENDIF
    ELSIF close < ATRts THEN
    ATRnew = close + ATRx
    IF ATRnew < ATRts THEN
    ATRts = ATRnew
    ENDIF
    ENDIF
    
    if not longonmarket and trend=1 and trend[1]<>1 then 
    buy 0.5 contract at market 
    endif 
    
    if not shortonmarket and trend=-1 and trend[1]<>-1 then
    sellshort 0.5 contract at market
    endif
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

convertir Un système de trading de la plateforme de tradingview


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by Nicolas
3 years ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 02/28/2023
Status: Active
Attachments: 1 files
Logo Logo
Loading...