problem with iCustom, thanks for who answers me!

 

hello, I was implementing an indicator in my EA, but I don't understand why it takes only the buffer of the long and not of the short, I send you below the codes to understand what I have done.

Thanks for whoever answers me

Indicator init:

int init() {
   
   TimeFrame = fmax(TimeFrame,_Period);    
   SetIndexStyle(0, DRAW_ARROW, EMPTY);
   SetIndexArrow(0, 233);
   SetIndexBuffer(0, arrow_up); //buy
   SetIndexStyle(1, DRAW_ARROW, EMPTY);
   SetIndexArrow(1, 234);
   SetIndexBuffer(1, arrow_dn);  //sell
   return (0);
}
double ArrowDn=iCustom(NULL,PERIOD_CURRENT,INDI_ARROW,TimeFrame,FasterMovingAverage,SlowerMovingAverage,RSIPeriod,MagicFilterPeriod,BollingerbandsPeriod,
    BollingerbandsShift,BollingerbandsDeviation,BullsPowerPeriod,BearsPowerPeriod,Alerts,Utstup,1,0); //BUFFER DOWN 1
    
double ArrowUp=iCustom(NULL,PERIOD_CURRENT,INDI_ARROW,TimeFrame,FasterMovingAverage,SlowerMovingAverage,RSIPeriod,MagicFilterPeriod,BollingerbandsPeriod,
    BollingerbandsShift,BollingerbandsDeviation,BullsPowerPeriod,BearsPowerPeriod,Alerts,Utstup,0,0);  //BUFFER UP 0


EA: 
if (ArrowUp){
//code EA
}

if(ArrowDn){
//code EA
}


 

Post all relevant code.
     How To Ask Questions The Smart Way. (2004)
          Be precise and informative about your problem

  1. Can't verify iCustom calls since you didn't post any of the indicator's inputs.
  2. Can't verify iCustom calls since you didn't post whether the calls are inside OnTick or not.
 
William Roeder #:

Post all relevant code.
     How To Ask Questions The Smart Way. (2004)
          Be precise and informative about your problem

  1. Can't verify iCustom calls since you didn't post any of the indicator's inputs.
  2. Can't verify iCustom calls since you didn't post whether the calls are inside OnTick or not.

Hi thanks for replying, I solved the problem that it did not enter short, but another one has arisen.

Now I'm sending you the code directly, anyway

Indicator: 


#property copyright ""
#property link      ""
#property indicator_buffers 5
#property indicator_color1 Yellow
#property indicator_color2 Red
#property indicator_color3 Blue
// The color for displaying arrows
#property indicator_color4 Green       // Long signal
#property indicator_color5 Red         // Short signal

#property indicator_width1 1
#property indicator_width2 3
#property indicator_width3 3
// Width of the arrows
#property indicator_width4 2  // Long signal arrow
#property indicator_width5 2  // Short signal arrow

extern int Lb = 3;
extern int Arrow_Distance = 5;
double ssla[],sslb[],sslc[],Up_Arrow_Buffer[],Down_Arrow_Buffer[],Hld,Hlv,Hlvprev;

#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(5);
   SetIndexBuffer(0,sslc);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID);
   SetIndexBuffer(1,ssla);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID);
   SetIndexBuffer(2,sslb);
   SetIndexStyle(2,DRAW_LINE,STYLE_SOLID);
   SetIndexStyle(3, DRAW_ARROW);
   SetIndexBuffer(3, Up_Arrow_Buffer);
   SetIndexArrow(3, 233); // Up arrow
   SetIndexStyle(4, DRAW_ARROW);
   SetIndexBuffer(4, Down_Arrow_Buffer);
   SetIndexArrow(4, 234); // Down arrow
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
 
//----
   for(int i=Bars-Lb;i>=0;i--)
   {
      if(Close[i]>iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_HIGH,i+1))
      Hld = 1;
      else 
      {
       if(Close[i]<iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_LOW,i+1))  
       Hld = -1;
       else
       Hld = 0;
      }
      
      if(Hld!=0)
      Hlv = Hld;
            
      if(Hlv == -1){
         sslc[i] = iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_HIGH,i+1);
         ssla[i] = iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_HIGH,i+1);
         
      }else{
         sslc[i] = iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_LOW,i+1);
         sslb[i] = iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_LOW,i+1);
         
         
      }
   }
   
   for(i=Bars-Lb;i>=0;i--)
   {
      if(sslb[i] == iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_LOW,i+1) && sslb[i+1] != iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_LOW,i+2))
      {
         Up_Arrow_Buffer[i] = sslb[i] - (Arrow_Distance * Point);
 
         continue;
      }
      if(ssla[i] == iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_HIGH,i+1) && ssla[i+1] != iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_HIGH,i+2))
      {
         Down_Arrow_Buffer[i] = ssla[i] + (Arrow_Distance * Point);
         continue;
      }
      Up_Arrow_Buffer[i] = EMPTY_VALUE;
      Down_Arrow_Buffer[i] = EMPTY_VALUE;
   }
  
//----
   return(0);
  }
//+------------------------------------------------------------------+




EA: 

extern double lb = 3;

double Get_TFT_Yellow_Value(int index)
{
   return (iCustom(NULL, 0, "TFT_Arrows", lb, 3, 0, index));
}

double Get_TFT_Red_Value(int index)
{
   return (iCustom(NULL, 0, "TFT_Arrows", lb, 3, 1, index));
}

double Get_TFT_Blue_Value(int index)
{
   return (iCustom(NULL, 0, "TFT_Arrows", lb, 3, 2, index));
}

double Get_TFT_UpArrow_Value(int index)
{
   return (iCustom(NULL, 0, "TFT_Arrows", lb, 3, 3, index));
}

double Get_TFT_DownArrow_Value(int index)
{
   return (iCustom(NULL, 0, "TFT_Arrows", lb, 3, 4, index));
}

bool TFT_SaysBuy()
{
   if (Get_TFT_UpArrow_Value(0)  != EMPTY_VALUE  && Get_TFT_Blue_Value(0) )
   {
      return (true);
   }
   else if(Get_TFT_Yellow_Value(0)){
   return (false);
   }
   return (false);
}

bool TFT_SaysSell()
{
   if (Get_TFT_DownArrow_Value(0)  != EMPTY_VALUE  && Get_TFT_Red_Value(0))
   {
      return (true);
   }
  else if(Get_TFT_Yellow_Value(0)){
   return (false);
   }
   return (false);
}


void OnTick ()
{
  if ( TFT_SaysBuy())
   {
   //code...
   }

 if (TFT_SaysSell())
   {
   //code...
   }
}


I do not see a condition given to this entry ..




 
   if (Get_TFT_UpArrow_Value(0)  != EMPTY_VALUE  && Get_TFT_Blue_Value(0) )
   {
      return (true);
   }
   else if(Get_TFT_Yellow_Value(0)){
True is non-zero. EMPTY_VALUE is also non-zero. These are not valid tests.
 
William Roeder #:
True is non-zero. EMPTY_VALUE is also non-zero. These are not valid tests.

You're right, thanks.

Resolved.