for (int i =::ArrayResize(TmpSort, ::ArraySize(ARRAY)) - 1; i >= 0; i--)
I do not advise you to write it this way. If the system fails to allocate the required amount of memory to the array, the program will continue to run quietly, leading to unpredictable consequences.
I do not advise you to write it this way. If the system fails to allocate the required amount of memory for the array, the program will continue to run quietly, leading to unpredictable consequences.
then get a detailed notification in case there is an error when running ArrayResize or ArrayCopy.
This allows you to see hard to identify problems in passing information through arrays, but even more importantly, get a message that the EA has stopped due to an array out of range(not the EA's fault). For example, because of a lack of memory or some other failure. In other words, you will know right away that an abnormal stopping of the EA took place, rather than accidentally notice it a few hours later.
The HistoryTicks library already contains this line (no need to add it), because the main purpose of the tools - fighting Expert Advisors on real accounts.
In the Terminal journal, there was only such a record in another project.
MemoryException 4471871064 bytes not available, 0 heapmin result
Thanks to the inserted line, the details of what has happened can be seen in the user log
Alert: ThirdPartyTicks - ERROR in int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint)! - see the logs.
int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 64: ::MQLInfoString(MQL_PROGRAM_PATH) = C:\Program Files\ICMarkets - MetaTrader 5\MQL5\Scripts\fxsaber\ThirdPartyTicks.ex5
PROGRAM_SCRIPTint ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 66: typename(T) = MqlTickint ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 67: sizeof(T) = 60int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 68: Res = -1int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 69: NewSize = 129140int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 70: Reserve = 74402041int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 71: ::ArraySize(Array) = 129139int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 72: PrevSize = 129139int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 73: NewSize*sizeof(T) = 7748400int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 74: PrevSize*sizeof(T) = 7748340int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 75: Reserve*sizeof(T) = 169155164int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 76: ::GetLastError() = 4004int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 77: DuringTime = 1195int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 79: ::TerminalInfoInteger(TERMINAL_BUILD) = 2138int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 80: ::TerminalInfoInteger(TERMINAL_DISK_SPACE) = 6344int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 81: ::TerminalInfoInteger(TERMINAL_MEMORY_PHYSICAL) = 16301int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 82: ::TerminalInfoInteger(TERMINAL_MEMORY_AVAILABLE) = 31530int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 83: ::TerminalInfoInteger(TERMINAL_MEMORY_TOTAL) = 32602int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 84: ::TerminalInfoInteger(TERMINAL_MEMORY_USED) = 1072int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 86: ::ChartID() = 132088214536525342int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 87: ::PeriodSeconds() = 60int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 88: ::Symbol() = EURUSD
int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 89: ::TimeCurrent() = 2019.09.1019:49:15int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 90: ::TimeLocal() = 2019.09.1019:49:12int ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 94: ::SymbolInfoTick(_Symbol,Tick) = true
time = 2019.09.1019:49:13.178 bid = 1.10436 ask = 1.10439 last = 0.00000 volume = 02TICK_FLAG_BIDint ARRAYRESIZE::ArrayResize_Real<MqlTick>(MqlTick&[],constint,constint), Line = 97: ::ChartSetInteger(0,CHART_BRING_TO_TOP,true) = true
array out of range in 'Array.mqh' (11,10)
Все продукты Маркета перед публикацией проходят обязательную предварительную проверку, так как небольшая ошибка в логике советника или индикатора может привести к убыткам на торговом счете. Именно поэтому нами разработана серия базовых проверок, призванных обеспечить необходимый уровень качества продуктов Маркета. Если в процессе проверки...
bool CheckMoneyForTrade(string symb,double lots,ENUM_ORDER_TYPE type)
{
//--- получим цену открытияMqlTick mqltick;
SymbolInfoTick(symb,mqltick);
double price=mqltick.ask;
if(type==ORDER_TYPE_SELL)
price=mqltick.bid;
//--- значения необходимой и свободной маржиdouble margin,free_margin=AccountInfoDouble(ACCOUNT_MARGIN_FREE);
//--- вызовем функцию проверкиif(!OrderCalcMargin(type,symb,lots,price,margin))
{
//--- что-то пошло не так, сообщим и вернем falsePrint("Error in ",__FUNCTION__," code=",GetLastError());
return(false);
}
//--- если не хватает средств на проведение операцииif(margin>free_margin)
{
//--- сообщим об ошибке и вернем falsePrint("Not enough money for ",EnumToString(type)," ",lots," ",symb," Error code=",GetLastError());
return(false);
}
//--- проверка прошла успешноreturn(true);
}
//--- вызовем функцию проверкиif(!OrderCalcMargin(type,symb,lots,price,margin))
{
//--- что-то пошло не так, сообщим и вернем falsePrint("Error in ",__FUNCTION__," code=",GetLastError());
return(false);
}
//--- если не хватает средств на проведение операцииif(margin>free_margin)
{
//--- сообщим об ошибке и вернем falsePrint("Not enough money for ",EnumToString(type)," ",lots," ",symb," Error code=",GetLastError());
return(false);
}
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 do not advise you to write it this way. If the system fails to allocate the required amount of memory to the array, the program will continue to run quietly, leading to unpredictable consequences.
I do not advise you to write it this way. If the system fails to allocate the required amount of memory for the array, the program will continue to run quietly, leading to unpredictable consequences.
I necessarily put it for the real account.
Forum on trading, automated trading systems and testing trading strategies
Libraries: HistoryTicks
fxsaber, 2019.09.10 18:58
Forum on trading, automated trading systems and trading strategy testing
Libraries: HistoryTicks
fxsaber, 2018.12.10 13:55
If you write the following line in the beginning of any MT4/5 Expert Advisorthen get a detailed notification in case there is an error when running ArrayResize or ArrayCopy.
This allows you to see hard to identify problems in passing information through arrays, but even more importantly, get a message that the EA has stopped due to an array out of range(not the EA's fault). For example, because of a lack of memory or some other failure. In other words, you will know right away that an abnormal stopping of the EA took place, rather than accidentally notice it a few hours later.
The HistoryTicks library already contains this line (no need to add it), because the main purpose of the tools - fighting Expert Advisors on real accounts.
In the Terminal journal, there was only such a record in another project.
Thanks to the inserted line, the details of what has happened can be seen in the user log
Please suggest an analog of MQL4 function MarketInfo(asymbol, MODE_MARGIN_REQUIRED) in MQL5.
I need to get the amount of free funds needed to open 1 lot to buy.
I tried different variants of SymbolInfoDouble(symbol, ...) function in MQL5, I can't find the right variant, it returns 0 everywhere.
Please suggest an analog of MQL4 function MarketInfo(asymbol, MODE_MARGIN_REQUIRED) in MQL5.
I need to get the amount of free funds needed to open 1 lot to buy.
I tried different variants of SymbolInfoDouble(symbol, ...) function in MQL5, I can't find the right variant, it returns 0 everywhere.
https://www.mql5.com/ru/articles/2555#not_enough_money
https://www.mql5.com/ru/articles/2555#not_enough_money
I'm sorry, I didn't understand why I needed this link. I didn't see the answer to my question there.
I'm sorry, I didn't understand why I needed this link. I didn't see the answer to my question there.
What exactly didn't you see in the article?
Examples of checking:
MQL5
What exactly didn't you see in the article?
Examples of checking:
MQL5
You need to getthe amount of free funds needed to open 1 lot to buy.
What does the check in the article have to do with it?
Need to getthe amount of available funds needed to open 1 lot to buy.
What does the check from the article have to do with it?
Because the article teaches diligent study of the material.
The example even gives you the full function to check before sending the trade order.
One:
and immediately the reference:
ACCOUNT_MARGIN_FREE
Size of free funds in the account in the deposit currency, available for position opening
AccountInfoDouble
and two is the minimum check:
Need to getthe amount of available funds needed to open 1 lot to buy.
What does the check from the article have to do with it?
didn't think you would have trouble reading the short code, then read the helphttps://www.mql5.com/ru/docs/trading/ordercalcmargin
While the article teaches diligent study of the material.
The example even gives the full function of checking before sending a trade order.
One:
and right away the reference:
ACCOUNT_MARGIN_FREE
Size of free funds in the account in the deposit currency, available for position opening
AccountInfoDouble
and two - minimum check:
Size of free funds in the account in the currency of deposit available to open the position I do not need
I calculate the lot size as % of the balance.
I need to get the amount ofavailable funds needed to open 1 lot to buy.