Navigation:Home > Content >

LeManSignal2.mq4

Time: 2011-09-04 | Download file:LeManSignal2.mq4

//+------------------------------------------------------------------+
//|                                                  LeManSignal.mq4 |
//|                                         Copyright © 2009, LeMan. |
//|                                                 [email protected] |
//+------------------------------------------------------------------+
//mod
#property copyright "Copyright © 2009, LeMan."
#property link      "[email protected]"
//----
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 Green
#property indicator_color4 Red

#property indicator_width1 2
#property indicator_width2 2
#property indicator_style3 2
#property indicator_style4 2
//----
extern int N    = 12;
//----
double OpenUp[];
double OpenDown[];

double OpenUpLv[];
double OpenDownLv[];


//+------------------------------------------------------------------+
int init() {
//----
   string short_name;
//----
   IndicatorDigits(Digits);
   IndicatorBuffers(4);
//----
   short_name = "LeManSignal ("+N+")";
   IndicatorShortName(short_name);
//----      
   SetIndexBuffer(0,OpenUp);
   SetIndexBuffer(1,OpenDown);  

   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);     
                 
   SetIndexStyle(0,DRAW_ARROW,EMPTY,2);
   SetIndexArrow(0,159);
   SetIndexStyle(1,DRAW_ARROW,EMPTY,2);
   SetIndexArrow(1,159);

   SetIndexLabel(0, "Open Buy");
   SetIndexLabel(1, "Open Sell");   
 
 
 
   SetIndexBuffer(2,OpenUpLv);
   SetIndexBuffer(3,OpenDownLv);  

   SetIndexLabel(2, "Open Buy /SL lvl");
   SetIndexLabel(3, "Open Sell /SL lvl");   
 
 
      
//----
   return(0);
}
//+------------------------------------------------------------------+
int start() { 
   
   double LevelStop = MarketInfo(Symbol(),14);    

   int counted_bars = IndicatorCounted();      
   if (counted_bars > 0) counted_bars--;

   int limit;
   limit = Bars - counted_bars;
  
   for (int i = limit; i >= 0; i--) {
            
      double H1 = iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, N, i+1));
      double H2 = iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, N, i+1+N));
      double H3 = iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, N, i+2));
      double H4 = iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, N, i+2+N));      
      double L1 = iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, N, i+1));
      double L2 = iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, N, i+1+N));
      double L3 = iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, N, i+2));
      double L4 = iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, N, i+2+N));      
      
      
      OpenUpLv[i] = OpenUpLv[i+1];        OpenDownLv[i] = OpenDownLv[i+1];

      OpenUp[i] = EMPTY_VALUE;            OpenDown[i] = EMPTY_VALUE;
            
      // Условие покупки                       
      if (H3 <= H4 && H1 > H2) {
         OpenUp[i] = High[i+1] + Point;
         OpenUpLv[i]  =OpenUp[i];
      }
      // Условие продажи      
      if (L3 >= L4 && L1 < L2) {
         OpenDown[i] = Low[i+1] - Point;         
         OpenDownLv[i]=OpenDown[i];
      }    

  }
   
//----
   return(0);
}
//+------------------------------------------------------------------+

Recommend