Buy pending order problem - page 3

 
Dominik Egert #:
Sort of...

The usage of iMA is correct, and gives you a handle. You should create this in OnInit() and use it later with CopyBuffer ()


Your IndicatorCreate will create a second instance, one that is actually displayed on the chart, but has nothing to do with iMA, they are both different instances of the same indicator.


Thank you Dominik it opens buy & sell orders.

int OnInit()
 {
  ResetLastError();
  
  if(!m_symbol.Name(Symbol()))
  {
   return(INIT_FAILED);
  }
   
  trade.SetExpertMagicNumber(MagicNumber);
  trade.SetMarginMode();
  trade.SetTypeFillingBySymbol(m_symbol.Name());
  
  MAClose=iMA(_Symbol,0,PeriodIndicator,0,MODE_LWMA,PRICE_CLOSE);
  
  
  return(INIT_SUCCEEDED);
 }
double MA[];
ArraySetAsSeries(MA,true);
CopyBuffer(MAClose,0,0,Bars(Symbol(),Period()),MA);