bar lagging

Back to topics list To post a new topic, please log in or register
avatar
23
Memma30 2015.11.09 22:32
 

avatar
23
Memma30 2015.11.09 22:33 #
 
//-----------------------------------------
//               NewBarcode.mq4
//                 
//-----------------------------------------



#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//#property indicator_color1 Black
//#property indicator_color2 Black


extern bool UseSound=True;
extern bool TypeChart=True;
extern string NameFileSound="alert.wav";

//---- buffers
double Upbuffer[];
double Dnbuffer[];
//datetime currBars;

//double ExitLong[];
//double ExitShort[];
double point=0.0001;
//+------------------------------------------------------------------+

int init()
  {
   SetIndexBuffer(0,Upbuffer);
   SetIndexBuffer(1,Dnbuffer);

   SetIndexStyle(0,DRAW_ARROW);
   SetIndexStyle(1,DRAW_ARROW);

   SetIndexArrow(0,241);
   SetIndexArrow(1,242);

   SetIndexLabel(0,"Up Signal");
   SetIndexLabel(1,"Down Signal");
// SetIndexLabel(2,"Exit Long");
//SetIndexLabel(3,"Exit Short");
   point=0.0001;
   if(Digits<4){point=0.01;}

   return(0);
  }
//+------------------------------------------------------------------+
int deinit()
  {

   return(0);
  }
//+------------------------------------------------------------------+
int start()
  {
   double Range=0,AvgRange;

   for(int i=1; i<=5; i++)
     {
      AvgRange=AvgRange+(High[i]-Low[i]);
      Range=AvgRange/10;

      if(Close[i+1]>Open[i+1] && Close[i+2]>Open[i+2])
        {
         //Up[i+1]=Low[i+1]-Range*1.5;
         Upbuffer[i]=Low[i]-(Range*1.5 *point);
         if(i==1)Alert("Previous bar","Previous bar"); Print("Up Signal, Trade Next Bar");
        }

      //if (Close[i]<Open[i])
      if(Close[i+1]<Open[i+1] && Close[i+2]<Open[i+2])
        {
         Dnbuffer[i]=High[i]+(Range*1.5*point);
         if(i==1)Alert("Trade next bar","Trade next bar"); Print("Down Signal");
        }
     }

   return(0);

  }
//+------------------------------------------------------------------+

avatar
23
Memma30 2015.11.09 22:35 #
 
Please help current bar is not working correctly and producing lagging. Thank you
avatar
13009
WHRoeder 2015.11.10 15:34 #
 
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. for(int i=1; i<=5; i++){
       AvgRange=AvgRange+(High[i]-Low[i]);
       Range=AvgRange/10;
  3. SMA(5) is (v1+v2+v3+v4+v5)/5. Your code generates ((((V1/10+V2)/10+v3)/10+V4)/10+V5)/10 which is V5/10 to one percent.
  4. Memma30: current bar is not working correctly and producing lagging.
    You never look at the current bar
Back to topics list  

To add comments, please log in or register