|
Post by bobpit on Apr 4, 2016 8:59:03 GMT
I am sorry if I have caused any confusion. This was my original question: You see, when I set the chart interval to 15min, I get nice rounded times (15:45:00, 16:00:00). But when I do it from AFL I the times are shifted by 1min: 15:59:00, 16:14:00. Am I doing something wrong? Why am I experiencing this? This seemed very odd to me. Through this forum and personal emails I verified that these are normal AB results, I am not doing something wrong. I have already contacted AB support and unless they give me a different solution, I will proceed to hack/change the datetimes in a way similar to what FX suggested.
|
|
fxshrat
Private Group
Posts: 566
Received Likes: 211
|
Post by fxshrat on Apr 6, 2016 9:51:59 GMT
For expanded HTF dt variable you can get the start times of the higher TF by doing this: //.... Code of page 1 //.....
MTFdt = TimeFrameExpand( MTFdt, TF, expandFirst ); MTFdtstart = ValueWhen( MTFdt != Ref( MTFdt, -1 ), dt );
MTFdtstr = DateTimeToStr( SelectedValue( MTFdtstart ) ); printf( "After TFSet, HTF: " + HTFintstr + ", C = %g, time = " + MTFdtstr + "\n", MTFclose );
Then you will get i.e. , ...., 14:15:00, 14:30:00, 14:45:00, ...., if LTF is 5-min or 1-min and HTF is 15-min and start time of interval is chosen. This works for expandfirst mode. But I guess that is still not what you want.
|
|
fxshrat
Private Group
Posts: 566
Received Likes: 211
|
Post by fxshrat on Apr 6, 2016 10:06:54 GMT
if you use expandLast then you may have to set to "End time of Interval" in preferences to at least get ..., 14:14:59, 14:29:59, ....
|
|
|
Post by bobpit on Apr 8, 2016 14:38:00 GMT
Thank you for the code fxshrat. You have given me very good ideas. AB support told me that compressed bars take the datetime of the last lower timeframe bar that is included in the higher timeframe bar. This explains almost all of my issues. I came up with this code too, that takes care of the inconsistent value of the last compressed bar: SetChartOptions( 0, chartShowArrows | chartShowDates ); SetBarsRequired( -2, -2 ); _N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g {{VALUES}}", O, H, L, C ) );
printf( "Lower TimeFrame, barindex()= %g, time = " + DateTimeToStr( SelectedValue( datetime() ) ) + "\n", barindex() ); Plot( C, "Close", ParamColor( "Color", colorDefault ), styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() ); expandmode = expandfirst; TF = in15Minute; TimeFrameSet( TF ); MTFfield = high; MTFdt = DateTime(); MTFdt[BarCount-1] = DateTimeAdd(MTFdt[BarCount-2],1,TF); // adjust last bar off value TimeFrameRestore();
MTFfield = TimeFrameExpand( MTFfield, TF, expandmode ); MTFdt = TimeFrameExpand( MTFdt, TF, expandmode ); MTFdt = Datetimeadd( MTFdt, -1, TF-in1minute); Plot( MTFfield, "MTFfield", colorblue, styleline ); printf( "High TimeFrame, High = %g, time = " + DateTimeToStr( SelectedValue( MTFdt ) ) + "\n", MTFfield ); Wrote a complete article here: bbb-amibroker.blogspot.gr/2016/04/datetime-of-compressed-arrays.htmlPS: Your code with all the colors looks really nice. But you posted an image of the code. Somebody interested cannot just copy/paste your code. Is this intentional?
|
|
fxshrat
Private Group
Posts: 566
Received Likes: 211
|
Post by fxshrat on Apr 8, 2016 21:57:45 GMT
|
|