I am copying ticks from symbol to Custom symbol. I get holes in history.
This is the script.
//+------------------------------------------------------------------+//| script.mq5 |//| Copyright 2021, MetaQuotes Ltd. |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright"Copyright 2021, MetaQuotes Ltd."#property link"https://www.mql5.com"#property version"1.00"//+------------------------------------------------------------------+//| Script program start function |//+------------------------------------------------------------------+//+------------------------------------------------------------------+// Creating a copy of the symbol to speed up the tester#property script_show_inputs#include <Symbol.mqh> //https://www.mql5.com/ru/code/18855#include <ErrorDescription.mqh> // https://www.mql5.com/ru/code/79int CloneTicks( string SymbFrom = NULL, string SymbTo = NULL, constulong _from_msc = 0, constulong _to_msc = LONG_MAX )
{
int Res;
SymbFrom = (SymbFrom == NULL) ? _Symbol : SymbFrom;
if (SymbTo == NULL) return -1;
if (SymbTo == SymbFrom) return -1;
if (!::SymbolInfoInteger(SymbTo, SYMBOL_CUSTOM)) return -1;
MqlTick Ticks[];
::CopyTicksRange(SymbFrom, Ticks, COPY_TICKS_ALL, _from_msc, _to_msc);
Res = ::CustomTicksReplace(SymbTo, _from_msc, _to_msc, Ticks);
return(Res);
}
voidOnStart()
{
const SYMBOL Symb("TESTER_" + _Symbol); // Created a symbol
Symb.DeleteHistory();
Symb.Delete(true);
Symb.Create(NULL,_Symbol);
if (Symb.IsExist()) // If a symbol is created
{
//Symb = _Symbol; // Copied all the properties and bar history (+ tick history if a custom) from the main symbol - clone
Symb.CloneProperties();
CustomSymbolSetString(Symb.Name,SYMBOL_PATH,"");
// Made the currencies of the symbol the currency of the account
Symb.SetProperty(SYMBOL_CURRENCY_BASE, AccountInfoString(ACCOUNT_CURRENCY));
Symb.SetProperty(SYMBOL_CURRENCY_PROFIT, AccountInfoString(ACCOUNT_CURRENCY));
Symb.SetProperty(SYMBOL_CURRENCY_MARGIN, AccountInfoString(ACCOUNT_CURRENCY));
if (Symb.On()) {};// // Included in Market Watch//ChartOpen(Symb.Name, PERIOD_CURRENT); // A new symbol chart has been openedif (!Symb.CloneRates(_Symbol)) Print("err rates: ",ErrorDescription(GetLastError()));
datetime date_from=D'2019.01.01';
datetime dt_start=date_from;
while (dt_start<TimeCurrent()) {
Print(dt_start);
ulong date_start_msc=(ulong)dt_start*1000;
ulong date_end_msc=(ulong)(dt_start+86400)*1000-1;
//if (!Symb.CloneHistory(_Symbol,date_start_msc,date_end_msc)) Print("err: ",GetLastError());//if (!Symb.CloneTicks(_Symbol,date_start_msc,date_end_msc)) Print("err ticks: ",ErrorDescription(GetLastError()));if (!CloneTicks(_Symbol,Symb.Name,date_start_msc,date_end_msc)) Print("err ticks: ",ErrorDescription(GetLastError()));
MqlTick t1[], t2[];
int ticks1=CopyTicksRange(_Symbol,t1,COPY_TICKS_INFO,date_start_msc,date_end_msc);
int ticks2=CopyTicksRange(Symb.Name,t2,COPY_TICKS_INFO,date_start_msc,date_end_msc);
if (ticks1 != ticks2) {
Print("wrong ticks count: ",ticks1," / ", ticks2);
}
dt_start+=86400;
}
dt_start=date_from;
int wrong_bars=0;
while (dt_start<TimeCurrent()) {
if (iBarShift(_Symbol,PERIOD_M1,dt_start,true)>=0 && iBarShift(Symb.Name,PERIOD_M1,dt_start,true) < 0) {
Print("wrong bar: ",dt_start);
wrong_bars++;
}
dt_start+=60;
}
Print("total wrong bars: ",wrong_bars);
//if (Symb.On()) // Included in Market WatchChartOpen(Symb.Name, PERIOD_CURRENT); // A new symbol chart has been opened
}
Print("end");
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I am copying ticks from symbol to Custom symbol. I get holes in history.
This is the script.
This is the output.
Why the CopyTicksRange from custom symbol is 0?
This is the history holes. Why are there a history holes?
.