iCustom - page 2

 
William Roeder #:

You are testing against zero. Does the indicator use zero for empty instead of EMPTY_VALUE?

//--- indicator buffers mapping
   SetIndexBuffer(0,BufferUP1,INDICATOR_DATA);
   SetIndexBuffer(1,BufferDN1,INDICATOR_DATA);
   SetIndexBuffer(2,BufferUP2,INDICATOR_DATA);
   SetIndexBuffer(3,BufferDN2,INDICATOR_DATA);
   SetIndexBuffer(4,BufferUP3,INDICATOR_DATA);
   SetIndexBuffer(5,BufferDN3,INDICATOR_DATA);
   SetIndexBuffer(6,BufferMA11,INDICATOR_CALCULATIONS);
   SetIndexBuffer(7,BufferMA12,INDICATOR_CALCULATIONS);
   SetIndexBuffer(8,BufferMA13,INDICATOR_CALCULATIONS);
   SetIndexBuffer(9,BufferMA21,INDICATOR_CALCULATIONS);
   SetIndexBuffer(10,BufferMA22,INDICATOR_CALCULATIONS);
   SetIndexBuffer(11,BufferMA31,INDICATOR_CALCULATIONS);
   SetIndexBuffer(12,BufferMA32,INDICATOR_CALCULATIONS);
   SetIndexBuffer(13,BufferATR,INDICATOR_CALCULATIONS);
//--- setting a code from the Wingdings charset as the property of PLOT_ARROW
   PlotIndexSetInteger(0,PLOT_ARROW,225);
   PlotIndexSetInteger(1,PLOT_ARROW,226);
   PlotIndexSetInteger(2,PLOT_ARROW,225);
   PlotIndexSetInteger(3,PLOT_ARROW,226);
   PlotIndexSetInteger(4,PLOT_ARROW,225);
   PlotIndexSetInteger(5,PLOT_ARROW,226);
//--- setting indicator parameters
   IndicatorSetString(INDICATOR_SHORTNAME," POWERED BY HFT");
   IndicatorSetInteger(INDICATOR_DIGITS,Digits());
//--- setting buffer arrays as timeseries
   ArraySetAsSeries(BufferUP1,true);
   ArraySetAsSeries(BufferDN1,true);
   ArraySetAsSeries(BufferUP2,true);
   ArraySetAsSeries(BufferDN2,true);
   ArraySetAsSeries(BufferUP3,true);
   ArraySetAsSeries(BufferDN3,true);
//---
   ArraySetAsSeries(BufferMA11,true);
   ArraySetAsSeries(BufferMA12,true);
   ArraySetAsSeries(BufferMA13,true);
   ArraySetAsSeries(BufferMA21,true);
   ArraySetAsSeries(BufferMA22,true);
   ArraySetAsSeries(BufferMA31,true);
   ArraySetAsSeries(BufferMA32,true);
   ArraySetAsSeries(BufferATR,true);

here is the buffer mapping of the indicator, Kindly help me out i want to call Buffer UP3 and Buffer DN3 

#include <Trade/Trade.mqh>
#include <Trade/OrderInfo.mqh>
#include <Trade/PositionInfo.mqh>

//--- input parameters
input double Lots      = 0.1;
input int StopLoss     = 100;
input int TakeProfit   = 50; 
input int TrailingStop = 0;

// Miscellaneous
input string OrderComment = "PROJECT";

//---
int    handle_iCustom; // variable for storing the handle of the iCustom indicator

// Main trading objects
CTrade trade;
CPositionInfo PositionInfo;

// Global variables
// Common
bool HaveLongPosition;
bool HaveShortPosition;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
 //--- create handle of the indicator iCustom
   handle_iCustom=iCustom(Symbol(),Period(),"Any custom indicator");
//--- if the handle is not created
   if(handle_iCustom==INVALID_HANDLE)
     {
      //--- tell about the failure and output the error code
      PrintFormat("Failed to create handle of the iCustom indicator for the symbol %s/%s, error code %d",
                  Symbol(),
                  EnumToString(Period()),
                  GetLastError());
      //--- the indicator is stopped early
      return(INIT_FAILED);
     }
//---
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   double up[],down[];
   ArraySetAsSeries(up,true);
   ArraySetAsSeries(down,true);
   int start_pos=0,count=3;
   if(!iGetArray(handle_iCustom,0,start_pos,count,up) ||
      !iGetArray(handle_iCustom,1,start_pos,count,down))
     {
      return;
     }
//---
double Ask = SymbolInfoDouble(Symbol(), SYMBOL_ASK);
   if(up[0]!=EMPTY_VALUE)
     {
      //--- signal "Up" in bar #0
      int d=0;
      Print(__FUNCTION__,"> New Buy signal trade");
      trade.Buy(1);
     }
   if(up[1]!=EMPTY_VALUE)
     {
      //--- signal "Up" in bar #1
      int d=0;
     }
double Bid = SymbolInfoDouble(Symbol(), SYMBOL_BID);     
   if(down[0]!=EMPTY_VALUE)
     {
      //--- signal "Down" in bar #0
      int d=0;
      Print(__FUNCTION__,"> New Sell signal trade");
      trade.Sell(1);
     }
   if(down[1]!=EMPTY_VALUE)
     {
      //--- signal "Down" in bar #1
      int d=0;
     }
  }
//+------------------------------------------------------------------+
//| Get value of buffers                                             |
//+------------------------------------------------------------------+
bool iGetArray(const int handle,const int buffer,const int start_pos,
               const int count,double &arr_buffer[])
  {
   bool result=true;
   if(!ArrayIsDynamic(arr_buffer))
     {
      PrintFormat("ERROR! EA: %s, FUNCTION: %s, this a no dynamic array!",__FILE__,__FUNCTION__);
      return(false);
     }
   ArrayFree(arr_buffer);
//--- reset error code
   ResetLastError();
//--- fill a part of the iBands array with values from the indicator buffer
   int copied=CopyBuffer(handle,buffer,start_pos,count,arr_buffer);
   if(copied!=count)
     {
      //--- if the copying fails, tell the error code
      PrintFormat("ERROR! EA: %s, FUNCTION: %s, amount to copy: %d, copied: %d, error code %d",
                  __FILE__,__FUNCTION__,count,copied,GetLastError());
      //--- quit with zero result - it means that the indicator is considered as not calculated
      return(false);
     }
   return(result);
  }
//+------------------------------------------------------------------+

i tried adding Main Trading Objects as well but