CustomTicksReplace

Fully replaces the price history of the custom symbol within the specified time interval with the data from the MqlTick type array.

int  CustomTicksReplace(
   const string     symbol,            // symbol name
   long             from_msc,          // start date
   long             to_msc,            // end date
   const MqlTick&   ticks[],           // array for the data to be applied to a custom symbol
   uint             count=WHOLE_ARRAY  // number of the ticks[] array elements to be used
   );

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.

ticks[]

[in]   Array of the MqlTick type tick data ordered in time in ascending order.

count=WHOLE_ARRAY

[in]  Number of the ticks[] array elements to be used for replacement in the specified time interval. WHOLE_ARRAY means that all ticks[] array elements should be used.

Return Value

Number of updated ticks or -1 in case of an error.

Note

Since several ticks may often have the same time up to a millisecond in a stream of quotes (accurate tick time is stored in the time_msc field of the MqlTick structure), the CustomTicksReplace function does not automatically sort out the ticks[] array elements by time. Therefore, the array of ticks must be pre-arranged in time ascending order.

The ticks are replaced consecutively, day after day, until the time specified in to_msc or until an error occurs. The first day from the specified range is processed followed by the next one, etc.  As soon as the mismatch between the tick time and the ascending (non-descending) order is detected, the tick replacement stops on the current day. All ticks from the previous days are successfully replaced, while the current day (at the moment of a wrong tick) and all the remaining days in the specified interval remain unchanged.

If the ticks[] array contains no tick data for any day (generally, any time interval), a "hole" corresponding to the missing data appears in the custom symbol history after the tick data from ticks[] are applied. In other words, the call of CustomTicksReplace with missing ticks is equivalent to deleting part of the tick history, as if CustomTicksDelete with the "hole" interval is called.

If the tick database has no data for the specified time interval, CustomTicksReplace will add to the database ticks form the ticks[] array.

The CustomTicksReplace function works directly with the tick database.

 

See also

CustomRatesDelete, CustomRatesUpdate, CustomTicksDelete, CopyTicks, CopyTicksRange