orari di apertura posizioni errati

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #154437 quote
    leo di mennoleo di menno
    Participant
    Average

    salve, qualcuno mi saprebbe dire perchè il prorealtime  mi apre le posizionio in orari totalmente differenti da quelli da me indicati? grazie a tutti per il supporto

    il codice è il seguente

    defparam cumulateorders=false
    time1=120000
    time2=010000
    time3=160000
    time4=070000
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0 OR OpenDayOfWeek = 1 OR OpenDayOfWeek = 2
    IF NOT LongOnMarket and time1 AND  dayofweek=3 or dayofweek=4 or dayofweek=5 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    IF longonmarket and time2 THEN
    SELL 1 CONTRACT AT MARKET
    ENDIF
    IF not longonmarket and time2 and dayofweek=5 THEN
    SELL 1 CONTRACT AT MARKEt
    ENDIF
    //ribassista
    if not shortonmarket and  dayofweek=1 or dayofweek=5 and time2 then
    sellshort 1 CONTRACT at market
    endif
    if shortonmarket and dayofweek=1 or dayofweek=5 and time1 then
    exitshort at market
    endif
    if not shortonmarket and dayofweek=2 or dayofweek=4 and time4 then
    sellshort 1 CONTRACT at market
    endif
    if shortonmarket and dayofweek=2 or dayofweek=4 and time4 then
    exitshort at market
    endif
    
    #154438 quote
    leo di mennoleo di menno
    Participant
    Average

    la stringa daysforbiddenentry andava inibita, ho sbagliato a copiare, non tenetene conto

    #154450 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Perché alle righe 2-5 assegni un valore semplicemente, per cui sono SEMPRE vere.

    Trasformale in:

    time1 = time = 120000 //OpenTime
    time2 = time = 010000 //OpenTime
    time3 = time = 160000 //OpenTime
    time4 = time = 070000 //OpenTime
    #154774 quote
    leo di mennoleo di menno
    Participant
    Average

    ciao, intanto grazie per la delucidazione tuttavia nonostante abbia fatto la modifica descritta il prt continua ad aprire e chiudere posizioni quando vuole, allego schermata posizioni chiuse su crude oil ad 1 ora

    IMG_20201221_205103-scaled.jpg IMG_20201221_205103-scaled.jpg
    #154776 quote
    leo di mennoleo di menno
    Participant
    Average

    il programma utilizzato è il seguente

    defparam cumulateorders=false
    time1=time=120000
    time2=time=010000
    time3=time=160000
    time4=time=070000
    IF NOT LongOnMarket and time1 AND  dayofweek=3 or dayofweek=4 or dayofweek=5 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    IF longonmarket and time2 THEN
    SELL 1 CONTRACT AT MARKET
    ENDIF
    IF not longonmarket and time2 and dayofweek=5 THEN
    SELL 1 CONTRACT AT MARKEt
    ENDIF
    //ribassista
    if not shortonmarket and  dayofweek=1 or dayofweek=5 and time2 then
    sellshort 1 CONTRACT at market
    endif
    if shortonmarket and dayofweek=1 or dayofweek=5 and time1 then
    exitshort at market
    endif
    if not shortonmarket and dayofweek=2 or dayofweek=4 and time4 then
    sellshort 1 CONTRACT at market
    endif
    if shortonmarket and dayofweek=2 or dayofweek=4 and time4 then
    exitshort at market
    endif
    
    #154812 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    C’era anche un errore nelle precedenze degli operatori logici; è sempre meglio mettere le parentesi per indicare quale deve essere la precedenza tra gli operatori, specialmente quando ce ne sono vari su una stessa riga:

    defparam cumulateorders=false
    time1=time=120000
    time2=time=010000
    time3=time=160000
    time4=time=070000
    IF (NOT LongOnMarket) and time1 AND  (dayofweek=3 or dayofweek=4 or dayofweek=5) THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    IF longonmarket and time2 THEN
    SELL 1 CONTRACT AT MARKET
    ENDIF
    IF (not longonmarket) and time2 and dayofweek=5 THEN
    SELL 1 CONTRACT AT MARKEt
    ENDIF
    //ribassista
    if (not shortonmarket) and  (dayofweek=1 or dayofweek=5) and time2 then
    sellshort 1 CONTRACT at market
    endif
    if shortonmarket and (dayofweek=1 or dayofweek=5) and time1 then
    exitshort at market
    endif
    if (not shortonmarket) and (dayofweek=2 or dayofweek=4) and time4 then
    sellshort 1 CONTRACT at market
    endif
    if shortonmarket and (dayofweek=2 or dayofweek=4) and time4 then
    exitshort at market
    endif
    #154845 quote
    leo di mennoleo di menno
    Participant
    Average

    ok, quindi la priorità è la seguente operazioni fuori dalla parentesi

    operazioni dentro

    e se volessi aggiungere anche una limitazione dell’operatività legata ai mesi? scrivo dentro la parentesi dei giorni oppure a parte? grazie

    #154850 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    No, è l’opposto, come in qualunque espressione.

    Le parentesi servono per cambiare l’ordine di precedenza, assegnandogli la priorità.

    In 3 + 1 * 4 la moltiplicazione ha la precedenza, se vuoi darla all’addizione devi metterla tra parentesi (3 + 1) * 4, nel primo caso il risultato è 7, nel secondo è 16.

    #154853 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Per i mesi, se non devi legarli ad altro mettili al di fuori. Meglio se li metti all’interno di proprie parentesi.

    #154877 quote
    leo di mennoleo di menno
    Participant
    Average

    devo comunque aggiungerli anche ai giorni della settimana, quindi suppongo che if (not longonmarket) and time1 and (dayofweek=3 or dayofweek=5) and (months=1 or months=6) then………… ho scritto months ma in realtà non so il comando giusto, ho cercato in giro ma trovo sempre riferimento ai giorni

    #154892 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Qui puoi trovare tutte le istruzioni e costanti https://www.prorealcode.com/prorealtime-documentation/

    #155051 quote
    leo di mennoleo di menno
    Participant
    Average

    salve, dopo aver modificato (spero correttamente il programma) funziona ma comunque con qualche errore

    mi spiego meglio

    il giorno 04/10/2016 entra short ed esce il giorno 5/10/2016 alle 16, questo orario è usato solo per le operazioni long e comunque solo per il venerdi…dayofweek=5, come mai questo errore? secondo me ce ne sono anche altri , cosa è scritto male? posto sia il codice che la lista di posizioni. grazie

    defparam cumulateorders=false
    time1=time=120000
    time2=time=010000
    time3=time=160000
    time4=time=070000
    //daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0 OR OpenDayOfWeek = 1 OR OpenDayOfWeek = 2
    IF (NOT LongOnMarket) and (month>=1 and month<=4) and time1 AND  (dayofweek=3 or dayofweek=4 or dayofweek=5) THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    IF longonmarket and time2 THEN
    SELL 1 CONTRACT AT MARKET
    ENDIF
    IF longonmarket and time3 and dayofweek=5 THEN
    SELL 1 CONTRACT AT MARKEt
    ENDIF
    //ribassista
    if (not shortonmarket) and (month>=7 and month<=12) and  (dayofweek=1 or dayofweek=5) and time2 then
    sellshort 1 CONTRACT at market
    endif
    if shortonmarket and (dayofweek=1 or dayofweek=5) and time1 then
    exitshort at market
    endif
    if (not shortonmarket) and (month>=10 and month<=11) and (dayofweek=2 or dayofweek=4) and time4 then
    sellshort 1 CONTRACT at market
    endif
    if shortonmarket and (dayofweek=2 or dayofweek=4) and time4 then
    exitshort at market
    endif
    set stop loss 127
    
    #155052 quote
    leo di mennoleo di menno
    Participant
    Average

    ecco uno degli errori(presunti)

    IMG_20201223_221548.jpg IMG_20201223_221548.jpg
    #155071 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Per fare una prova occorre sapere su quale strumento e TF l’hai usato.

    Ad ogni modo aggiungi queste righe alla fine del codice e guarda nella finestra delle variabili, alla fine del backtest, quali valori hanno candela per candela che ti risulti errata:

    graph time1
    graph time2
    graph time3
    graph time4
    graph dayofweek
    graph month
    #155492 quote
    leo di mennoleo di menno
    Participant
    Average

    grazie per le info, una delucidazione: come si traduce questa stringa(tradestation) per calcolare lo stop loss con il prorealtime? grazie

    if mp=0  then value1=c*bigpointvalue*0.03;

    setstoploss(value1);

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

orari di apertura posizioni errati


ProOrder: Trading Automatico & Backtesting

New Reply
Author
Summary

This topic contains 15 replies,
has 2 voices, and was last updated by robertogozzirobertogozzi
5 years, 9 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 12/19/2020
Status: Active
Attachments: 2 files
ProRealCode ProRealCode
Loading...