Sistema giornaliero con loss e profit

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

    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
    Aragorna
    Participant
    Junior

    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
    Aragorna
    Participant
    Junior

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

    #221012 quote
    Ciccarelli Franco
    Participant
    Junior

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

    #221015 quote
    robertogozzi
    Moderator
    Master

    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.

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 robertogozzi
2 years, 4 months ago.

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