Can someone please find the mistake, thanks

 
//+------------------------------------------------------------------+
//|                                              Trend Run Alert.mq4 |
//|                                        Copyright © 2011, Jay Bee |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Jay Bee"
#property link      ""

#property indicator_chart_window

//--- buffers


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

   ObjectsDeleteAll(0, OBJ_LABEL);

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   
   if (counted_bars<0) return(-1);

   if (counted_bars>0) counted_bars--;
   
   int    pos=Bars-counted_bars-1;
   
   double dClose1,dClose2,dClose3;
   double 3SMA1,3SMA2,3SMA3;
 
  
   while(pos>=0)
      {
         dClose1 = Close[pos+1]; 
         dClose2 = Close[pos+2];
         dClose3 = Close[pos+3];
         
         3SMA1= iMA(NULL,0,3,0,0,PRICE_TYPICAL,pos+1); 
         3SMA2= iMA(NULL,0,3,0,0,PRICE_TYPICAL,pos+2); 
         3SMA3= iMA(NULL,0,3,0,0,PRICE_TYPICAL,pos+2); 
         
         if(dClose3>3SMA3 && dClose2>3SMA2 && dClose1>3SMA1)
         {
            ObjectsDeleteAll(0, OBJ_LABEL);
            ObjectCreate("UPTREND",OBJ_LABEL,0,0,0);
            ObjectSetText("UPTREND","UPTREND",10,"Times New Roman", Green);
            ObjectSet("UPTREND", OBJPROP_CORNER, 0);
            ObjectSet("UPTREND", OBJPROP_XDISTANCE, 5);
            ObjectSet("UPTREND", OBJPROP_YDISTANCE, 15);
         }
         
         else if(dClose3<3SMA3 && dClose2<3SMA2 && dClose1<3SMA1)
         {
            ObjectsDeleteAll(0, OBJ_LABEL);
            ObjectCreate("DOWNTREND",OBJ_LABEL,0,0,0);
            ObjectSetText("DOWNTREND","DOWNTREND",10,"Times New Roman", Red);
            ObjectSet("DOWNTREND", OBJPROP_CORNER, 0);
            ObjectSet("DOWNTREND", OBJPROP_XDISTANCE, 10);
            ObjectSet("DOWNTREND", OBJPROP_YDISTANCE, 30);
         }
                
            
         else
         {
            ObjectsDeleteAll(0, OBJ_LABEL);      
            ObjectCreate("CONGESTION",OBJ_LABEL,0,0,0);
            ObjectSetText("CONGESTION","CONGESTION",10,"Times New Roman", Yellow);
            ObjectSet("CONGESTION", OBJPROP_CORNER, 0);
            ObjectSet("CONGESTION", OBJPROP_XDISTANCE, 15);
            ObjectSet("CONGESTION", OBJPROP_YDISTANCE, 45);
         
         }       
                 
         
         pos--;
         
      }
              
         
      
   return(0);
  }

  
 
Whats the error?
 
zzuegg:
Whats the error?
Error Message 0: No error message in error message.
 

Is it not compiling?

Not doing what you want?

Unless you say what it's not doing how can anyone guess what it should do?

 

Its not showing correct status of the market when i checked it with the moving average and price, sometime it shows correct and sometimes not

I cant understand the error...!!

 
May be i didnt write correctly the iMA() func?
 
dabbler:
Error Message 0: No error message in error message.
  1. You're not printing any error messages so of course there is no error message in the journal.
  2.  if (counted_bars>0) counted_bars--;
    is unnecessary drop.
 
Jay007:

Hi Jay!

Look here:

         
         3SMA1= iMA(NULL,0,3,0,0,PRICE_TYPICAL,pos+1); 
         3SMA2= iMA(NULL,0,3,0,0,PRICE_TYPICAL,pos+2); 
         3SMA3= iMA(NULL,0,3,0,0,PRICE_TYPICAL,pos+2); 
         

Should say:         3SMA3= iMA(NULL,0,3,0,0,PRICE_TYPICAL,pos+3); 

 
acushnir:

Hi Jay!

Look here:


Thanks a lot, seems to work, will check manually also..))
 
acushnir:

Hi Jay!

Look here:


one more question, what if i dont want to compare it with given values, but with the values with one bar shift to the forward?
 
Jay007:

one more question, what if i dont want to compare it with given values, but with the values with one bar shift to the forward?
You can't read the future
Reason: