Aiuto alla programmazione
- This topic has 2 replies, 2 voices, and was last updated 3 years ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
Forums › ProRealTime forum Italiano › Supporto ProOrder › Aiuto alla programmazione
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
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
//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.
Grazie mille Roberto