SendOrder() not allowed in OnTimer()?
Check your error codes here - https://book.mql4.com/appendix/errors
| ERR_REMAINDER_FROM_ZERO_DIVIDE | 4012 | Remainder from zero divide. |
Check your error codes here - https://book.mql4.com/appendix/errors
| ERR_REMAINDER_FROM_ZERO_DIVIDE | 4012 | Remainder from zero divide. |
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:
//+------------------------------------------------------------------+
//| 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();
}
//+------------------------------------------------------------------+
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.
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.