So I assembled the history in UTC, single file per asset, that has a mix of daily and 1-minute bars, with the timestamp at the end of the bar as written in the manual.
I've been reading about it and I am still very confused on how to set up the script to make use of this data. With the below setup, I get "
SMA Lookback period exceeded by 286360 bars" error. I am guessing it's expecting 200*1440 minute bars before the StartDate. Do I need to make my own
bar() function to make use of this data properly?
The data is stored like this. I don't need empty bars where there is no data, correct?
2018.07.31 13:33 190.02 190.31 189.95 190.21 0 834 // MINUTE
2018.07.31 13:32 190.31 190.34 189.91 190 0 1233 // MINUTE
2018.07.31 13:31 190.34 190.5 190 190.3 0 4165 //MINUTE
2018.07.30 20:00 191.98 192.2 189.07 189.91 0 1.59208E+07 //DAILY
2018.07.27 20:00 194.93 195.19 190.21 190.98 0 1.41448E+07 //DAILY
2018.07.26 20:00 194.61 195.96 193.61 194.21 0 1.43066E+07 //DAILY
The assets file first has a DUMMY asset, then another entry for AAPL
The very basic script where I am opening a long trade on a specific date that has daily resolution data:
function run() {
BarPeriod = 1;
StartDate = 20130301;
LookBack = 200*1440; // enough for the 200day SMA
LifeTime = 448; // automatically close trades at the end of the day
assetList("History\AssetsEarnings.csv");
History = "m.t6";
asset(""); // not sure if I need the DUMMY here...
asset("AAPL");
TimeFrame = 1440; // daily SMA
vars dailyPrices = series(priceClose());
vars smaDaily = series(SMA(dailyPrices, 200));
// buy after open on 2018-07-31... the day that has minute resolution data
if(year(0)==2018 && month(0)==7 && day(0)==31) {
TimeFrame = 1; // run on minute intervals during trading
if(ltod(ET, 0)==931 && NumOpenLong == 0) {
enterLong();
}
}
else {
TimeFrame = 1440;
}