break out candela oraria

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #161225 quote
    Gabriele Battista
    Participant
    Senior

    è possibile costruire un back test che prenda posizione long o short al break out di una candela oraria es. 9-10. grazie

    #161232 quote
    robertogozzi
    Moderator
    Master

    Eccolo:

    IF IntraDayBarIndex = 0 THEN
       Massimo = 0
       Minimo  = 0
    ENDIF
    IF Time = 090000 THEN
       Massimo = high
       Minimo  = low
    ENDIF
    IF Time >= 090000 AND Not OnMarket THEN
       IF close < Massimo THEN
          BUY       1 Contract AT Massimo + (1 * PipSize) STOP
       ENDIF
       IF close > Minimo THEN
          SELLSHORT 1 Contract AT Minimo  - (1 * PipSize) STOP
       ENDIF
    ENDIF
    #161233 quote
    Gabriele Battista
    Participant
    Senior

    Grazie, se volessi inserire un target ed uno stop loss pari al 50% del range come dovrei fare?

    #161234 quote
    robertogozzi
    Moderator
    Master

    Alla fine aggiungi:

    SET STOP   LOSS   (Massimo - Minimo) / 2
    SET TARGET PROFIT (Massimo - Minimo) / 2
    #161262 quote
    Gabriele Battista
    Participant
    Senior

    noto due problemi, dovuti anche alla mia non chiarezza: entra ed esce più volte in giornata mentre vorrei una sola operazione (la prima dal lato che rompe), altra che breakka la candela delle 8 anzichè quella delle 9. ti allego la lista degli ordini del 3/2 ad esempio (la candela oraria delle 8 ha min 13885 e max 13951, lo stop loss ed il take profit sono (max-min)/5) Allego anche il codice che ho modificato nello Stop e Target e provato ad ottimizzare al valore n=5. Ti ringrazio per la disponibilità e la pazienza

    IF IntraDayBarIndex = 0 THEN
    Massimo = 0
    Minimo  = 0
    ENDIF
    IF Time = 090000 THEN
    Massimo = high
    Minimo  = low
    ENDIF
    IF Time >= 090000 AND Not OnMarket THEN
    IF close < Massimo THEN
    BUY       1 Contract AT Massimo + (1 * PipSize) STOP
    ENDIF
    IF close > Minimo THEN
    SELLSHORT 1 Contract AT Minimo  - (1 * PipSize) STOP
    ENDIF
    ENDIF
    SET STOP LOSS (Massimo - Minimo) / n
    SET TARGET PROFIT (Massimo - Minimo) / n
    

     

    Data Tipo Prezzo Qtà Valorizzazione
    3-feb-2021 20.00.00 Vendita (profit) 13.969 1 349.225,00
    3-feb-2021 19.00.00 Acquisto (entry) 13.952 1 348.800,00
    3-feb-2021 17.00.00 Vendita (loss) 13.935 1 348.375,00
    3-feb-2021 16.00.00 Acquisto (entry) 13.952 1 348.800,00
    3-feb-2021 15.00.00 Acquisto (profit) 13.867 1 346.675,00
    3-feb-2021 15.00.00 Vendita (entry) 13.884 1 347.100,00
    3-feb-2021 10.00.00 Acquisto (loss) 13.901 1 347.525,00
    3-feb-2021 10.00.00 Vendita (entry) 13.884 1 347.100,00
    3-feb-2021 9.00.00 Vendita (profit) 13.969 1 349.225,00
    3-feb-2021 9.00.00 Acquisto (entry) 13.952 1 348.800,00
    #161264 quote
    robertogozzi
    Moderator
    Master

    L’ora puoi cambiarla come preferisci, dove c’è 090000 ci scrivi 080000 o qualunque altra ed è fatto.

    Per limitare ad una sola operazione giornaliera aggiungi, all’inizio (o comunque prima di BUY/SELLSHORT):

    Otd = (Barindex - TradeIndex(1) > IntradayBarIndex)

    poi aggiungi AND Otd alle condizioni della riga 9:

    IF Time >= 090000 AND Not OnMarket AND Otd THEN
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

break out candela oraria


ProOrder: Trading Automatico & Backtesting

New Reply
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by robertogozzi
4 years, 12 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 02/12/2021
Status: Active
Attachments: No files
Logo Logo
Loading...