Download MetaTrader 5
To add comments, please log in or register
Sign up for MQL5.community to leave your comments!
George Goudinakis
120
George Goudinakis 2014.03.05 19:32 

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
Moderator
30282
Alain Verleyen 2014.03.05 19:34  

Hello,

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


This time, I edited it for you.

Alain Verleyen
Moderator
30282
Alain Verleyen 2014.03.05 19:36  
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 2014.03.06 03:40  
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 2014.03.06 03:43  
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