Download MetaTrader 5

Stack overflow strange error

To add comments, please log in or register
Bogdan Alin Baltatu
2927
Bogdan Alin Baltatu  

I have a strage problem.I call a code from an script and works fine and if i call from am EA i have 'stack overflow' error.

What causes this problem?


//Later

I recive stack overflow error on OrderSend function.

Documentation on MQL5: Trade Functions / OrderSend
  • www.mql5.com
Trade Functions / OrderSend - Documentation on MQL5
Slava
Moderator
6918
Slava  

Recursive calls?

Bogdan Alin Baltatu
2927
Bogdan Alin Baltatu  
Yes, i call OrderSend function for eatch positions.
Documentation on MQL5: Trade Functions / OrderSend
  • www.mql5.com
Trade Functions / OrderSend - Documentation on MQL5
Rashid Umarov
Admin
11994
Rashid Umarov  
dudufx:

Yes, i call OrderSend function for eatch positions.
You can see sample of a recursive call here - https://www.mql5.com/en/docs/common/GetTickCount
Documentation on MQL5: Common Functions / GetTickCount
  • www.mql5.com
Common Functions / GetTickCount - Documentation on MQL5
Bogdan Caramalac
1112
Bogdan Caramalac  
No Rosh, my pal got it wrong, the function with OrderSend is NOT recursive. I can't tell why it generates the stack overflow. If it moves the function block inside the caller, there is no error anymore.
Rashid Umarov
Admin
11994
Rashid Umarov  
Yo had better to write to Servicedesk with source code.
Get in touch with developers using Service Desk!
  • www.mql5.com
We therefore attach great importance to all user reports about issues in our programs and try to answer each one of them.
Slava
Moderator
6918
Slava  
TheEconomist:
No Rosh, my pal got it wrong, the function with OrderSend is NOT recursive. I can't tell why it generates the stack overflow. If it moves the function block inside the caller, there is no error anymore.

pure recursive call

void CTrade::OrderSend(MqlTradeRequest &request,MqlTradeResult &results)
{
   OrderSend(request,results);
}

right call

void CTrade::OrderSend(MqlTradeRequest &request,MqlTradeResult &results)
{
   ::OrderSend(request,results);
}

See scope resolution operation 

To add comments, please log in or register