Scripts di esempio
Collapse
This is a sticky topic.
X
X
-
Nuova domanda per Max appena può...
Nello Script è possibile identificare il Close di una barra di un determinato timeframe?
Come uso l\'istruzione RTH_5MIN ?
GrazieComment
-
Piccolo contributo alla discussione
Un piccolo contributo alla discussione
(ho lasciato tutte le dichiarazioni di variabili, anche quelle non necessarie)
1.aggiungere 5 optioni call e 5 put piu atm alla strategia alle 9:40.
2. scrive valore su fileCodice:uses classes dim z dim controllo dim atmstrike dim under as tsecurity dim price dim underisin dim atmvola dim atmexp dim nextexp,nextexpma,nextexpanno,nextexpnc ,j,i dim atmcall as toption dim calls as toption = [0,0,0,0,0] dim puts as toption = [0,0,0,0,0] dim sommaevolacalls as single = 0 dim sommaevolaputs as single = 0 dim sommavolacalls as single = 0 dim sommavolaputs as single = 0 dim a as double dim strikestep, strikeas dim ore as Word, minuti as Word, secondi as Word, usec as Word dim volacallbs, volaputbs dim pricea As Double, delta As Double, gamma As Double, theta As Double, vega As Double, rho As Double, timeValue As Double, implVolatility As Double dim diffvola dim count = 0 dim ciao as tstringlist = [0,0,0,0,0,0,0,0] dim file as tstringlist dim percorso as string dim anno, mese, giorno under = CurrentStrategy.GetMainUnderlying price = CurrentStrategy.GetMainUnderlyingprice underisin = under.isin count = CurrentStrategy.GetOptionCount file = new TStringList() strikestep = GetNextStrike(underisin,price) - GetPreviousStrike(underisin,price) \'strikestep = intervallo tra strike atmstrike = GetNearestStrike(underisin, price) nextexp = CDate(GetNextExpiry(underisin, now())) if mid(nextexp,2,1)= "/" then nextexp = "0" + left(nextexp,9) else nextexp = left(nextexp,10) end if \'nextexp format mm/gg/aaaa nextexpma = left(nextexp,2) + "-" + right(nextexp,4) \'nextexpma format mm-aaaa DecodeTime(Now(), ore, minuti, secondi, usec) DecodeDate(Now(), anno, mese, giorno) if ore = 9 and minuti<40 then SetPersistentVar(controllo,1) else SetPersistentVar(controllo,0) end if if controllo = 1 then CurrentStrategy.DisableOptionExpiry(nextexp) file.SaveToFile(percorso) for i=0 to 4 step 1 CurrentStrategy.AddParametricOption(underisin,CALL,i-2,0) CurrentStrategy.AddParametricOption(underisin,PUT,i-2,0) next end if \'assegnare le opzioni aggiunte a variabili array: \'nota : getstrikebyindex mi sembra che non funzioni for i = 0 to 4 strikeas = cstr(atmstrike + (i-2)*strikestep) calls[i] = CurrentStrategy.GetByName("C @ "+strikeas+" "+nextexpma) puts[i] = CurrentStrategy.GetByName("P @ "+strikeas+" "+nextexpma) next
Codice:price = CurrentStrategy.GetMainUnderlyingprice z = CStr(giorno) file.LoadFromFile(percorso) file.add(price & " ciao " ) file.SaveToFile(percorso) file.freeE' difficile vedere un gatto nero in una stanza buia, specialmente se non c'è.Comment
-
E' difficile vedere un gatto nero in una stanza buia, specialmente se non c'è.Comment
-
....non si desidera ciò che è facile ottenere (Ovidio)....
Comment
-
Comment
-
Comment
-
ho provato a cancellare tutte le unit presenti nello script dopodichè ne ho generata una nuova in basic, ho fatto copia incolla e poi run.
l\'errore non compare più
ma non so se adesso funziona .
Apo....non si desidera ciò che è facile ottenere (Ovidio)....
Comment
-
I file si possono condividere se si invia in condivisione la strategia su cui è scritto lo script...se corri dietro a due lepri, non ne prendi nemmeno una.Comment
-
Ciao,
in attesa di Max ....... intanto ti rispondo io:
E questo penso che sia soltanto un assaggio!Codice:Dim myUnderlying as TUnderlying Dim myHistoryDataContext as THistoryDataContext Dim myHistoricalData as THistoricalData Dim myDataVectorCLOSE as TDataVector myUnderlying = CurrentStrategy.GetMainUnderlying myHistoryDataContext = myUnderlying.AssertHistory(RTH_5MIN) \'Ottenimento dei dati storici dei CLOSE myHistoricalData = myHistoryDataContext.HistoricalData myDataVectorCLOSE = myHistoricalData.VectorClose \'Metodo alternativo per l\'ottenimento dei dati storici dei CLOSE: \'myDataVectorCLOSE = myHistoryDataContext.GetSerieByName("CLOSE") \'Richiesta di mostrare i valori di alcune proprietà ShowMessage("Ultimo valore in ordine temporale: " & myDataVectorCLOSE.Last) ShowMessage("Penultimo valore in ordine temporale: " & myDataVectorCLOSE.LastClosed) \'A questo punto utilizzando opportunamente le proprietà ed i metodi \'della classe TDataVector (vedere il Manuale !!!!) \'è possibile ottenere altre informazioni.
Comment
-
Comment
-
Grazie Smash! Nel weekend sperimento...Ciao,
in attesa di Max ....... intanto ti rispondo io:
E questo penso che sia soltanto un assaggio!Codice:Dim myUnderlying as TUnderlying Dim myHistoryDataContext as THistoryDataContext Dim myHistoricalData as THistoricalData Dim myDataVectorCLOSE as TDataVector myUnderlying = CurrentStrategy.GetMainUnderlying myHistoryDataContext = myUnderlying.AssertHistory(RTH_5MIN) \'Ottenimento dei dati storici dei CLOSE myHistoricalData = myHistoryDataContext.HistoricalData myDataVectorCLOSE = myHistoricalData.VectorClose \'Metodo alternativo per l\'ottenimento dei dati storici dei CLOSE: \'myDataVectorCLOSE = myHistoryDataContext.GetSerieByName("CLOSE") \'Richiesta di mostrare i valori di alcune proprietà ShowMessage("Ultimo valore in ordine temporale: " & myDataVectorCLOSE.Last) ShowMessage("Penultimo valore in ordine temporale: " & myDataVectorCLOSE.LastClosed) \'A questo punto utilizzando opportunamente le proprietà ed i metodi \'della classe TDataVector (vedere il Manuale !!!!) \'è possibile ottenere altre informazioni.
Comment





Comment