STOP e PROFIT diversi lato Long e Short

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #103115 quote
    Giuliano_G
    Participant
    Average
    IF LONGONMARKET THEN
    SET STOP PLOSS MySLL
    SET TARGET PPROFIT MyTPL
    ENDIF
    IF SHORTONMARKET THEN
    SET STOP PLOSS MySLS
    SET TARGET PPROFIT MyTPS
    ENDIF

    Buongiorno a tutti,

    per avere Stop e Profit diversi tra lato long e short ho pensato di scrivere così il codice, il problema è che giustamente verifica di essere LONGONMARKET  o SHORTONMARKET  alla candela successiva, quindi nel caso di un sistema in 1H rimane 1 ora senza stop loss (del Profit mi interessa meno). Come posso risolvere? Grazie

    #103116 quote
    robertogozzi
    Moderator
    Master

    Se non vari il calcolo mentre è a mercato, non è necessario settarli nuovamente ad ogni candela, quindi puoi farlo anche solo quando entri in posizione:

    IF MieCondizioniLong AND Not OnMarket THEN
       BUY 1 CONTRACT AT MARKET
       SET STOP   PLOSS   MySLL
       SET TARGET PPROFIT MyTPL
    ENDIF
    IF MieCondizioniShort AND Not OnMarket THEN
       SELLSHORT 1 CONTRACT AT MARKET
       SET STOP   PLOSS   MySLS
       SET TARGET PPROFIT MyTPS
    ENDIF
    #103119 quote
    Giuliano_G
    Participant
    Average

    In realtà varia perché si adatta all’ATR, questa è porzione completa

    MyATR=(AverageTrueRange[24](close)[1])*10000
    MySLL=MyATR*4
    MyTPL=MyATR*8
    MySLS=MyATR*3
    MyTPS=MyATR*4
    IF LONGONMARKET THEN
    SET STOP PLOSS MySLL
    SET TARGET PPROFIT MyTPL
    ENDIF
    IF SHORTONMARKET THEN
    SET STOP PLOSS MySLS
    SET TARGET PPROFIT MyTPS
    ENDIF
    #103120 quote
    robertogozzi
    Moderator
    Master

    Va bene, basta che aggiungi le due righe per lo SL e TP anche quando entri in posizione.

    Tieni presente che come l’hai messo tu tis viene cambiato ad ogni nuova candela, sia SL che TP.

    #103121 quote
    Giuliano_G
    Participant
    Average

    Sì, l’ho backtestato così, variabile ad ogni candela. Ottimo grazie

    #103199 quote
    Ciao Roberto,
    Tu intendi di aggiungere stop e target quando si entra a mercato come in questo esempio.
    Grazie
    IF MieCondizioniLong AND Not OnMarket THEN
       BUY 1 CONTRACT AT MARKET
       SET STOP   PLOSS   MySLL
       SET TARGET PPROFIT MyTPL
    ENDIF
    IF MieCondizioniShort AND Not OnMarket THEN
       SELLSHORT 1 CONTRACT AT MARKET
       SET STOP   PLOSS   MySLS
       SET TARGET PPROFIT MyTPS
    ENDIF
    
    ATR=(AverageTrueRange[24](close)[1])*10000
    MySLL=MyATR*4
    MyTPL=MyATR*8
    MySLS=MyATR*3
    MyTPS=MyATR*4
    #103208 quote
    robertogozzi
    Moderator
    Master

    Puoi usare entrambi, lo setti quando entri e poi, visto che lo vari candela per candela, lo setti ogni volta.

    #103209 quote

    Grazie

    #104545 quote
    agamennone m
    Participant
    Junior

    ciao,se invece volessi inserire uno stop quando entro long al minimo delle ultime 5 candele che,una volta superato il livello entry cominciasse a funzionare su ATR tipo trailing? Fattibile?

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

STOP e PROFIT diversi lato Long e Short


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Giuliano_G @giuliano_g Participant
Summary

This topic contains 8 replies,
has 4 voices, and was last updated by agamennone m
6 years, 6 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 07/22/2019
Status: Active
Attachments: No files
Logo Logo
Loading...