Aiuto alla programmazione

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #185847 quote
    Fabbri Fausto
    Participant
    New

    Ho fatto un programmino per operare con barre a 1 giorno su SPTRD.

    Entro a mercato long un giorno della settimana a un certo time e ad un certo livello di RSI ed esco uno dei giorni successivi a un certo time.

    Questa sarebbe la mia intenzione, ma il programma non funziona.

    Provato su 200000 barre, entra a mercato una sola volta e non esce più.

    Da quello che penso, credo di aver sbagliato qualcosa nell’indicazione o nell’uso di time, ma non ho capito perchè e non trovo una soluzione.

    Posto il programmino e chiedo un aiuto, grazie.

    //maximum number of open positions
    ONCE maxPositions = 1
    //number of RSI periods and oversold level(<=)
    ONCE periods = 2
    ONCE level = 20
    //1=domenica 2=lunedì 3=martedì 4=mercoledì 5=giovedì 6=venerdì 7=sabato
    //day and time of entry
    ONCE dayEntry = 2
    ONCE timeEntry = 010000
    //day and time of exit
    ONCE dayExit = 4
    ONCE timeExit = 173000

    lv = RSI[periods](CLOSE)

    IF DAYOFWEEK = dayEntry THEN
    IF lv <= level THEN
    IF TIME >= timeEntry THEN
    IF COUNTOFPOSITION < maxPositions THEN
    BUY 1 CONTRACTS AT MARKET
    ENDIF
    ENDIF
    ENDIF
    ENDIF

    IF DAYOFWEEK = dayExit THEN
    IF LONGONMARKET THEN
    IF TIME >= timeExit THEN
    SELL AT MARKET
    ENDIF
    ENDIF
    ENDIF

    #185855 quote
    robertogozzi
    Moderator
    Master

    La prossima volta dai un titolo significativo al tuo argomento. Descrivi la tua domanda o l’oggetto nel titolo. Non utilizzare titoli privi di significato come “Aiuto per la codifica”.
    Adesso l’ho cambiato io.
    Grazie 🙂

    Perché le strategie vengono eseguite sempre e solo alla chiusura di ogni candela, per cui sul Giornaliero alle ore 00:00 (e 01:00 con l’ora legale), quindi le ore 173000 non potranno essere mai rilevate (e l’operazione resta aperta).

    Devi cambiare orario per la chiusura dell’operazione, oppure usare un time frame diverso, oppure (credo sia la soluzione migliore) utilizzare il supporto MTF che ti consente di usare più time frame (se cerchi MTF nel sito, troverai molte indicazioni).

    Questa è la versione MTF:

    //maximum number of open positions
    Timeframe(Daily,UpdateOnClose)
    ONCE maxPositions = 1
    //number of RSI periods and oversold level(<=)
    ONCE periods = 2
    ONCE level = 20
    //1=domenica 2=lunedì 3=martedì 4=mercoledì 5=giovedì 6=venerdì 7=sabato
    //day and time of entry
    ONCE dayEntry = 2
    ONCE timeEntry = 010000
    //day and time of exit
    ONCE dayExit = 4
    ONCE timeExit = 173000
    lv = RSI[periods](CLOSE)
    IF DAYOFWEEK = dayEntry THEN
       IF lv <= level THEN
          IF TIME >= timeEntry THEN
             IF COUNTOFPOSITION < maxPositions THEN
                BUY 1 CONTRACTS AT MARKET
             ENDIF
          ENDIF
       ENDIF
    ENDIF
    Timeframe(default)
    IF DAYOFWEEK = dayExit THEN
       IF LONGONMARKET THEN
          IF TIME >= timeExit THEN
             SELL AT MARKET
          ENDIF
       ENDIF
    ENDIF

    Il time frame di default è quello che deve essere sul grafico (sempre quello più piccolo) e le candele devono aprire/chiudere all’ora desiderata. Puoi usare il 30 minuti, ma andrebbe bene anche 15 minuti (non 20 minuti), 10 minuti, 5 minuti, 1 minuto.

    #185862 quote
    Fabbri Fausto
    Participant
    New

    Grazie mille Roberto

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

Aiuto alla programmazione


ProOrder: Trading Automatico & Backtesting

New Reply
Author
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Fabbri Fausto
4 years, 2 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 01/18/2022
Status: Active
Attachments: No files
Logo Logo
Loading...