Live non chiude la posizione

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #261902 quote
    Gaspare
    Participant
    Veteran

    Salve

    il TS messo live su US500 cash 1, non chiude, invece in backtesting la posizione viene chiusa

    stesso problema anche con altri indici

    Grazie


    DEFPARAM CumulateOrders = false
    Defparam Flatbefore= 060000
    Defparam Flatafter = 220000
    ONCE M = 15.0
    ONCE E = 1.6
    ONCE Y = 1.0
    ONCE Z = 2.0
    ONCE F = 5.0
    MyAdx= Adx[5] >= 45
    St1  = Supertrend[ E , F ]
    L1  = close > St1
    S1  = close < St1
    MHull  = average[M ,7](close)
    Bullish = MHull > MHull[1] and MHULL[1] < MHULL[2]
    Bearish = MHull < MHull[1] and MHULL[1] > MHULL[2]
     
    IF L1 and Bullish and MyAdx AND Not LongOnMarket THEN
    BUY 0.2 CONTRACT AT market
    SET STOP LOSS Averagetruerange [5](close)*Y
    endif
    
    IF S1 and Bearish and MyAdx AND Not ShortOnMarket THEN
    SELLSHORT 0.2 CONTRACT AT market
    SET TARGET PROFIT Averagetruerange [5](close)*Z
    ENDIF
    set stop ploss 50
    
    0015STHk25-SP.itf
    #261903 quote
    GraHal
    Participant
    Master

    1. Non hai impostato un obiettivo di profitto per i tuoi acquisti/posizioni long… è intenzionale?


    2. In ogni caso, l’unico Stop Loss che funziona è set stop ploss 50, poiché si trova sull’ultima riga di codice e quindi rende superfluo/non attivo qualsiasi Stop Loss precedente.


    I punti 1 e 2 potrebbero essere responsabili di ciò che stai osservando/sperimentando?

    Gaspare and robertogozzi thanked this post
    #261906 quote
    robertogozzi
    Moderator
    Master

    Per le operazioni LONG hai messo, come stop loss:

    SET STOP LOSS Averagetruerange [5](close)*Y
    

    mentre per le operazioni SHORT non l’hai messo.

    In ogni caso hai messo lo stop loss esterno agli IF…ENDIF di entrata:

    set stop ploss 50
    

    che vale per entrami i casi, LOING e SHORT, in quanto viene SEMPRE eseguito, quindi sovrascrive anche quello LONG.

    Inoltre NON hai messo il target profit per i LONG, ma solo per gli SHORT, penso non esca per questo motivo.

    Prova questa versione modificata:

    DEFPARAM CumulateOrders = false
    Defparam Flatbefore= 060000
    Defparam Flatafter = 220000
    ONCE M = 15.0
    ONCE E = 1.6
    ONCE Y = 1.0
    ONCE Z = 2.0
    ONCE F = 5.0
    MyAdx= Adx[5] >= 45
    St1  = Supertrend[ E , F ]
    L1  = close > St1
    S1  = close < St1
    MHull  = average[M ,7](close)
    Bullish = MHull > MHull[1] and MHULL[1] < MHULL[2]
    Bearish = MHull < MHull[1] and MHULL[1] > MHULL[2]
     
    IF L1 and Bullish and MyAdx AND Not LongOnMarket THEN
    BUY 0.2 CONTRACT AT market
    SET STOP LOSS Averagetruerange [5](close)*Y
    SET TARGET PROFIT Averagetruerange [5](close)*Z
    endif
    
    
    IF S1 and Bearish and MyAdx AND Not ShortOnMarket THEN
    SELLSHORT 0.2 CONTRACT AT market
    SET STOP LOSS Averagetruerange [5](close)*Y
    SET TARGET PROFIT Averagetruerange [5](close)*Z
    ENDIF
    //set stop ploss 50
    


    Gaspare and GraHal thanked this post
    #261907 quote
    Gaspare
    Participant
    Veteran

    non capisco perchè il backtesting mi chiude tutte le posizioni positive o negative

    certo non ho il target ma ho inserito un ATR che dovrebbe fare da target….?

    Ho inserito la riga di codice del loss per ridurre lo stop

    Forse sbaglio il codice relativo allo ATR

    #261908 quote
    robertogozzi
    Moderator
    Master

    Questa versione contiene le righe per visualizzare i valori di SL e TP, così puoi verificare meglio se l’ATR funziona come vuoi tu:

    DEFPARAM CumulateOrders = false
    Defparam Flatbefore= 060000
    Defparam Flatafter = 220000
    ONCE M = 15.0
    ONCE E = 1.6
    ONCE Y = 1.0
    ONCE Z = 2.0
    ONCE F = 5.0
    MyAdx= Adx[5] >= 45
    St1  = Supertrend[ E , F ]
    L1  = close > St1
    S1  = close < St1
    MHull  = average[M ,7](close)
    Bullish = MHull > MHull[1] and MHULL[1] < MHULL[2]
    Bearish = MHull < MHull[1] and MHULL[1] > MHULL[2]
     
    IF L1 and Bullish and MyAdx AND Not LongOnMarket THEN
    BUY 0.2 CONTRACT AT market
    SET STOP LOSS Averagetruerange [5](close)*Y
    SL = Averagetruerange [5](close)*Y
    SET TARGET PROFIT Averagetruerange [5](close)*Z
    TP = Averagetruerange [5](close)*Z
    endif
    
    
    IF S1 and Bearish and MyAdx AND Not ShortOnMarket THEN
    SELLSHORT 0.2 CONTRACT AT market
    SET STOP LOSS Averagetruerange [5](close)*Y
    SL = Averagetruerange [5](close)*Y
    SET TARGET PROFIT Averagetruerange [5](close)*Z
    TP = Averagetruerange [5](close)*Z
    ENDIF
    //set stop ploss 50
    graph SL
    graph TP
    
    GraHal and Gaspare thanked this post
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Live non chiude la posizione


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Gaspare @gaspare Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by robertogozzi
1 week, 4 days ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 06/12/2026
Status: Active
Attachments: 1 files
Logo Logo
Loading...