Following your advice (LoadServerData() calls SeriesInfoInteger( a_symbol, PERIOD_M1, SERIES_SERVER_FIRSTDATE),
i.e. it reads "first date in history by symbol on server regardless of period".
This request itself is not actually considered a history request, i.e. it does not cause a cache to be built,
does not prevent unloading of symbol data. It makes sense to either request SERIES_FIRSTDATE or the number of bars of the timeseries.),
I added a new function to the indicator to prevent the unloading of symbol data:
//+------------------------------------------------------------------+// Custom indicator Book Event function |//+------------------------------------------------------------------+voidOnBookEvent( conststring &symbol )
{
if ( ( ( symbol == _Symbol ) || ( symbol == sec_symbol ) ) && ( !IsStopped() ) )
{
GetBars( sec_symbol, time_frame );
}
}
//+------------------------------------------------------------------+// Custom indicator Check timer function |//+------------------------------------------------------------------+bool CheckTimer( constuint start_value, constuint per_value )
{
uint end_value = GetTickCount();
if ( end_value < start_value )
{
if ( ( start_value - end_value ) >= per_value ) return( true );
}
else
{
if ( ( end_value - start_value ) >= per_value ) return( true );
}
return( false );
}
//+------------------------------------------------------------------+//| Custom indicator Get local data function |//+------------------------------------------------------------------+int GetLocalData( conststring a_symbol, ENUM_TIMEFRAMES a_period )
{
long first_date;
int fail_cnt = 0;
//--- while ( ( fail_cnt < 3 ) && !IsStopped() )
{
first_date = long( SeriesInfoInteger( a_symbol, PERIOD_M1, SERIES_TERMINAL_FIRSTDATE ) );
//--- if ( first_date > 0 )
{
int f_cnt = 0;
datetime times[1];
long a_bars = 0;
//--- while ( ( f_cnt < 5 ) && !IsStopped() )
{
if ( bool( SeriesInfoInteger( a_symbol, PERIOD_M1, SERIES_BARS_COUNT, a_bars ) ) )
{
if ( a_bars > 0 )
{
if ( bool( SeriesInfoInteger( a_symbol, a_period, SERIES_BARS_COUNT, a_bars ) ) )
if ( a_bars > 0 ) return( int( a_bars ) );
}
}
else
{
//--- force timeseries buildCopyTime( a_symbol, a_period, 0, 1, times );
uint start_tick = GetTickCount();
//--- while ( !CheckTimer( start_tick, 5 ) )
{
f_cnt--;
f_cnt++;
}
}
f_cnt++;
}
// Print( "GetLocalData: Таймсерия не построена!" );
}
else
{
uint start_tick = GetTickCount();
//--- while ( !CheckTimer( start_tick, 5 ) )
{
fail_cnt--;
fail_cnt++;
}
}
//---
fail_cnt++;
}
// Print( "GetLocalData: Нет данных в терминале!" );return( 0 );
}
//+------------------------------------------------------------------+//| Custom indicator Get server data function |//+------------------------------------------------------------------+int LoadServerData( conststring a_symbol, ENUM_TIMEFRAMES period )
{
int fail_cnt = 0;
//---while ( ( fail_cnt < 5 ) && !IsStopped() )
{
long first_date = long( SeriesInfoInteger( a_symbol, PERIOD_M1, SERIES_SERVER_FIRSTDATE ) );
//---if ( first_date > 0 )
{
if ( SymbolIsSynchronized( a_symbol ) )
{
// Print( "LoadServerData: Первая дата на сервере есть. Пробуем получить локальные данные..." );return( GetLocalData( a_symbol, period ) );
}
}
else
{
uint start_tick = GetTickCount();
//--- while ( !CheckTimer( start_tick, 10 ) )
{
fail_cnt--;
fail_cnt++;
}
}
fail_cnt++;
}
// Print( "LoadServerData: Первой даты на сервере нет!" );return( 0 );
}
//+------------------------------------------------------------------+//| Custom indicator Get bars function |//+------------------------------------------------------------------+int GetBars( string symbol, ENUM_TIMEFRAMES period )
{
if ( !IsStopped() )
{
int a_bars = Bars( symbol, period );
//---if ( a_bars > 0 )
{
return( a_bars );
}
else
{
// Print( "GetBars: Бары не получены проверяем синхронизации..." );//---Check symbol is synchronized if ( SymbolIsSynchronized( symbol ) )
{
// Print( "GetBars: Символ сихронизирован. Проверяем таймсерию..." );//---Check series is synchronizedif ( bool( SeriesInfoInteger( symbol, period, SERIES_SYNCHRONIZED ) ) )
{
// Print( "GetBars: Серия синхронизирована. Пробуем получить бары..." );
a_bars = Bars( symbol, period );
//--- if ( a_bars > 0 )
{
return( a_bars );
}
else
{
return( GetLocalData( symbol, period ) );
}
}
else
{
// Print( "GetBars: Серия не сихронизирована. Пробуем получить данные из терминала..." );return( GetLocalData( symbol, period ) );
}
}
else
{
// Print( "GetBars: Символ не синхронизирован. Пробуем получить данные с сервера..." );return( LoadServerData( symbol, period ) );
}
}
}
return( 0 );
}
The OnBookEvent() function is triggered on BR-8.15 and BR-9.15 characters quite often,
but the result is the same:
2015.07.2320:48:13.449 Spread (BR-8.15,M1) OnCalculate: Не получены бары по символу BR-9.152015.07.2320:48:13.449 Spread (BR-8.15,M1) OnCalculate: Не получены бары по символу BR-9.152015.07.2320:48:13.449 Spread (BR-8.15,M1) OnCalculate: Не получены бары по символу BR-9.152015.07.2320:48:13.449 Spread (BR-8.15,M1) OnCalculate: Не получены бары по символу BR-9.152015.07.2320:48:13.449 Spread (BR-8.15,M1) OnCalculate: Не получены бары по символу BR-9.15
Michael, have you managed to overcome this problem of getting series from other symbols? I'm sick and tired of fighting with my indicator, it constantly loses synchronization with other symbols.
Right now the demo server is giving out Build 1159 of June 22, 2015. And in it the multicurrency indicators work horribly too. You have to switch periods several times or restart the indicator to get it to display correctly. And after a while it doesn't get the series data again. I always write in the log.
Данные символа "Si-12.15" не синхронизированы с торговым сервером.
To the developers:
Is it impossible to make a function, not to check if data is synchronized or not, but directly to synchronize and not to unload this data from memory?
Resource saving is good, in terms of algorithm optimization. But why should I be so fanatical about offloading data from memory?
I'd rather buy an additional gigabyte or two of memory in my PC instead of bothering with this bothersome series synchronization.
Make a function that is called once at OnInit() to load data for the required symbol and it won't be unloaded as long as the indicator is running.
The terminal should prepare data and monitor their updates, instead of the user thinking about the first date, how many bars I have and on the server, etc.
Michael, have you managed to overcome this problem with getting series from other symbols? I'm sick and tired of fighting with my indicator, it constantly loses synchronization with other symbols.
Right now the demo server is issuing Bild 1159 from June 22, 2015. And in it the multicurrency indicators also work horribly. You have to switch periods several times or restart the indicator to get it to display correctly. And after a while it doesn't get the series data again. I always write in the log.
To the developers:
Is it impossible to make a function, not to check if data is synchronized or not, but directly to synchronize and not to unload this data from memory?
Resource saving is good, in terms of algorithm optimization. But why should I be so fanatical about offloading data from memory?
I'd rather buy an additional gigabyte or two of memory in my PC instead of bothering with this bothersome series synchronization.
Make a function that is called once in OnInit() to load data for the required symbol and it will not be unloaded again until the indicator runs.
The terminal should prepare data and monitor their updates, instead of the user thinking about the first date, how many bars I have and on the server, etc.
Good afternoon!
The developers have replied that they will fix it in the new build.
FORTS. I encountered a problem, functions OrderCheck() and OrderCalcMargin() sometimes (!) incorrectly determine the required GO for a trade and as a result return FALSE.
With the required GO for RTS-12.15(SYMBOL_MARGIN_INITIAL) of 12,500 , the function requires as much as 143,105 rubles!
At the same time everything opens perfectly manually.
How do I call:
MqlTradeRequest MtRequest = {0};
MqlTradeRequest.action = TRADE_ACTION_DEAL;
MqlTradeRequest.magic = 0;
MqlTradeRequest.order = 0;
MqlTradeRequest.symbol = "RTS-12.15";
MqlTradeRequest.volume = 1.00;
MqlTradeRequest.price = 86470;
MqlTradeRequest.stoplimit = 0;
MqlTradeRequest.sl = 0;
MqlTradeRequest.tp = 0;
MqlTradeRequest.deviation = 50;
MqlTradeRequest.type = ORDER_TYPE_SELL;
MqlTradeRequest.type_filling = ORDER_FILLING_FOK;
MqlTradeRequest.type_time = gtc;
MqlTradeRequest.expiration = 0;
MqlTradeRequest.comment = NULL;
MqlTradeCheckResult MtCheckResult = {0};
OrderCheck(MtRequest,MtCheckResult);
Получаю в ответ False и такую структуру:
MqlTradeCheckResult.retcode: 10019 (There is not enough money to complete the request)
MqlTradeCheckResult.balance: 132727.37
MqlTradeCheckResult.equity: 130772.91
MqlTradeCheckResult.profit: 0.00
MqlTradeCheckResult.margin: 143104.55
MqlTradeCheckResult.margin_free: -12331.64
MqlTradeCheckResult.margin_level: 91.38
MqlTradeCheckResult.comment: No money
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.
Good afternoon, Anton!
Following your advice (LoadServerData() calls SeriesInfoInteger( a_symbol, PERIOD_M1, SERIES_SERVER_FIRSTDATE),
i.e. it reads "first date in history by symbol on server regardless of period".
This request itself is not actually considered a history request, i.e. it does not cause a cache to be built,
does not prevent unloading of symbol data. It makes sense to either request SERIES_FIRSTDATE or the number of bars of the timeseries.),
I added a new function to the indicator to prevent the unloading of symbol data:
The OnBookEvent() function is triggered on BR-8.15 and BR-9.15 characters quite often,
but the result is the same:
So what's the problem?
Why is it impossible to get Bars?
The OnBookEvent() function triggers on characters BR-8.15 and BR-9.15 quite often,
but the result is the same:
So what's the problem?
Why is it impossible to get Bars?
The frequency of "often enough" does not inspire confidence. Better to add log output from GetBars() function for debugging.
If you want to understand it, then open a request in servicedesk. Attach full-fledged code example, we will try to reproduce the problem.
The frequency of "often enough" does not inspire confidence. Better to add log output from GetBars() for debugging.
If you have a desire to figure it out, then open a request in the servicedesk. Attach a full-fledged code example, let's try to reproduce the problem.
Ok. Request:Errors,MetaTrader 5 Client,Opened,Started: 2015.07.24 18:28,#1267768
P/S "Quite often" is 10 to 100 OnBookEvent() triggers on two highly liquid instruments per MINUTE.
Hooray!
Reproduced the problem. Indeed the symbol data was sometimes unloaded from memory even with periodic queries. The error will be fixed.
Thank you!
Michael, have you managed to overcome this problem of getting series from other symbols? I'm sick and tired of fighting with my indicator, it constantly loses synchronization with other symbols.
Right now the demo server is giving out Build 1159 of June 22, 2015. And in it the multicurrency indicators work horribly too. You have to switch periods several times or restart the indicator to get it to display correctly. And after a while it doesn't get the series data again. I always write in the log.
Данные символа "Si-12.15" не синхронизированы с торговым сервером.To the developers:
Is it impossible to make a function, not to check if data is synchronized or not, but directly to synchronize and not to unload this data from memory?
Resource saving is good, in terms of algorithm optimization. But why should I be so fanatical about offloading data from memory?
I'd rather buy an additional gigabyte or two of memory in my PC instead of bothering with this bothersome series synchronization.
Make a function that is called once at OnInit() to load data for the required symbol and it won't be unloaded as long as the indicator is running.
The terminal should prepare data and monitor their updates, instead of the user thinking about the first date, how many bars I have and on the server, etc.
Michael, have you managed to overcome this problem with getting series from other symbols? I'm sick and tired of fighting with my indicator, it constantly loses synchronization with other symbols.
Right now the demo server is issuing Bild 1159 from June 22, 2015. And in it the multicurrency indicators also work horribly. You have to switch periods several times or restart the indicator to get it to display correctly. And after a while it doesn't get the series data again. I always write in the log.
To the developers:
Is it impossible to make a function, not to check if data is synchronized or not, but directly to synchronize and not to unload this data from memory?
Resource saving is good, in terms of algorithm optimization. But why should I be so fanatical about offloading data from memory?
I'd rather buy an additional gigabyte or two of memory in my PC instead of bothering with this bothersome series synchronization.
Make a function that is called once in OnInit() to load data for the required symbol and it will not be unloaded again until the indicator runs.
The terminal should prepare data and monitor their updates, instead of the user thinking about the first date, how many bars I have and on the server, etc.
Good afternoon!
The developers have replied that they will fix it in the new build.
It is not yet known when it will be released.
FORTS. I encountered a problem, functions OrderCheck() and OrderCalcMargin() sometimes (!) incorrectly determine the required GO for a trade and as a result return FALSE.
With the required GO for RTS-12.15(SYMBOL_MARGIN_INITIAL) of 12,500 , the function requires as much as 143,105 rubles!
At the same time everything opens perfectly manually.
How do I call:
Try it this way:
Here's my result: