Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий
fxsaber, 2018.12.06 14:12
// Пример создания перевернутого символа #include <fxsaber\ThirdPartyTicks\CustomSymbol.mqh> // https://www.mql5.com/ru/code/20225 CUSTOMSYMBOL CustomSymb(StringSubstr(_Symbol, 3, 3) + StringSubstr(_Symbol, 0, 3) + StringSubstr(_Symbol, 6)); // Создали символ double ReversePrice( const double Price ) { return(Price ? NormalizeDouble(1 / Price, _Digits) : 0); } void ReverseTick( MqlTick &Tick ) { Tick.bid = ReversePrice(Tick.bid); Tick.ask = ReversePrice(Tick.ask); Tick.last = ReversePrice(Tick.last); } bool ReverseTicks( MqlTick &Ticks[] ) { for (int i = ArraySize(Ticks) - 1; i >= 0; i--) ReverseTick(Ticks[i]); return(true); } bool GetTicks( MqlTick &Ticks[] ) { return(CopyTicks(_Symbol, Ticks) > 0); } void OnInit() { MqlTick Ticks[]; if (CustomSymb.IsCustom() && GetTicks(Ticks) && ReverseTicks(Ticks) && (CustomSymb.AddTicks(Ticks) > 0) && (CustomSymb.DataToSymbol() > 0) && CustomSymb.On()) ChartOpen(CustomSymb.Name, PERIOD_CURRENT); // Открыли график } void OnTick() { MqlTick Tick[1]; if (CustomSymb.IsCustom() && SymbolInfoTick(_Symbol, Tick[0]) && ReverseTicks(Tick)) CustomTicksAdd(CustomSymb.Name, Tick); }
...
Can anyone tell me what's the problem?
There is no problem.
There is no problem.
As I thought so, too. still the ticks and bars databases are empty. The thing is, I had another program that use SymbolInfoTick() and then add the tick into custom symbol via CUstomTicksAdd and it works! ticks and bars database are being created for the custom symbol. :)
But then during weekend when the market is closed, there is no incoming tick, so I thought of creating an incoming tick from the standard symbol (using CopyTick()) and add it into the custom symbol using CustomTicksAdd(). These functions are triggered in OnTimer() so as to "generate" incoming tick for the custom symbol. This is to test my other test code. But it doesn't work. No tick nor bar databases are being created. :(
Is it because CustomTicksAdd only works when the market is open?
As I thought so, too. still the ticks and bars databases are empty. The thing is, I had another program that use SymbolInfoTick() and then add the tick into custom symbol via CUstomTicksAdd and it works! ticks and bars database are being created for the custom symbol. :)
But then during weekend when the market is closed, there is no incoming tick, so I thought of creating an incoming tick from the standard symbol (using CopyTick()) and add it into the custom symbol using CustomTicksAdd(). These functions are triggered in OnTimer() so as to "generate" incoming tick for the custom symbol. This is to test my other test code. But it doesn't work. No tick nor bar databases are being created. :(
Is it because CustomTicksAdd only works when the market is open?
I don't have problem.
Maybe in your code. You can provide a testcase source code (a code that compiles this time).
I don't have problem.
Maybe in your code. You can provide a testcase source code (a code that compiles this time).
Still the same. My tick database is still empty. Not sure why. Just for your info, my MT5 build is 1940. Anyway, it did trigger OnTick() on my other testcode, which I want it to. So, at least it does that.
Thanks Alain for your input. Appreciate it.
Still the same. My tick database is still empty. Not sure why. Just for your info, my MT5 build is 1940. Anyway, it did trigger OnTick() on my other testcode, which I want it to. So, at least it does that.
Thanks Alain for your input. Appreciate it.
Just for info. Once the market is open, my tick database is visible with data. I guess tick database is only visible when market is open and hidden and the market is closed.
Just for info. Once the market is open, my tick database is visible with data. I guess tick database is only visible when market is open and hidden and the market is closed.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi Everyone,
I am trying to make a simple test on Custom Symbol. I am using CopyTicks to get ticks' data from standard symbol and create a new custom symbol via CustomTicksAdd . The funny thing is that the CustomTicksAdd manage to add tick when it returns a value 1. However, when I check it at the Custom Symbol database, the historical data bars is empty and the ticks data is also empty. Why is that?
From what I understand about CustomTicksAdd from the MT5 documentation, it suppose to add to the custom symbol database.
Below is how my code looks like.
int added;
int i;
MqlTick atick[1];
MqlTick mtick[];
int n = CopyTicks(_Symbol, mtick,COPY_TICKS_ALL, ((ulong)startdate)*1000, 0);
if(n>0)
do {
atick[0] = mtick[i];
added = CustomTicksAdd(CustomSymbol, atick);
if(added == -1)
{
int err;
err = GetLastError();
Print("CustomTicksAdd failed: ", err);
if(err == ERR_MARKET_UNKNOWN_SYMBOL)
{
bStopAll = true;
Alert("Custom symbol ", destSymbol, " is unavailable, expert is disabled.");
}
else
if(err == ERR_MARKET_NOT_SELECTED)
{
bStopAll = true;
Alert("Custom symbol ", destSymbol, " is not selected, expert is disabled.");
}
ResetLastError();
}
i++;
}while(i< ArraySize(mtick))
Can anyone tell me what's the problem?
regards.