Sistema giornaliero con loss e profit

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #220920 quote
    Ciccarelli FrancoCiccarelli Franco
    Participant
    Senior

    Nel codice trovato in libreria (allego) ho aggiunto un loss e profit, ma essendo il TF giornaliero , gli stessi operano a fine giornata e il drawdown è veramente alto. Vorrei limitarlo agendo sul loss e profit che dovrebbero agire dentro la candela, ma non so se è possibile.

    Grazie a chi mi può aiutare.

    //Universal XBody STrategy
    // instrument: DAX
    // timeframe : Daily
    // Spread: 4
    // created and coded by davidelaferla
    //————————————————————————-

    //————————————————————————-
    defparam cumulateorders=false

    //***********************************************************************************************************
    N = 1
    //—————— SYSTEM VARIABLES—————————————
    //CAC40 Values: ——————————————– Ottimization info
    period=per// Optimize best value for each Symbol, range=1-1000, with step=1
    mode=md// Optimize the best trading mode , range=1-4, with step=1
    invertsignal=inv// 1=positive signal, -1=negative signal, range=-1-1, with step=2
    //***********************************************************************************************
    //—————— SYSTEM FILTER—————————————
    filter1=fl1// to set after the variable optimization, range=1-100, with step=1
    filter2=fl2// to set after the variable optimization, range=0-100, with step=1
    //—————— INDICATOR —————————————
    body=close-open
    var=(body-body[1])
    sumvar=summation[period](var)
    if sumvar>filter1*pipsize then
    green=(sumvar)
    endif
    if sumvar<-filter2*pipsize then
    red=(sumvar)
    endif

    if mode=1 then
    c1=red<red[1]
    c2=green>green[1]
    endif
    if mode=2 then
    c1=red>red[1]
    c2=green<green[1]
    endif
    if mode=3 then
    c1=red<red[1]
    c2=green<green[1]
    endif
    if mode=4 then
    c1=red>red[1]
    c2=green>green[1]
    endif
    if c1 then
    signal=1*invertsignal
    elsif c2 then
    signal=-1*invertsignal
    endif

    // Conditions for entering long positions and exit short positions
    IF signal>0 then
    BUY n contract AT market
    ENDIF
    // Conditions for entering short positions and exit long positions
    IF signal<0 THEN
    SELLSHORT n CONTRACTs AT market

     

    SET STOP LOSS l*AverageTrueRange[10](close)
    SET TARGET PROFIT p*AverageTrueRange[12](close)

    ENDIF

    #220922 quote
    AragornaAragorna
    Participant
    Average

    secondo me l’unico modo è inserire un TF diverso sulla parte di esecuzione e inserire un timeframe giornaliero sull’indicatore, per esempio:

    //Universal XBody STrategy
    // instrument: DAX
    // timeframe : Daily
    // Spread: 4
    // created and coded by davidelaferla
    //————————————————————————-

    //————————————————————————-
    defparam cumulateorders=false

    Timeframe ( 1 day, updateonclose)

    //***********************************************************************************************************
    N = 1
    //—————— SYSTEM VARIABLES—————————————
    //CAC40 Values: ——————————————– Ottimization info
    period=per// Optimize best value for each Symbol, range=1-1000, with step=1
    mode=md// Optimize the best trading mode , range=1-4, with step=1
    invertsignal=inv// 1=positive signal, -1=negative signal, range=-1-1, with step=2
    //***********************************************************************************************
    //—————— SYSTEM FILTER—————————————
    filter1=fl1// to set after the variable optimization, range=1-100, with step=1
    filter2=fl2// to set after the variable optimization, range=0-100, with step=1
    //—————— INDICATOR —————————————
    body=close-open
    var=(body-body[1])
    sumvar=summation[period](var)
    if sumvar>filter1*pipsize then
    green=(sumvar)
    endif
    if sumvar<-filter2*pipsize then
    red=(sumvar)
    endif

    if mode=1 then
    c1=red<red[1]
    c2=green>green[1]
    endif
    if mode=2 then
    c1=red>red[1]
    c2=green<green[1]
    endif
    if mode=3 then
    c1=red<red[1]
    c2=green<green[1]
    endif
    if mode=4 then
    c1=red>red[1]
    c2=green>green[1]
    endif
    if c1 then
    signal=1*invertsignal
    elsif c2 then
    signal=-1*invertsignal
    endif

    Timeframe ( 1 hour, default)

    // Conditions for entering long positions and exit short positions
    IF signal>0 then
    BUY n contract AT market
    ENDIF
    // Conditions for entering short positions and exit long positions
    IF signal<0 THEN
    SELLSHORT n CONTRACTs AT market

     

    SET STOP LOSS l*AverageTrueRange[10](close)
    SET TARGET PROFIT p*AverageTrueRange[12](close)

    ENDIF

    robertogozzi thanked this post
    #220923 quote
    AragornaAragorna
    Participant
    Average

    da adattare i valori di AverageTrueRange, perchè lavoranso ull’orario, quidni da moltiplicare per 24 presumo

    #221012 quote
    Ciccarelli FrancoCiccarelli Franco
    Participant
    Senior

    Lo sto provando, ma mi da l’errore che allego

    Cattura.jpg Cattura.jpg
    #221015 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Devi usare un TF di 1 ora o minore (però se minore, bisogna che 60, che sono i minuti di un’ora ne siano multipli).

Viewing 5 posts - 1 through 5 (of 5 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

Sistema giornaliero con loss e profit


ProOrder: Trading Automatico & Backtesting

New Reply
Summary

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

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 09/13/2023
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...