Check your error codes here - https://book.mql4.com/appendix/errors
ERR_REMAINDER_FROM_ZERO_DIVIDE | 4012 | Remainder from zero divide. |
![Error Codes - Appendixes - MQL4 Tutorial Error Codes - Appendixes - MQL4 Tutorial](https://c.mql5.com/36/11/error-codes-appendixes-mql4-tutoria__1.png)
honest_knave:
I'm in MT5. And, sorry, the error code is ERR_FUNCTION_NOT_ALLOWED 4014. Not 4012 as I originally posted.
Check your error codes here - https://book.mql4.com/appendix/errors
ERR_REMAINDER_FROM_ZERO_DIVIDE | 4012 | Remainder from zero divide. |
Roberto Jacobs:
Maybe you need to check ENUM_TERMINAL_INFO_INTEGER = TERMINAL_TRADE_ALLOWED OR IsTradeAllowed()
Maybe you need to check ENUM_TERMINAL_INFO_INTEGER = TERMINAL_TRADE_ALLOWED OR IsTradeAllowed()
Both MessageBox() and OrderSend() functions return Error 4014 from my OnTimer:
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
EventSetTimer(1);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
return(rates_total);
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
Alert(ENUM_TERMINAL_INFO_INTEGER(TERMINAL_TRADE_ALLOWED));
MessageBox("Check", "Query",MB_OKCANCEL);
Alert(GetLastError());
MqlTradeRequest request={0};
MqlTradeResult result={0};
OrderSend(request,result);
Alert(GetLastError());
EventKillTimer();
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
EventSetTimer(1);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
return(rates_total);
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
Alert(ENUM_TERMINAL_INFO_INTEGER(TERMINAL_TRADE_ALLOWED));
MessageBox("Check", "Query",MB_OKCANCEL);
Alert(GetLastError());
MqlTradeRequest request={0};
MqlTradeResult result={0};
OrderSend(request,result);
Alert(GetLastError());
EventKillTimer();
}
//+------------------------------------------------------------------+
Surprisingly it's what is stated in the documentation
![](https://c.mql5.com/3/114/surprised.gif)
Alain Verleyen:
Surprisingly it's what is stated in the documentation
Ah, the damned documentation again :) So much of it to read, so easy to miss something. I'm trying to be a good student, honest... but even the best students might need a little support now again again right?. Thanks again for your help everyone.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Can I not use SendOrder() in the OnTimer() function?
I want to look for a local file and then send an order when it appears. I have the code, but the function returns 4014.
Thanks.