как добавить индикатор в советник.

 

Подскажите пожалуйста, как добавить код индикатора в советник так, чтобы был доступен массив open[] в качестве цены выставляемого ордера, метод iCustom не подходит.

спасибо.

код индикатора:

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot LRMA
#property indicator_label1  "LRMA"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrBlue
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2
//--- input parameters
input int      LRMAPeriod=14; // Period LRMA
//--- indicator buffers
double         LRMABuffer[];
//#include <MovingAverages.mqh>
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,LRMABuffer,INDICATOR_DATA);
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);

   ArraySetAsSeries(LRMABuffer,true);
//---
   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[])
  {
//---
//   ArraySetAsSeries(LRMABuffer,true);
   ArraySetAsSeries(open,true);

   if(rates_total<=LRMAPeriod) return(0);
   int limit=rates_total-prev_calculated;
   if(limit>1)
     {
      ArrayInitialize(LRMABuffer,0.0);
      limit=rates_total-LRMAPeriod-1;
     }

   for(int pos=limit;pos>=0;pos--)
     {
      LRMABuffer[pos]=LRMA(pos,LRMAPeriod,open);
      //      Print("Bar(",pos,")=", LRMABuffer[pos]);
     }

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+\\
// Calculate LRMA
//+------------------------------------------------------------------+\\
double LRMA(const int pos,const int period,const double  &price[])
  {
   double Res=0;
   double tmpS=0,tmpW=0,wsum=0;;
   for(int i=0;i<period;i++)
     {
      tmpS+=price[pos+i];
      tmpW+=price[pos+i]*(period-i);
      wsum+=(period-i);
     }
   tmpS/=period;
   tmpW/=wsum;
   Res=3.0*tmpW-2.0*tmpS;

   return(Res);
  }
//+------------------------------------------------------------------+


код советника:

#include <Trade\Trade.mqh>
#include <Trade\AccountInfo.mqh>
#include <R.mqh>

CTrade  ct;
CSymbolInfo cs;
CPositionInfo cp;
CAccountInfo ca;
CHistoryOrderInfo ch;
COrderInfo co;

double cl_arr_a[],hi_arr_a[],lo_arr_a[],op_arr_a[];

int    hdl_ma3=0;
double ma3_buf[];

int OnInit()
  {
      ct.SetTypeFilling(ORDER_FILLING_RETURN);
      ct.SetAsyncMode(true);

string sym1 = "USDRUB_TOM";
      
      hdl_ma3=iMA(sym1,PERIOD_M1,1,0,MODE_SMA,PRICE_OPEN);

      return(INIT_SUCCEEDED);
  }
  
  
void OnTick()
{

      MqlTick tick;
      if(!SymbolInfoTick(Symbol(),tick));   
 
string sym1 = "USDRUB_TOM";

      CopyBuffer(hdl_ma3,0,0,1,ma3_buf);
      

               ct.BuyLimit(1,ma3_buf[0],sym1,0,0,ORDER_TIME_DAY);
               ct.SellLimit(1,ma3_buf[0],sym1,0,0,ORDER_TIME_DAY);
}

нужно использовать open[0] в качестве цены выставляемого ордера, т.е.:

               ct.BuyLimit(1,open[0],sym1,0,0,ORDER_TIME_DAY);
               ct.SellLimit(1,open[0],sym1,0,0,ORDER_TIME_DAY);
 
Можно использовать CopyRates() или CopyOpen() если никакие другие значения не будут нужны.