Chiudere definitivamente una strateggia

Forums ProRealTime forum Italiano Supporto ProOrder Chiudere definitivamente una strateggia

Viewing 14 posts - 1 through 14 (of 14 total)
  • #222973

    Che istruzioni dovrei usare per chiudere definitivamente una strategia al raggiungimento di un livello di prezzo?

     

    Grazie

     

     

     

    #222974

    QUIT, questa è l’istruzione per chiudere una strategia ed interromperne l’autotrading.

    Se poi volessi riattivarla basta la la esegui nuovamente in autotrading.

     

    #222975

    Esentato

    https://www.prorealcode.com/documentation/quit/

    1 user thanked author for this post.
    #222977

    Grazie per le risposte, mi andrebbe bene l’esempio 1, ma invece dell’ora vorrei mettere il prezzo. Come devo fare?

    #222982

    Metti il prezzo che desideri al posto dell’ora:

     

    #222987

    Vale anche per la versione short del codice?

    Grazie

    #222988

    Non mi funziona, allego versione long e short, ditemi per cortesia se le istruzioni da me messe sono giuste.

    Grazie

     

    DEFPARAM CumulateOrders = FALSE
    TradingTime=Time>=080000and Time<=180000

    // LONG
    indicator1 = Volume
    indicator2 = ExponentialAverage[14](Volume)
    c1 = (indicator1 >= indicator2)

    IF ( close > open and close[1] > open[1] ) and c1 and TradingTime Then
    BUY 1 CONTRACTS AT MARKET
    endif
    PrezzoUscita= 1.3900
    IF ShortOnMarket AND PrezzoUscita then
    QUIT

     

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

    //trailing stop
    trailingstop = tra

    //resetting variables when no trades are on market
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    priceexit = 0
    endif

    //case SHORT order
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
    if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
    endif
    endif

    //case LONG order
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
    if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE – trailing stop price level
    endif
    endif

    //exit on trailing stop price levels
    if onmarket and priceexit>0 then
    EXITSHORT AT priceexit STOP
    SELL AT priceexit STOP
    endif

     

    DEFPARAM CumulateOrders = False

    TradingTime=Time>=090000and Time<=210000

    // SHORT
    indicator1 = Volume
    indicator2 = ExponentialAverage[14](Volume)
    c1 = (indicator1 >= indicator2)

    IF ( ( close < open and close[1] < open[1] )) and c1 and TradingTime THEN
    SELLSHORT 1 CONTRACTS AT MARKET
    endif
    PrezzoUscita= 1.3500
    IF shortOnMarket AND PrezzoUscita then
    QUIT

     

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

    ENDIF
    //trailing stop
    trailingstop = tra

    //resetting variables when no trades are on market
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    priceexit = 0
    endif

    //case SHORT order
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
    if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
    endif
    endif

    //case LONG order
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
    if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE – trailing stop price level
    endif
    endif

    //exit on trailing stop price levels
    if onmarket and priceexit>0 then
    EXITSHORT AT priceexit STOP
    SELL AT priceexit STOP
    endif

    #222992

    Manca il confronto, con cosa vuoi confrontare il prezzo di uscita? Immagino con CLOSE:

    vale anche per le operazioni LONG.

    #222996

    Grazie sempre gentile.

    #223016

    Scusami Roberto, contrariamente a quando credevo non funziona , praticamente nei backtest  che eseguo, ultimamente sull’argento TF 1 ora , le entrate e le uscite sono determinate dalle date  ma non dal valore che inserisco.

    Ti allego i due codici che uso per vedere dove sbaglio.

    Versione long

    DEFPARAM CumulateOrders = FALSE
    TradingTime=Time>=080000and Time<=180000

    // LONG
    indicator1 = Volume
    indicator2 = ExponentialAverage[14](Volume)
    c1 = (indicator1 >= indicator2)

    IF ( close > open and close[1] > open[1] ) and c1 and TradingTime Then
    BUY 1 CONTRACTS AT MARKET
    endif
    PrezzoUscita =2400
    IF shortOnMarket AND close = PrezzoUscita then
    QUIT
    endif

     

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

     

    //trailing stop
    trailingstop = tra

    //resetting variables when no trades are on market
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    priceexit = 0
    endif

    //case SHORT order
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
    if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
    endif
    endif

    //case LONG order
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
    if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE – trailing stop price level
    endif
    endif

    //exit on trailing stop price levels
    if onmarket and priceexit>0 then
    EXITSHORT AT priceexit STOP
    SELL AT priceexit STOP
    endif

     

    Versione short

     

     

    DEFPARAM CumulateOrders = False

    TradingTime=Time>=090000and Time<=210000

    // SHORT
    indicator1 = Volume
    indicator2 = ExponentialAverage[14](Volume)
    c1 = (indicator1 >= indicator2)

    IF ( ( close < open and close[1] < open[1] )) and c1 and TradingTime THEN
    SELLSHORT 1 CONTRACTS AT MARKET
    endif
    PrezzoUscita= 2150
    IF shortOnMarket AND close = PrezzoUscita then
    QUIT

     

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

    ENDIF
    //trailing stop
    trailingstop = tra

    //resetting variables when no trades are on market
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    priceexit = 0
    endif

    //case SHORT order
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
    if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
    endif
    endif

    //case LONG order
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
    if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE – trailing stop price level
    endif
    endif

    //exit on trailing stop price levels
    if onmarket and priceexit>0 then
    EXITSHORT AT priceexit STOP
    SELL AT priceexit STOP
    endif

    #223138

    Roberto, forse non lo ritieni interessante?

    #223180

    Nella versione LONG devi usare LongOnMarket.

    Questa LONG sul DAX funziona, con il livello che ho indicato:

    anche questa versione SHORT funziona:

    Se vuoi puoi aggiungere il trailing stop, ma con un valore alto, altrimenti entra in funzione quello e difficilmente esce con QUIT. Io ho provato con TRA=100.

    #223197

    Si funziona , ma esce esattamente a quel prezzo, io invece vorrei che uscisse da quel prezzo in su o in giù per la variante short.

    Grazie

     

    #223198

    Risolto grazie.

Viewing 14 posts - 1 through 14 (of 14 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login