OrderCalcMargin() gives error - 4014: System function is not allowed to call

To add comments, please log in or register
George Goudinakis
120
George Goudinakis  

Could anyone shed some light on this error, I am adding an example code

#property indicator_chart_window
int OnInit()
{
    double dVol = 1.0;
    double dMargin = 0.0;
    double dAsk = SymbolInfoDouble(_Symbol, SYMBOL_ASK);

   if(!OrderCalcMargin(ORDER_TYPE_BUY,_Symbol,dVol,dAsk,dMargin)) {
        Print("Last error = ",GetLastError());//,": (OrderCalcMargin()) ",ErrorDescription(GetLastError()));
   }

   Print("dMargin = ",dMargin);

   return(INIT_SUCCEEDED);

}


Many thanks

George

Alain Verleyen
39032
Alain Verleyen  

Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.

Alain Verleyen
39032
Alain Verleyen  
geodeas:

Could anyone shed some light on this error, I am adding an example code



Many thanks

George

You can't call trading related functions in an indicator.

See https://www.mql5.com/en/docs/runtime/running

Documentation on MQL5: MQL5 programs / Program Running
Documentation on MQL5: MQL5 programs / Program Running
  • www.mql5.com
MQL5 programs / Program Running - Documentation on MQL5
George Goudinakis
120
George Goudinakis  
angevoyageur:

Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.

Thanks, I'll keep it in mind.
George Goudinakis
120
George Goudinakis  
angevoyageur:

You can't call trading related functions in an indicator.

See https://www.mql5.com/en/docs/runtime/running

OK, thank you.
To add comments, please log in or register