Aiuto alla programmazione
Forums › ProRealTime forum Italiano › Supporto ProOrder › Aiuto alla programmazione
- This topic has 2 replies, 2 voices, and was last updated 3 years ago by
Fabbri Fausto.
-
-
01/18/2022 at 4:40 PM #185847
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 = 173000lv = 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
ENDIFIF DAYOFWEEK = dayExit THEN
IF LONGONMARKET THEN
IF TIME >= timeExit THEN
SELL AT MARKET
ENDIF
ENDIF
ENDIF01/18/2022 at 5:40 PM #185855La 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:
12345678910111213141516171819202122232425262728293031//maximum number of open positionsTimeframe(Daily,UpdateOnClose)ONCE maxPositions = 1//number of RSI periods and oversold level(<=)ONCE periods = 2ONCE level = 20//1=domenica 2=lunedì 3=martedì 4=mercoledì 5=giovedì 6=venerdì 7=sabato//day and time of entryONCE dayEntry = 2ONCE timeEntry = 010000//day and time of exitONCE dayExit = 4ONCE timeExit = 173000lv = RSI[periods](CLOSE)IF DAYOFWEEK = dayEntry THENIF lv <= level THENIF TIME >= timeEntry THENIF COUNTOFPOSITION < maxPositions THENBUY 1 CONTRACTS AT MARKETENDIFENDIFENDIFENDIFTimeframe(default)IF DAYOFWEEK = dayExit THENIF LONGONMARKET THENIF TIME >= timeExit THENSELL AT MARKETENDIFENDIFENDIFIl 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.
01/18/2022 at 6:23 PM #185862Grazie mille Roberto
-
AuthorPosts
