Why Not work CopyTicksRange?

To add comments, please log in or register
Ehsan Tavakoli
160
Ehsan Tavakoli  
int OnInit()
  {


    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

Alain Verleyen
36128
Alain Verleyen  
Please read the documentation. The dates should be provided as ulong in milliseconds, not datetime.
Ehsan Tavakoli
160
Ehsan Tavakoli  
Alain Verleyen:
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

int OnInit()
  {


    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?

honest_knave
Moderator
2302
honest_knave  

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...)

Ehsan Tavakoli
160
Ehsan Tavakoli  
honest_knave:

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...)

oh . you are right

I was confused

I change to this

ulong Start = ulong(Start_date)*1000;
ulong End   = ulong(End_date  )*1000;
thank you
To add comments, please log in or register