Topics
Replies
Spotware
16 Dec 2013, 11:16
The "index" that is the parameter to the Calculate method, is the index of the series that the instance is attached to. The series of other timeframes / symbols have different indexes. So, to get the index of a specific series you would need to use a method such as GetIndexByTime and GetindexbyExactTime.
example:
MarketSeries series; protected override void Initialize() { series = MarketData.GetSeries(Symbol, TimeFrame.Daily); } public override void Calculate(int index) { var index2 = series.OpenTime.GetIndexByExactTime(MarketSeries.OpenTime.LastValue); if (index2 > 0) var close = series.Close[index2]; }
The difference between the two is that GetIndexByTime returns the closest index to the open time, whereas the GetindexbyExactTime will only return an index if there is one at the exact time and will return -1 otherwise.
@Spotware
Spotware
13 Dec 2013, 16:45
RE: RE:
hichem said:
Wouldn't that expose .algo files to including malware ? I mean anyone can include anything in the .algo files and since the content will not be inspectable, a developer can put malware in the .algo file and no one can discover it.
Spotware said:
Starting from the next version algo files will be protected. Also, algo files will be automatically installed, so it will be easier to distribute them.
All referenced dll's will be included into the algo file.
If the source code is attached it is recommended to read it before running.
We recommend not to run .algo files without source code from not trusted publishers.
@Spotware
Spotware
13 Dec 2013, 14:44
RE: RE:
ErikD said:
Does this always have to be done when dealing with calculations that need the past value of it self in order to complete?
Yes. The data series will be populated with NAN initially, so if you are trying to access past values they should contain some value such as zero or the closing price.
@Spotware
Spotware
13 Dec 2013, 09:25
RE:
lec0456 said:
isn't the code in the example wrong? It reads:
foreach (var position in Positions) { ClosePosition(positions); }There is o variable positions, right? shouldn't it be:
foreach (var position in Positions) { ClosePosition(position); }???
Yes, thank you for pointing that out.
@Spotware
Spotware
17 Dec 2013, 09:11
RE:
lec0456 said:
Yes that is correct.
@Spotware