Please read the documentation. The dates should be provided as ulong in milliseconds, not datetime.
Hi
I've read this before
I casted datetime to millisecond but not work
{
MqlTick tick_Range[] , tick[] ;
int copied_Range , copied ;
datetime Start_date = D'2016.11.11';
datetime End_date = D'2016.12.12';
ulong Start = ulong(Start_date);
ulong End = ulong(End_date );
copied_Range = CopyTicksRange( Symbol() , tick_Range , COPY_TICKS_TRADE , Start , End );
copied = CopyTicks ( Symbol() , tick , COPY_TICKS_TRADE , 0 , 1000 );
Print( "Start = " , Start , " | " , "End = " , End );
Print( "copied_Range = " , copied_Range , " | " , "copied = " , copied );
//---
return(0);
}
Print result :
Start = 1478822400 | End = 1481500800
copied_Range = 0 | copied = 1000
My casting is wrong?
Type casting alone isn't going to fix it.
datetime is the number of seconds elapsed since 01 January 1970.
What you have done is stored the number of seconds elapsed since 01 January 1970 into a ulong variable.
You need to convert the value to milliseconds (1000 times more...)
Type casting alone isn't going to fix it.
datetime is the number of seconds elapsed since 01 January 1970.
What you have done is stored the number of seconds elapsed since 01 January 1970 into a ulong variable.
You need to convert the value to milliseconds (1000 times more...)
I was confused
I change to this
ulong End = ulong(End_date )*1000;
I was confused
I change to this
ulong End = ulong(End_date )*1000;
I need to use CopyTicksRange and CopyTicks they both do not work. I am constructing a array of lasts. Very simple. But would like to verify with one of these two, but both are not working for me. They keep returning -1. Here is the simple code I thought about:
int qteTick=0; double ArrayDeLast[]; void OnTick() { double Last=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_LAST),_Digits); ArrayResize(ArrayDeLast,qteTick+1); ArrayDeLast[qteTick]=Last; qteTick=qteTick+1; }
The code above works fine. No problem. But the code below does not. I have tried use OnInit function replacing the OnTick. Also have tried using the "End" and "Start" variables. No success. Is there a declartion needed for copyTicks to work?
void OnTick() { MqlTick ArrayDeTicks[]; MqlTick tick[]; int copied_Range , copied ; // ulong End = ulong(TimeCurrent()); // ulong Start = End-10; copied_Range = CopyTicksRange( Symbol() , ArrayDeTicks , COPY_TICKS_TRADE , 1585217010000 , 1585217011000 ); copied = CopyTicks ( Symbol() , tick , COPY_TICKS_TRADE , 0 , 1000 ); Comment(copied_Range," ",copied); }
Regards,
I need to use CopyTicksRange and CopyTicks they both do not work. I am constructing a array of lasts. Very simple. But would like to verify with one of these two, but both are not working for me. They keep returning -1. Here is the simple code I thought about:
The code above works fine. No problem. But the code below does not. I have tried use OnInit function replacing the OnTick. Also have tried using the "End" and "Start" variables. No success. Is there a declartion needed for copyTicks to work?
Regards,
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
{
MqlTick tick_Range[] , tick[] ;
int copied_Range , copied ;
datetime Start = D'2016.11.11';
datetime End = D'2016.12.12';
copied_Range = CopyTicksRange( Symbol() , tick_Range , COPY_TICKS_TRADE , Start , End );
copied = CopyTicks ( Symbol() , tick , COPY_TICKS_TRADE , 0 , 1000 );
Print( "copied_Range = " , copied_Range , " | " , "copied = " , copied );
//---
return(0);
}
This is Print result :
copied_Range = 0 | copied = 1000