Hello Members,
I have following problem with CopyTime & CopyBuffer with mql5
when I am printing data for iTime[0] its showing 0:00 1970 date means no value.
Also with fractal
when printing
it shows a long string of numbers.
Where I am mistaking, could you please help?
Thank you in advance.
Regards
Please show the code that can be played. How do we know what is in your variables? How do we know which type of your variables are?
Example of the code being reproduced:
//+------------------------------------------------------------------+ //| Test_en.mq5 | //| Copyright 2012, CompanyName | //| http://www.companyname.net | //+------------------------------------------------------------------+ #property script_show_inputs input int count=1; // data count to copy //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnStart() { string symbol_name=Symbol(); // symbol name ENUM_TIMEFRAMES timeframe=Period(); // period int start_pos=0; // start position datetime time_array[]; // target array to copy open times ResetLastError(); int result=CopyTime(symbol_name,timeframe,start_pos,count,time_array); if(result==-1) { Print("CopyTime error# ",GetLastError()); return; } if(result<count) { Print("Ordered ",IntegerToString(count),", received ",IntegerToString(result)); return; } ArrayPrint(time_array); } //+------------------------------------------------------------------+
if input parameter "data count to copy"==9, Result from the "Experts" tab:
[0] 2017.05.04 08:05:00 2017.05.04 08:06:00 2017.05.04 08:07:00 2017.05.04 08:08:00 2017.05.04 08:09:00 [5] 2017.05.04 08:10:00 2017.05.04 08:11:00 2017.05.04 08:12:00 2017.05.04 08:13:00
Please show the code that can be played. How do we know what is in your variables? How do we know which type of your variables are?
Example of the code being reproduced:
if input parameter "data count to copy"==9, Result from the "Experts" tab:
Hello Vladimir, Pardon I solve the copytime problem, I was allocating it inside a loop thats why it was not working.
But Copybuffer with fractal indicator is still showing a long string. Here is the details with variable allocation & its type:
int handle_fractal,FractalBar = 5; double fractal_up[],fractal_down[]; int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { handle_fractal = iFractals(_Symbol, PERIOD_CURRENT); ArraySetAsSeries (fractal_down, true); ArraySetAsSeries (fractal_up, true); for(int f = 0; f<=FractalBar; f++) { //--- get the data CopyBuffer(handle_fractal, LOWER_LINE, f, 1, fractal_down); if(fractal_down[f]!= 0) // Current chart Dwn Do something } //--- return value of prev_calculated for next call return(rates_total); }
Even if I don't use the loop, use the plain code as following:
//--- get the data CopyBuffer(handle_fractal,LOWER_LINE, 1, 1, fractal_down); printf(DoubleToString(fractal_down[0],_Digits));
it still prints a long string of data:
2017.05.04 14:46:38.647 Indicator MT5 (GBPUSD,M4) 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.00000000
IFractal indicator in the indicator buffer can store:
- price (in this case, you see the arrow)
- or a value EMPTY_VALUE
Here is a snippet of the iFractal indicator code:
if(prev_calculated<7) { limit=2; //--- clean up arrays ArrayInitialize(ExtUpperBuffer,EMPTY_VALUE); ArrayInitialize(ExtLowerBuffer,EMPTY_VALUE); } else limit=rates_total-5; for(i=limit;i<rates_total-3 && !IsStopped();i++) { //---- Upper Fractal if(high[i]>high[i+1] && high[i]>high[i+2] && high[i]>=high[i-1] && high[i]>=high[i-2]) ExtUpperBuffer[i]=high[i]; else ExtUpperBuffer[i]=EMPTY_VALUE; //---- Lower Fractal if(low[i]<low[i+1] && low[i]<low[i+2] && low[i]<=low[i-1] && low[i]<=low[i-2]) ExtLowerBuffer[i]=low[i]; else ExtLowerBuffer[i]=EMPTY_VALUE; }
So the indicator buffer iFractal does not have a value of "0.0".
IFractal indicator in the indicator buffer can store:
- price (in this case, you see the arrow)
- or a value EMPTY_VALUE
Here is a snippet of the iFractal indicator code:
So the indicator buffer iFractal does not have a value of "0.0".
Still not clear. I need price just like it shows up in mql4 with ifractal function. In mql4 for Fractal up it shows double value and if there is no fractal up its shows 0
Where I should use the EMPTY_VALUE on my code structure.
Thank you in advance
printf(DoubleToString(fractal_down[0],_Digits));
- Perhaps you should read the manual. PrintFormat takes a format string and one or more values. You meant Print
- There will never be a fractal on the current bar (or bar one.) Try 2.
- Perhaps you should read the manual. PrintFormat takes a format string and one or more values. You meant Print
- There will never be a fractal on the current bar (or bar one.) Try 2.
Hello whroeder,
Thank you for the suggestion. I tried it with Print & PrintFormat both. Didn't created any difference with 0 index, long string number.
Plus with fractal_down[2] as you suggested, it shows array out of range error in both cases.
Hello whroeder,
Thank you for the suggestion. I tried it with Print & PrintFormat both. Didn't created any difference with 0 index, long string number.
Plus with fractal_down[2] as you suggested, it shows array out of range error in both cases.
Check already in the help what is the value of EMPTY_VALUE.
IFractal indicator in the indicator buffer can store:
- or price (in this case, you see the arrow)
- or a value EMPTY_VALUE
Check already in the help what is the value of EMPTY_VALUE.
IFractal indicator in the indicator buffer can store:
- or price (in this case, you see the arrow)
- or a value EMPTY_VALUE
Okay I got it finally, What I did is I manually check the chart on which bar fractal formed, then input that bar index & it print function showing it correctly.
In this case, EMPTY_VALUE seems a long digit number when I try to print it. That's why the confusion.
I solve it with following line of code:
if(fractal_down[0]!= EMPTY_VALUE) Do something;

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello Members,
I have following problem with CopyTime & CopyBuffer with mql5
when I am printing data for iTime[0] its showing 0:00 1970 date means no value.
Also with fractal
when printing
it shows a long string of numbers.
Where I am mistaking, could you please help?
Thank you in advance.
Regards