Download MetaTrader 5

Can't get third buffer from CopyBuffer

To add comments, please log in or register
Deposit to your account via Visa QIWI Wallet
Eggo
86
Eggo 2015.03.28 21:44 

I want to get some values from my indicator to EA. But can get only from first buffer, how to get values from other buffers?

In example below, i try to get values from third buffer, and always get 4806 error. When I try to get from first buffer, everything is all right. I tested it in strategy tester

int OnInit()
  {
   Indicator=iCustom(NULL,0,"Indicat", InpReversalMode, InpPips, InpPercent, _suppRessPercent);
    if(Indicator> 0)
      {
       Print(Indicator);
      }

   return(INIT_SUCCEEDED);
  }

void OnTick()
  {
      bars=Bars(_Symbol,_Period);
      if(BarsCalculated(Indicator)==bars)
      {
         ArraySetAsSeries(value,true);
         ResetLastError();
         if(CopyBuffer(Indicator,2,0,3, value) <= -1)
         {
            Sleep(50);
            for(int i=0;i<100;i++)
            {
               if(BarsCalculated(Indicator)>0)
                  break;
               Sleep(50);
            }
            if(CopyBuffer(Indicator,2,0,3, value) == -1)
            {
               Print("Error getting buffer: ", GetLastError());
            }
         }
         else
            Print(" buffer copied successfully");
      }
 }

 



Stuart Browne
5816
Stuart Browne 2015.03.29 23:32  
Eggo:

I want to get some values from my indicator to EA. But can get only from first buffer, how to get values from other buffers?

In example below, i try to get values from third buffer, and always get 4806 error. When I try to get from first buffer, everything is all right. I tested it in strategy tester. 

 



Have another look at the iCustom documentation, in particular the "mode" parameter


 

double  iCustom(
   string       symbol,           // symbol
   int          timeframe,        // timeframe
   string       name,             // path/name of the custom indicator compiled program
   ...                            // custom indicator input parameters (if necessary)
   int          mode,             // line index
   int          shift             // shift
   );
To add comments, please log in or register