BACKTEST GIORNI SETTIMANA

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #238915 quote
    frax81frax81
    Participant
    New

    Salve, premetto di non avere dimestichezza con la programmazione ma di aver provato comunque a scrivere il backtest desiderato, con scarsi risultati.

    Ho ad oggi la versione free di prorealtime e volevo fare un backtest che mi restituisca una statistica EOD dell’andamento dei giorni della settimana, delle settimane nell’anno e dei mesi dell’anno.

    Per la serie:

    copro in apertura lunedì, vendo alla chiusura lunedì.

    —–

    compro lunedì in apertura vendi venerdì in chiusura la prima settimana del mese di gennaio

    —–

    compro all’apertura il primo gennaio, vendo alla chiusura il 31 gennaio

    grazie a chi vorrà aiutarmi

    robertogozzi thanked this post
    #238944 quote
    Iván GonzálezIván González
    Moderator
    Legend

    Ciao bene. I robot non possono assumere posizioni alla chiusura del mercato. Possono assumere posizioni solo all'apertura o durante la negoziazione della candela tramite ordine stop/limit. Puoi avvicinarti all'uscita alla chiusura della candela, ad esempio abbassando i tempi a candele da 1 minuto. Il problema è che perdi molta storia. In ogni caso, non potrai farlo con i dati EOD. Se vuoi davvero controllare gli output alla chiusura, ti direi di farlo con Excel.

    #238966 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Puoi provare questo, ottimizzando la variabile TIPO (riga 1), potrai provare quale delle 3 strategie da risultati migliori:

    Tipo = 3
    //
    // 1 - copro in apertura lunedì, vendo alla chiusura lunedì.
    //
    IF Tipo = 1 THEN
       IF (DayOfWeek = 1) AND (DayOfWeek <> DayOfWeek[1]) AND Not OnMarket THEN
          BUY 1 CONTRACT AT MARKET
       ENDIF
       IF (DayOfWeek >= 2) AND LongOnMarket THEN
          SELL 1 CONTRACT AT MARKET
       ENDIF
    ENDIF
    //
    // 2 - compro lunedì in apertura vendi venerdì in chiusura la prima settimana del mese
    //     di gennaio
    //
    IF Tipo = 2 THEN
       IF (DayOfWeek = 1) AND (DayOfWeek <> DayOfWeek[1]) AND (Month <> Month[1]) AND (Month = 1) AND Not OnMarket THEN
          BUY 1 CONTRACT AT MARKET
       ENDIF
       IF ((OpenDayOfWeek >= 5) OR (DayOfWeek < DayOfWeek[1])) AND LongOnMarket THEN
          SELL 1 CONTRACT AT MARKET
       ENDIF
    ENDIF
    //
    // 3 - Compro all’apertura il primo gennaio, vendo alla chiusura il 31 gennaio
    //
    IF Tipo = 3 THEN
       IF (Day >= 1) AND (Month = 1) AND Not OnMarket THEN
          BUY 1 CONTRACT AT MARKET
       ENDIF
       IF (((Day = 31) AND (Month = 1)) OR (Month >= 2))  AND LongOnMarket THEN
          SELL 1 CONTRACT AT MARKET
       ENDIF
    ENDIF
    Iván González thanked this post
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

BACKTEST GIORNI SETTIMANA


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
frax81 @frax81 Participant
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by robertogozzirobertogozzi
1 year, 11 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 10/12/2024
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...