Migliore/Peggiore mese per entrare

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #165966 quote
    abd78abd78
    Participant
    Veteran
    defparam cumulateorders=false
    c=1
    
    // Condizioni per entrare su posizioni long
    IF dayofweek=g  THEN
    BUY c CONTRACTS AT MARKET
    ENDIF
    
    // Condizioni per uscire da posizioni long
    If LongOnMarket THEN
    SELL AT MARKET
    ENDIF
    

    Vorrei cambiare la condizione invece che mettere i giorni della settimana (da 1 a 5) farlo mensile.

    Come faccio a farlo con il mensile? quindi (1-12)(gennaio-dicembre)?

    #165968 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Ecco qui (è una versione aggiornata del codice che puoi trovare qui https://www.prorealcode.com/topic/time-and-day-conditions/), a cui ho aggiunto poche righe per una semplice entrata all’incrocio rialzista del prezzo con una media semplice a 20 periodi:

    DEFPARAM CumulateOrders = FALSE
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ONCE startT = 000000                                                          //Starting TIME
    ONCE endT   = 240000                                                          //Ending TIME
    TimeRef     = OpenTime                                                        //can be replaced by TIME, if needed
    DayRef      = OpenDayOfWeek                                                   //can be replaced by DAYOFWEEK, if needed
    MonthRef    = OpenMonth                                                       //can be replaced by MONTH, if needed
    //----------------------------------------------------------------------------------------------------------------------
    td0         = 0 AND DayRef = 0 AND TimeRef >= startT AND TimeRef <= endT      //Sunday
    td1         = 1 AND DayRef = 1 AND TimeRef >= startT AND TimeRef <= endT      //Monday
    td2         = 1 AND DayRef = 2 AND TimeRef >= startT AND TimeRef <= endT      //Tuesday
    td3         = 1 AND DayRef = 3 AND TimeRef >= startT AND TimeRef <= endT      //Wednesday
    td4         = 1 AND DayRef = 4 AND TimeRef >= startT AND TimeRef <= endT      //Thursday
    td5         = 1 AND DayRef = 5 AND TimeRef >= startT AND TimeRef <= endT      //Friday
    td6         = 0 AND DayRef >=6 AND TimeRef >= startT AND TimeRef <= endT      //Saturday (or else ?!)
    tdCond      = td0 OR td1 OR td2 OR td3 OR td4 OR td5 OR td6                               //Time & Day condition
    //----------------------------------------------------------------------------------------------------------------------
    m1          = 1 AND MonthRef = 1                                              //January
    m2          = 1 AND MonthRef = 2                                              //February
    m3          = 1 AND MonthRef = 3                                              //March
    m4          = 1 AND MonthRef = 4                                              //April
    m5          = 1 AND MonthRef = 5                                              //May
    m6          = 1 AND MonthRef = 6                                              //June
    m7          = 1 AND MonthRef = 7                                              //July
    m8          = 1 AND MonthRef = 8                                              //August
    m9          = 1 AND MonthRef = 9                                              //September
    m10         = 1 AND MonthRef = 10                                             //October
    m11         = 1 AND MonthRef = 11                                             //November
    m12         = 1 AND MonthRef = 12                                             //December
    mCond       = m1 OR m2 OR m3 OR m4 OR m5 OR m6 OR m7 OR m8 OR m9 OR m10 OR m11 OR m12     //Month condition
    //----------------------------------------------------------------------------------------------------------------------
    tdmCond     = tdCond AND mCond                                                            //Time & Day & Month condition
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    IF close CROSSES OVER Average[20,0](close) AND Not OnMarket AND tdmCond THEN
       BUY 1 Contract AT Market
    ENDIF
    SET TARGET pPROFIT 100
    SET STOP   pLOSS   100

    Ovviamente potrai cambiare gli orari di trading (adesso è tutto il giorno, dalle 0 alle 24, da indicare sempre con 6 cifre).

    Per DEselezionare i giorni della settimana ed i mesi basta che dove c’è “= 1” (nella prima parte dove viene assegnato il valore alla variabile) ci metti “= 0“, o viceversa per selezionarli.

    #165970 quote
    abd78abd78
    Participant
    Veteran

    td7 e td8 come le imposto?

    Comunque volevo semplicemente visualizzare una lista dei mesi migliori e peggiori.

    (esempio con l’oro miglior giorno settimana per andare long è il venerdì)

    migliorgiornosettimana.png migliorgiornosettimana.png
    #165978 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    td7 e td8 li ho cancellati poco dopo. Non servono.

    Allora basta che all tua riga 5 scrivi Month al posto di DayOfWeek e G dovrà contenere il mese scelto di volta in volta.

    abd78 thanked this post
    #165980 quote
    abd78abd78
    Participant
    Veteran
    #165984 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Così va bene, ti aprirà posizioni solo per il mese di Gennaio.

    Poi lo cambi in 2 per Febbraio e così via.

    abd78 thanked this post
    #166106 quote
    MauroProMauroPro
    Participant
    Veteran

    Ciao Roberto, sai quale può essere il motivo per cui inserendo il tuo codice nel mio TS, salta completamente un operazione: giovedi 1 aprile aperta alle 001500 e chiusa alle 022400?

    #166118 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Posta il tuo codice,

    #166121 quote
    MauroProMauroPro
    Participant
    Veteran

    Come devo impostare il tuo codice per ottenerne uno equivalente a questo?

    DEFPARAM Flatbefore = 000000
    DEFPARAM Flatafter = 215700
    limitHour = time<213000

    Ho provato questo ma su 120 k ci sono 10 operazioni in meno

    DEFPARAM Flatafter = 215700
    limitHour = time<213000
    
    //-------------------------------------------------------------------------------------
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ONCE startT = 0000000                                                         //Starting TIME
    ONCE endT   = 2157000                                                         //Ending TIME
    TimeRef     = OpenTime                                                        //can be replaced by TIME, if needed
    DayRef      = OpenDayOfWeek                                                   //can be replaced by DAYOFWEEK, if needed
    MonthRef    = OpenMonth                                                       //can be replaced by MONTH, if needed
    //----------------------------------------------------------------------------------------------------------------------
    td0         = 0 AND DayRef = 0 AND TimeRef >= startT AND TimeRef <= endT      //Sunday
    td1         = 1 AND DayRef = 1 AND TimeRef >= startT AND TimeRef <= endT      //Monday
    td2         = 1 AND DayRef = 2 AND TimeRef >= startT AND TimeRef <= endT      //Tuesday
    td3         = 1 AND DayRef = 3 AND TimeRef >= startT AND TimeRef <= endT      //Wednesday
    td4         = 1 AND DayRef = 4 AND TimeRef >= startT AND TimeRef <= endT      //Thursday
    td5         = 1 AND DayRef = 5 AND TimeRef >= startT AND TimeRef <= endT      //Friday
    td6         = 0 AND DayRef >=6 AND TimeRef >= startT AND TimeRef <= endT      //Saturday (or else ?!)
    tdCond      = td0 OR td1 OR td2 OR td3 OR td4 OR td5 OR td6                               //Time & Day condition
    //----------------------------------------------------------------------------------------------------------------------
    m1          = 1 AND MonthRef = 1                                              //January
    m2          = 1 AND MonthRef = 2                                              //February
    m3          = 1 AND MonthRef = 3                                              //March
    m4          = 1 AND MonthRef = 4                                              //April
    m5          = 1 AND MonthRef = 5                                              //May
    m6          = 1 AND MonthRef = 6                                              //June
    m7          = 1 AND MonthRef = 7                                              //July
    m8          = 1 AND MonthRef = 8                                              //August
    m9          = 1 AND MonthRef = 9                                              //September
    m10         = 1 AND MonthRef = 10                                             //October
    m11         = 1 AND MonthRef = 11                                             //November
    m12         = 1 AND MonthRef = 12                                             //December
    mCond       = m1 OR m2 OR m3 OR m4 OR m5 OR m6 OR m7 OR m8 OR m9 OR m10 OR m11 OR m12     //Month condition
    //----------------------------------------------------------------------------------------------------------------------
    tdmCond     = tdCond AND mCond                                                            //Time & Day & Month condition
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    #166130 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Non ho capito la relazione tra i mesi migliori/peggiori e limithour.

    #166132 quote
    MauroProMauroPro
    Participant
    Veteran

    limitHour si può togliere, ma i codici restano differenti

    #166137 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Alle righe 6 e 7 c’è uno zero di troppo.

    Con DEFPARAM il mio codice non c’entra niente.

    Ho postato quel codice perché volevi selezionare i mesi.

    Non capisco cosa ha a che fare tutto quello che hai scritto dopo con il tuo primo post.

Viewing 12 posts - 1 through 12 (of 12 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

Migliore/Peggiore mese per entrare


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
abd78 @fede9483 Participant
Summary

This topic contains 11 replies,
has 3 voices, and was last updated by robertogozzirobertogozzi
5 years, 6 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 04/01/2021
Status: Active
Attachments: 2 files
ProRealCode ProRealCode
Loading...