Navigation´╝ÜHome > Content >

KC_trend_v1.mq4

Time: 2012-04-05 | Download file:KC_trend_v1.mq4

//+------------------------------------------------------------------+
//|                                                 TMA+KC+SLOPE.mq4 |
//|                                           Copyright 2012, SANFIC |
//|                                        http://www.san-fic.ru     |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, SANFIC"
#property link      "http://www.metaquotes.net"
#property indicator_minimum -0.1
#property indicator_maximum 1.1

#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 Green
#property indicator_width1 4
#property indicator_color2 Lime
#property indicator_width2 4
#property indicator_color3 Maroon
#property indicator_width3 4
#property indicator_color4 Red
#property indicator_width4 4





extern string TimeFrame       = "current time frame";
extern int    HalfLength      = 56;
extern int    HalfLength2     = 240;
extern int    Price           = 0;
extern int    ATRPeriod       = 100;
extern double  K = 2.0;
extern double ATRMultiplier   = 5.0;

double Buf_up1[];
double Buf_up2[];
double Buf_low1[];
double Buf_low2[];
double Buf_Cl[];
double Buf_Ul[];
double Buf_Cu[];
double Buf_Lu[];
double KC_C ;
double KC_U;
double KC_L;
double KC_u;
double KC_l; 



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
 SetIndexStyle(0,DRAW_HISTOGRAM);
 SetIndexBuffer(0,Buf_up1);
 SetIndexStyle(1,DRAW_HISTOGRAM);
 SetIndexBuffer(1,Buf_up2);
 SetIndexStyle(2,DRAW_HISTOGRAM);
 SetIndexBuffer(2,Buf_low1);
 SetIndexStyle(3,DRAW_HISTOGRAM);
 SetIndexBuffer(3,Buf_low2);
 
 SetIndexStyle(4,DRAW_NONE);
 SetIndexBuffer(4,Buf_Cl);
 SetIndexStyle(5,DRAW_NONE);
 SetIndexBuffer(5,Buf_Ul);
 SetIndexStyle(6,DRAW_NONE);
 SetIndexBuffer(6,Buf_Lu);
 SetIndexStyle(7,DRAW_NONE);
 SetIndexBuffer(7,Buf_Cu);
 
 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
     int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   
     
   
   for (int i=limit;i>=0;i--) {
   
   KC_C = iCustom(NULL,0,"KC",HalfLength2,Price,ATRPeriod,K,1,i);
   KC_U = iCustom(NULL,0,"KC",HalfLength2,Price,ATRPeriod,K,0,i);
   KC_L = iCustom(NULL,0,"KC",HalfLength2,Price,ATRPeriod,K,2,i);
   KC_u = iCustom(NULL,0,"KC",HalfLength,Price,ATRPeriod,K,0,i);
   KC_l = iCustom(NULL,0,"KC",HalfLength,Price,ATRPeriod,K,2,i);
   
   Buf_Cl[i] = KC_l - KC_C;
   Buf_Ul[i] = KC_l - KC_U;
   Buf_Cu[i] = KC_C - KC_u;
   Buf_Lu[i] = KC_L - KC_u;
 
    
   if (Buf_Cl[i] > 0 && Buf_Ul[i] < 0 )
   {
   Buf_up1[i]=1;   
   Buf_up2[i]=EMPTY_VALUE;
   Buf_low1[i]=EMPTY_VALUE;
   Buf_low2[i]=EMPTY_VALUE;   
   }
   
   if (Buf_Cl[i] > 0 && Buf_Ul[i] > 0 )
   {
   Buf_up1[i]=EMPTY_VALUE;   
   Buf_up2[i]=1;
   Buf_low1[i]=EMPTY_VALUE;
   Buf_low2[i]=EMPTY_VALUE;   
   }
   
   if (Buf_Cu[i] > 0 && Buf_Lu[i] < 0 )
   {
   Buf_up1[i]=EMPTY_VALUE;   
   Buf_up2[i]=EMPTY_VALUE;
   Buf_low1[i]=1;
   Buf_low2[i]=EMPTY_VALUE;   
   }
   if (Buf_Cu[i] > 0 && Buf_Lu[i] > 0 )
   {
   Buf_up1[i]=EMPTY_VALUE;   
   Buf_up2[i]=EMPTY_VALUE;
   Buf_low1[i]=EMPTY_VALUE;
   Buf_low2[i]=1;   
   }
   }
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Recommend