buffer issues :( - page 3

 

Thanx Raptor for your advice...I have used the print statements as you instructed and found that no matter which color block is plotted on the chart

the values of those buffers do not change...the 5min red is always 0 and the 5min blue is always 4 even if i look back to the [1] or [2] candles values.

this helps me see why the indy wasnt alerting properly...

now my (inevitable) questions is how the heck do I code an alerter for this indy? I have done an alerter before that used a comparison of buffers and it worked fine...

so now im stumped as to how to proceed...some guidance /suggestions as to how I can code an alerter for this indicator would be much appreciated.

also want to take a moment to thank you all (especially Raptor and Dabbler) for their assistance...and ENDLESS patience :)

thanks guys...

any advice on how to proceed would be gratefully and humbly accepted

 

Can you please show the code you are currently using for your iCustom calls . . .

I think you maybe looking at the wrong buffers . . . buffer 0 is buf4_up i.e. H1 if you are on a M5 chart

 
//+------------------------------------------------------------------+
//|                                          BUFFER CHANGE ALERT.mq4 |
//|                                                                . |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "."
#property link      ""

#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int   counted_bars=IndicatorCounted();
//----
      int h     =TimeHour(TimeCurrent());
      int m     =TimeMinute(TimeCurrent());
      int total = OrdersTotal();

   double red5current    = iCustom(Symbol(),0,"4 TF HAS Bar",2,6,3,2,0,Blue,Red,White,500,1,1); // RED 5 min
   double blue5current   = iCustom(Symbol(),0,"4 TF HAS Bar",2,6,3,2,0,Blue,Red,White,500,0,1); // BLUE 5 min
   
   double red5last       = iCustom(Symbol(),0,"4 TF HAS Bar",2,6,3,2,0,Blue,Red,White,500,1,2); // previous RED 5 min
   double blue5last      = iCustom(Symbol(),0,"4 TF HAS Bar",2,6,3,2,0,Blue,Red,White,500,0,2); // previous BLUE 5 min
   
   double red15current   = iCustom(Symbol(),0,"4 TF HAS Bar",2,6,3,2,0,Blue,Red,White,500,2,1); // RED 15 min
   double blue15current  = iCustom(Symbol(),0,"4 TF HAS Bar",2,6,3,2,0,Blue,Red,White,500,3,1); // BLUE 15 min
   
   double red15last      = iCustom(Symbol(),0,"4 TF HAS Bar",2,6,3,2,0,Blue,Red,White,500,2,2); // previous RED 15 min
   double blue15last     = iCustom(Symbol(),0,"4 TF HAS Bar",2,6,3,2,0,Blue,Red,White,500,3,2); // previous BLUE 15 min
   
//----
if(red15last>blue15last)
   {
  Print("is blue5current ", blue5current, " > red5current ? ", red5current);
   if(blue5last>red5last)
      {
    //  Print("is blue5current ", blue5current, " < red5current ? ", red5current);   // add this . . .  run and check the experts/journal tab
      if(blue5current<red5current)
         {
         AlertOnce("15min RED , 5min BLUE",1);
         return(0);
         }
      }
   }



//----
   return(0);
  }
//+------------------------------------------------------------------+
bool AlertOnce(string alert_msg,int ref)
{
static int LastAlert_1 =0;
static int LastAlert_2 =0;
static int LastAlert_3 =0;
static int LastAlert_4 =0;

switch(ref)
{
case 1:
if(LastAlert_1==0 || LastAlert_1 < Bars)
{
Alert(alert_msg);
LastAlert_1=Bars;
return(1);
}
break;

case 2:
if(LastAlert_2==0 || LastAlert_2< Bars)
{Alert(alert_msg);
LastAlert_2=Bars;
return(1);
}
break;

case 3:
if(LastAlert_3==0 || LastAlert_3< Bars)
{Alert(alert_msg);
LastAlert_3=Bars;
return(1);
}
break;

case 4:
if(LastAlert_4==0 || LastAlert_4< Bars)
{Alert(alert_msg);
LastAlert_4=Bars;
return(1);
}
break;
}
}

/*



*/
 

I ran a script with buffers set as in the code above the same as the code in this post and it works fine as a script...but just wont work as an alerter...

heres what worked fine as a script (it alerts perfectly as to what the colors are over the 3 criteria (colors of : 15min candle[1], 5min candle[2], 5min candle[1]) ...but the minute I try use the exact same comparison criteria in the same format as this script in an alert indicator ...then it wont do a thing)

//+------------------------------------------------------------------+
//|                                                  Buffer test.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "."
#property link      ""


//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
   int h=TimeHour(TimeCurrent());
   int m=TimeMinute(TimeCurrent());

   double red5current    = iCustom(Symbol(),0,"4 TF HAS Bar",2,6,3,2,0,Blue,Red,White,500,1,1); // RED 5 min
   double blue5current   = iCustom(Symbol(),0,"4 TF HAS Bar",2,6,3,2,0,Blue,Red,White,500,0,1); // BLUE 5 min
   
   double red5last       = iCustom(Symbol(),0,"4 TF HAS Bar",2,6,3,2,0,Blue,Red,White,500,1,2); // previous RED 5 min
   double blue5last      = iCustom(Symbol(),0,"4 TF HAS Bar",2,6,3,2,0,Blue,Red,White,500,0,2); // previous BLUE 5 min
   
   double blue15current  = iCustom(Symbol(),0,"4 TF HAS Bar",2,6,3,2,0,Blue,Red,White,500,3,1); // BLUE 15 min 
   double blue15last     = iCustom(Symbol(),0,"4 TF HAS Bar",2,6,3,2,0,Blue,Red,White,500,3,2); // BLUE 15 min last candle [2]
   
   double red15current   = iCustom(Symbol(),0,"4 TF HAS Bar",2,6,3,2,0,Blue,Red,White,500,2,1); // RED 15 min
   double red15last      = iCustom(Symbol(),0,"4 TF HAS Bar",2,6,3,2,0,Blue,Red,White,500,2,2); // previous RED 15 min [2]
   
  if(red15current<blue15current)
   {
  AlertOnce("15min is RED",1);
   }
   else{
    AlertOnce("15min is BLUE",2);
   }
   
     if(red5last<blue5last)
   {
   AlertOnce("Previous 5min is BLUE",3);
   }
   else{
    AlertOnce("Previous 5min is RED",4);
   }
   
   if(red5current<blue5current)
   {
  AlertOnce("Last Closed 5min is BLUE",5);
   }
   else{
   AlertOnce("Last Closed 5min is RED",6);
   }
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
bool AlertOnce(string alert_msg,int ref)
{
static int LastAlert_1 =0;
static int LastAlert_2 =0;
static int LastAlert_3 =0;
static int LastAlert_4 =0;
static int LastAlert_5 =0;
static int LastAlert_6 =0;

switch(ref)
{
case 1:
if(LastAlert_1==0 || LastAlert_1 < Bars)
{
Alert(alert_msg);
LastAlert_1=Bars;
return(1);
}
break;

case 2:
if(LastAlert_2==0 || LastAlert_2< Bars)
{Alert(alert_msg);
LastAlert_2=Bars;
return(1);
}
break;

case 3:
if(LastAlert_3==0 || LastAlert_3< Bars)
{Alert(alert_msg);
LastAlert_3=Bars;
return(1);
}
break;

case 4:
if(LastAlert_4==0 || LastAlert_4< Bars)
{Alert(alert_msg);
LastAlert_4=Bars;
return(1);
}
break;

case 5:
if(LastAlert_5==0 || LastAlert_5< Bars)
{Alert(alert_msg);
LastAlert_5=Bars;
return(1);
}
break;

case 6:
if(LastAlert_6==0 || LastAlert_6< Bars)
{Alert(alert_msg);
LastAlert_6=Bars;
return(1);
}
break;
}
}
Reason: