Posted By: gtell
Exporting data from multiple timeframe - 04/21/17 08:28
Dear all,
dear jcl,
I have a question regarding multiple timeframe indicator.
I am still using Zorro 1.50.
Suppose that I want to export the value of Alma indicator with a lag of 3 bars.
The following script does the job:
the following are the first lines of the export:
it looks good.
Now, suppose that I want to add the value of an indicator calculated on a different timeframe.
What I expect is that the output starts from the same date and I should have 3 more columns. The following is the script:
Basically this script export the value of lagged alma in the 60 minutes timeframe and the value of price change in 5 minutes timeframe.
The output is the following:
So the question is: why it does not start from January 3th?
Thanks for your time in reading this.
Cheers.
dear jcl,
I have a question regarding multiple timeframe indicator.
I am still using Zorro 1.50.
Suppose that I want to export the value of Alma indicator with a lag of 3 bars.
The following script does the job:
Code:
function run() { StartDate = 20160101; EndDate = 20161231; BarPeriod = 60; LookBack = 200; set(RULES); set(LOGFILE); set(PLOTNOW); Spread = RollLong = RollShort = Commission = Slippage = 0; char line[300]; string Name = strf("DataTestMF2_%s%s.csv", strmid(Asset,0,3), strmid(Asset,4,3)); vars CLOSE = series(priceClose()); var alma = scale(ALMA(CLOSE,10),100)/100; vars ALMA = series(alma); if(is(INITRUN)) { file_delete(Name); file_write(Name,"Date, Open, High, Low, Close, ALMA",0); } if(!is(LOOKBACK)) { sprintf(line, "n%04i-%02i-%02i %02i:%02i, %.5f, %.5f, %.5f, %.5f, %.5f", year(),month(),day(),hour(),minute(), priceOpen(),priceHigh(),priceLow(),priceClose(),ALMA[3]); if(frame(0)) file_append(Name, line); } }
the following are the first lines of the export:
Code:
Date, Open, High, Low, Close, ALMA 2016-01-03 23:00, 1.08770, 1.08792, 1.08672, 1.08675, -0.54380 2016-01-04 00:00, 1.08658, 1.08675, 1.08458, 1.08544, -0.57637 2016-01-04 01:00, 1.08565, 1.08580, 1.08435, 1.08461, -0.57091 2016-01-04 02:00, 1.08463, 1.08621, 1.08273, 1.08599, -0.55041 2016-01-04 03:00, 1.08626, 1.08760, 1.08588, 1.08721, -0.53313 2016-01-04 04:00, 1.08729, 1.08733, 1.08672, 1.08722, -0.54062 2016-01-04 05:00, 1.08725, 1.08838, 1.08698, 1.08793, -0.57339 2016-01-04 06:00, 1.08792, 1.09053, 1.08739, 1.08964, -0.58233 2016-01-04 07:00, 1.08964, 1.09028, 1.08843, 1.08920, -0.54234 2016-01-04 08:00, 1.08957, 1.09207, 1.08820, 1.09127, -0.48632 2016-01-04 09:00, 1.09139, 1.09466, 1.09107, 1.09255, -0.43851 2016-01-04 10:00, 1.09251, 1.09331, 1.09129, 1.09307, -0.38145 2016-01-04 11:00, 1.09337, 1.09363, 1.09055, 1.09064, -0.31208 2016-01-04 12:00, 1.09059, 1.09204, 1.08976, 1.09187, -0.24255 2016-01-04 13:00, 1.09178, 1.09252, 1.08966, 1.09029, -0.14962 2016-01-04 14:00, 1.09012, 1.09051, 1.08461, 1.08534, -0.07119 2016-01-04 15:00, 1.08546, 1.08633, 1.08335, 1.08416, -0.05952 2016-01-04 16:00, 1.08443, 1.08482, 1.08013, 1.08033, -0.09868 2016-01-04 17:00, 1.08039, 1.08125, 1.07814, 1.08020, -0.14860 2016-01-04 18:00, 1.08024, 1.08234, 1.08002, 1.08198, -0.26521 2016-01-04 19:00, 1.08183, 1.08250, 1.08129, 1.08224, -0.43997 2016-01-04 20:00, 1.08223, 1.08283, 1.08159, 1.08273, -0.58506 2016-01-04 21:00, 1.08272, 1.08377, 1.08263, 1.08294, -0.66573 2016-01-04 22:00, 1.08296, 1.08374, 1.08289, 1.08336, -0.68048 2016-01-04 23:00, 1.08325, 1.08335, 1.08274, 1.08297, -0.66300
it looks good.
Now, suppose that I want to add the value of an indicator calculated on a different timeframe.
What I expect is that the output starts from the same date and I should have 3 more columns. The following is the script:
Code:
function run() { StartDate = 20160101; EndDate = 20161231; BarPeriod = 5; TimeFrame = 12; LookBack = 1200; set(RULES); set(LOGFILE); set(PLOTNOW); Spread = RollLong = RollShort = Commission = Slippage = 0; vars CLOSE = series(priceClose()); var alma = scale(ALMA(CLOSE,10),100)/100; vars ALMA = series(alma); TimeFrame = 1; var PriceDiff = (priceClose(0)-priceClose(6))/priceClose(0); PriceDiff = scale(PriceDiff, 100)/100; vars PD = series(PriceDiff); var pd0 = PD[0]; var pd1 = PD[1]; var pd2 = PD[2]; TimeFrame = 12; char line[300]; string Name = strf("DataTestMF1_%s%s.csv", strmid(Asset,0,3), strmid(Asset,4,3)); if(is(INITRUN)) { file_delete(Name); file_write(Name,"Date, Open, High, Low, Close, ALMA, ret1, ret1, ret1",0); } if(!is(LOOKBACK)) { sprintf(line, "n%04i-%02i-%02i %02i:%02i, %.5f, %.5f, %.5f, %.5f, %.5f, %.5f, %.5f, %.5f", year(),month(),day(),hour(),minute(), priceOpen(),priceHigh(),priceLow(),priceClose(),ALMA[3], pd0, pd1, pd2); if(frame(0)) file_append(Name, line); } }
Basically this script export the value of lagged alma in the 60 minutes timeframe and the value of price change in 5 minutes timeframe.
The output is the following:
Code:
Date, Open, High, Low, Close, ALMA, pd0, pd1, pd2 2016-01-08 03:00, 1.08853, 1.08908, 1.08762, 1.08868, 0.41190, 0.28578, 0.34522, 0.21621 2016-01-08 04:00, 1.08869, 1.08894, 1.08804, 1.08827, 0.39879, 0.01907, -0.09674, -0.21776 2016-01-08 05:00, 1.08812, 1.08844, 1.08723, 1.08749, 0.38246, -0.11665, -0.12942, -0.27975 2016-01-08 06:00, 1.08744, 1.08854, 1.08734, 1.08777, 0.34529, -0.24808, 0.02944, 0.07264 2016-01-08 07:00, 1.08774, 1.08815, 1.08553, 1.08617, 0.29268, -0.69163, -0.66401, -0.81675 2016-01-08 08:00, 1.08595, 1.08889, 1.08551, 1.08874, 0.25388, 0.94465, 0.79819, 0.32647 2016-01-08 09:00, 1.08851, 1.09001, 1.08691, 1.08711, 0.23153, -0.17089, -0.38559, -0.33323 2016-01-08 10:00, 1.08724, 1.08830, 1.08671, 1.08716, 0.21211, -0.29672, -0.23913, -0.28216 2016-01-08 11:00, 1.08702, 1.08753, 1.08587, 1.08694, 0.19206, 0.26347, 0.52108, 0.33155 2016-01-08 12:00, 1.08706, 1.08768, 1.08615, 1.08725, 0.18528, -0.11513, 0.00355, 0.02372 2016-01-08 13:00, 1.08715, 1.08774, 1.08590, 1.08642, 0.19415, 0.09200, 0.09518, 0.33694 2016-01-08 14:00, 1.08624, 1.08710, 1.08034, 1.08466, 0.19029, -0.60163, -0.56962, -0.91718 2016-01-08 15:00, 1.08415, 1.08907, 1.08340, 1.08652, 0.18173, -0.32238, -0.00729, -0.30864 2016-01-08 16:00, 1.08697, 1.09093, 1.08644, 1.09059, 0.17844, 0.43507, 0.05261, -0.02440 2016-01-08 17:00, 1.09049, 1.09172, 1.08846, 1.08876, 0.17220, -0.45878, -0.20032, -0.09039 2016-01-08 18:00, 1.08843, 1.08924, 1.08704, 1.08893, 0.15538, 0.32946, 0.42800, 0.06519 2016-01-08 19:00, 1.08895, 1.09049, 1.08863, 1.08959, 0.14895, -0.07918, -0.18478, -0.08822 2016-01-10 23:00, 1.08942, 1.09466, 1.08900, 1.09455, 0.19131, 0.86701, 0.05060, 0.03761 2016-01-11 00:00, 1.09440, 1.09706, 1.09331, 1.09374, 0.24686, -0.15974, -0.18004, -0.39795 2016-01-11 01:00, 1.09367, 1.09413, 1.09242, 1.09376, 0.26194, 0.05265, 0.04224, 0.08446 2016-01-11 02:00, 1.09369, 1.09464, 1.09238, 1.09385, 0.27175, -0.00331, -0.07078, 0.16713 2016-01-11 03:00, 1.09372, 1.09382, 1.09180, 1.09213, 0.30866, 0.05294, 0.04687, 0.08110 2016-01-11 04:00, 1.09207, 1.09239, 1.09082, 1.09134, 0.35766, -0.21857, -0.31536, -0.33227 2016-01-11 05:00, 1.09126, 1.09157, 1.09083, 1.09142, 0.38023, 0.04102, 0.04465, 0.11003 2016-01-11 06:00, 1.09134, 1.09194, 1.09094, 1.09187, 0.37771, 0.07923, -0.02478, 0.12567 2016-01-11 07:00, 1.09188, 1.09342, 1.09146, 1.09272, 0.36237, 0.40401, 0.62812, 0.47816 2016-01-11 08:00, 1.09200, 1.09238, 1.08932, 1.09001, 0.33420, -0.39875, -0.30972, -0.83781 2016-01-11 09:00, 1.08988, 1.09009, 1.08726, 1.08836, 0.31216, -0.12036, -0.50657, -0.38999 2016-01-11 10:00, 1.08877, 1.08938, 1.08816, 1.08862, 0.30770, 0.12678, -0.14968, -0.12121 2016-01-11 11:00, 1.08868, 1.09019, 1.08849, 1.08995, 0.31188, 0.24670, 0.39044, 0.07744 2016-01-11 12:00, 1.08997, 1.09071, 1.08927, 1.08991, 0.29939, -0.02807, -0.14362, -0.31769
So the question is: why it does not start from January 3th?
Thanks for your time in reading this.
Cheers.