LeManTrend





//+------------------------------------------------------------------+
//|                                                   LeManTrend.mq4 |
//|                                         Copyright © 2009, LeMan. |
//|                                                 b-market@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, LeMan."
#property link      "b-market@mail.ru"
//----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
//---- Âõîäíûå ïàðàìåòðû
extern int Min       = 13;
extern int Midle     = 21;
extern int Max       = 34;
extern int PeriodEMA = 3;
//---- Áóôåðû
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double TempBuffer1[];
double TempBuffer2[];

//+------------------------------------------------------------------+
int init() {
//----
   IndicatorDigits(Digits);
   IndicatorBuffers(4);
   
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexBuffer(2,TempBuffer1);                              
   SetIndexBuffer(3,TempBuffer2);                              

   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE); 
   
   SetIndexDrawBegin(0,Max);           
   SetIndexDrawBegin(1,Max);           
//----
   return(0);
}
//+------------------------------------------------------------------+
int deinit() {
//----  
   
//----
   return(0);
}
//+------------------------------------------------------------------+
int start() {
//----
   int i, counted_bars = IndicatorCounted();
//----
   if (Bars <= Max) {
      return(0);
   }
//---- initial zero
   if (counted_bars < 1) {
      for(i=1; i<=Max; i++) {
         ExtMapBuffer1[Bars-i] = 0.0;
         ExtMapBuffer2[Bars-i] = 0.0;
      }
   }
//----
   i = Bars-counted_bars-1;
//----
   while(i >= 0) {
      double High1 = iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, Min,i+1));
      double High2 = iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, Midle,i+1));
      double High3 = iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, Max,i+1));    
      TempBuffer1[i] = ((High[i]-High1)+(High[i]-High2)+(High[i]-High3));
      double Low1 = iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, Min, i+1));
      double Low2 = iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, Midle, i+1));
      double Low3 = iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, Max, i+1));    
      TempBuffer2[i] = ((Low1-Low[i])+(Low2-Low[i])+(Low3-Low[i]));
      i--;
   } 
   if (counted_bars > 0) {
      counted_bars--;
   }
   int limit = Bars-counted_bars;   

   for(i=0; i<limit; i++) {
      if (PeriodEMA > 0 ) {
         ExtMapBuffer1[i] = iMAOnArray(TempBuffer1,Bars,PeriodEMA,0,MODE_EMA,i);
         ExtMapBuffer2[i] = iMAOnArray(TempBuffer2,Bars,PeriodEMA,0,MODE_EMA,i);
      } else {
         ExtMapBuffer1[i] = TempBuffer1[i];
         ExtMapBuffer2[i] = TempBuffer2[i];      
      }
   }
//----     
   return(0);
  }
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:

Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar


Indicator Curves created:


Implements a curve of type DRAW_LINE

Indicators Used:

Moving average indicator


Custom Indicators Used:

Order Management characteristics:

Other Features: