CustomTicksDelete() is not deleting ticks from database

 

Hi

Do anyone is having this problem ...

I cant delete tick data from tick database using CustomTicksDelete(string symbol name,long start date ,long end date);

It always return 0,i.e. 0 ticks deleted

But  CustomRatesDelete() works fine for bars ,but I want to delete the ticks in the database.


Thanks :)

 
debjit625:

Hi

Do anyone is having this problem ...

I cant delete tick data from tick database using CustomTicksDelete(string symbol name,long start date ,long end date);

It always return 0,i.e. 0 ticks deleted

But  CustomRatesDelete() works fine for bars ,but I want to delete the ticks in the database.


Thanks :)

Did you set the start and end parameters correctly ?

Show your code.

 
Alain Verleyen:

Did you set the start and end parameters correctly ?

Show your code.

Yep I guess so.As for CustomRatesDelete()  we use same paratemeters and it works.But anyway here is what I did .

1) Made a custom symbol and named it "New".

2)Added Tick data to it for  13th dec 2019 from 9:15 to 3:30 

Now using this code to delete but it always return 0 .

datetime start = StringToTime("2019.12.13 09:15:00");
datetime end = StringToTime("2019.12.13 15:30:00);

int num = CustomTicksDelete("New",start,end);

Print("Numbers of Ticks deleted : ",num);


Thanks

 
debjit625:

Yep I guess so.As for CustomRatesDelete()  we use same paratemeters and it works.But anyway here is what I did .

1) Made a custom symbol and named it "New".

2)Added Tick data to it for  13th dec 2019 from 9:15 to 3:30 

Now using this code to delete but it always return 0 .


Thanks

Read the documentation again, start/end parameters are not datetime.
 
Alain Verleyen:
Read the documentation again, start/end parameters are not datetime.

Its the same thing its long datatype , datetime is a 8 byte data type just cast it to long it will give you the epoch time in ms.

datetime somedate = StringToTime("2019.12.13 09:15:00");

Print((long)somedate);

See what it prints its just an epoch time.

CustomRatesDelete() also take start and end parameters as long ,just pass datetime it will work.

 
debjit625:

Its the same thing its long datatype , datetime is a 8 byte data type just cast it to long it will give you the epoch time in ms.


CustomRatesDelete() also take start and end parameters as long ,just pass datetime it will work.

Ok so there is no need to ask for help if you don't listen. I said you to read the documentation, not to assume.
 
Alain Verleyen:
Ok so there is no need to ask for help if you don't listen. I said you to read the documentation, not to assume.

Ok I read it and it says

Deletes all ticks from the price history of the custom symbol in the specified time interval.

int  CustomTicksDelete(
   const string     symbol,            // symbol name
   long             from_msc,          // start date
   long             to_msc             // end date
   );

Parameters

symbol

[in]  Custom symbol name.

from_msc

[in]  Time of the first tick in the price history within the specified range to be removed. Time in milliseconds since 01.01.1970.

to_msc

[in]  Time of the last tick in the price history within the specified range to be removed. Time in milliseconds since 01.01.1970.


So they are of long type.I still dont understand can you tell me what should I use in place of from_msc and to_msc

As you have understood the problem ,tell me what to do?


Thanks

 
debjit625:

Ok I read it and it says

Deletes all ticks from the price history of the custom symbol in the specified time interval.

int  CustomTicksDelete(
   const string     symbol,            // symbol name
   long             from_msc,          // start date
   long             to_msc             // end date
   );

Parameters

symbol

[in]  Custom symbol name.

from_msc

[in]  Time of the first tick in the price history within the specified range to be removed. Time in milliseconds since 01.01.1970.

to_msc

[in]  Time of the last tick in the price history within the specified range to be removed. Time in milliseconds since 01.01.1970.


So they are of long type.I still dont understand can you tell me what should I use in place of from_msc and to_msc

As you have understood the problem ,tell me what to do?


Thanks

It's a long type because it's a number of milliseconds, not a number of seconds like a datetime.

   int deleted=CustomTicksDelete(symbol,(long)startDT*1000+X,(long)endDT*1000+Y);     // X and Y are eventual milliseconds precision, or 0 to delete between 2 dates
 

@Alain Verleyen

Ok I totally missed it.

It works now ...

Thanks a lot man saved my day :)

Alain Verleyen
Alain Verleyen
  • www.mql5.com
Hello everyone, I am a computer scientist and professional programmer. I can help you by coding an indicator, a script, or a comprehensive strategy (trading robot). If you have ideas but have difficulty to formulate it for automation, I can also help you establish a specification. I focus on quality, not only will the code do what you want...
 
debjit625:

@Alain Verleyen

Ok I totally missed it.

It works now ...

Thanks a lot man saved my day :)

I tried to use the MSC dates like that :


int ret1 = CustomTicksDelete("GBPUSDCustom",0,long(ticks_array[idx-1].time) * 1000);
Print ("number of deleted ticks ", ret1); 

I also tried :

int ret1 = CustomTicksDelete("GBPUSDCustom",0,long(TimeCurrent()) * 1000);
Print ("number of deleted ticks ", ret1); 
but it doesn't work better

but it deletes 0 ticks....so I now use a very high long number to delete everything, but it is strange that the code doesn't work... what am i doing wrong ?