
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I need the quotes of the m1 bars together with the quotes of the bars of the current chart to go back for "LookBackBars" (if possible) of the actual timeframe
Mt4 now offers 'me' for this 3 'data-streams':
So I wrote a little script
I get for the chart with timeframe M5:
LookBackBars 10000: 2017.01.24 00:09 // <= oldest required date
Bars 133356: 2014.01.01 22:00
M1 50005: 2016.12.21 07:46 // <= oldest available date M1
P0 10001: 2016.04.11 04:55 // <= oldest available date Chart
=> newBarsBack: 10000 t 2017.01.24 00:09 // maxdate to begin calculation
Time[133355]: 2014.01.01 22:00 - 2017.02.27 17:30 // no problem
m1, 35572 =?= 50005 2017.01.24 00:10 - 2017.02.27 17:34 // fine as requested
p0, 3115 =?= 10001 2017.02.12 22:00 - 2017.02.27 17:30 // uups - what happened here?? Wasn't I told that 10001 bars can be requested?
For the first part I did:
Str1 = StringConcatenate("\nGIVEN\nLookBackBars ",LookBackBars,": ",TimeToString(TimeMaxBars),"\nBars ",Bars,": ",TimeToString(Time[Bars-1]));
TimeOldM1 = (datetime)SeriesInfoInteger(_Symbol, PERIOD_M1, SERIES_SERVER_FIRSTDATE);
BarsOldM1 = SeriesInfoInteger(_Symbol, PERIOD_M1, SERIES_BARS_COUNT);
TimeOldP0 = (datetime)SeriesInfoInteger(_Symbol, _Period, SERIES_SERVER_FIRSTDATE);
BarsOldP0 = SeriesInfoInteger(_Symbol, _Period, SERIES_BARS_COUNT);
TimeOldCalc = fmax3(TimeMaxBars,TimeOldM1,TimeOldP0);
BarsOldP0 = (TimeCurrent() - TimeOldCalc)/(_Period*60); //Chart
BarsOldM1 = (TimeCurrent() - TimeOldCalc)/(60); //Min
if ( BarsOldP0 < LookBackBars ) {
Str1 = Str1 +"\nCORRECTED";
LookBackBars = (int)BarsOldP0;
}
int allMin = CopyRates(_Symbol, PERIOD_M1, TimeCurrent(),TimeOldCalc, rMin),
allPer = CopyRates(_Symbol, _Period, TimeCurrent(),TimeOldCalc, rPer),
lim = Bars - 1;
Str2 = StringConcatenate("\nGOT\nTime[",lim,"]: ",TimeToString(Time[lim])," - ",TimeToString(Time[0]),
"\nm1, ",allMin," =?= ",BarsOldM1," ",TimeToString(rMin[0].time)," - ",TimeToString(rMin[allMin-1].time),
"\np0, ",allPer," =?= ",BarsOldP0," ",TimeToString(rPer[0].time)," - ",TimeToString(rPer[allPer-1].time)
);
Why do I get such a stupid small value for the array size (allPer) for rPer - not only once, but again and again?