CoeffofLine_trueEdit





//+----------------------------------------------------------------+
//|                                          CoeffofLine_true.mq4  |
//|                                     Ramdass - Conversion only  |
//+----------------------------------------------------------------+
//http://codebase.mql4.com/ru/624
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1  Black
#property indicator_color2 Green
#property indicator_color3 Red
//----
extern int ndot = 5;
extern int CountBars = 300;
//---- buffers
double Work[];
double Up[];
double Dw[];
//+----------------------------------------------------------------+
//| Custom indicator initialization function                       |
//+----------------------------------------------------------------+
int init()
  {
//---- indicator line
   SetIndexBuffer(0, Work);
   SetIndexBuffer(1, Up);
   SetIndexBuffer(2, Dw);   
   SetIndexStyle(0, DRAW_NONE); 
   SetIndexStyle(1, DRAW_HISTOGRAM, 0, 2); 
   SetIndexStyle(2, DRAW_HISTOGRAM, 0, 2);
//----
   IndicatorShortName("CoeffofLine_true2(" + ndot + ")");
   SetIndexLabel(1,NULL);
   SetIndexLabel(2,NULL);      
//----
   if (CountBars >= Bars) 
       CountBars = Bars;
   SetIndexDrawBegin(0, Bars - CountBars + ndot + 1);
   SetIndexDrawBegin(1, Bars - CountBars + ndot + 1);
//----
   return(0);
  }
//+----------------------------------------------------------------+
//| CoeffofLine_true                                               |
//+----------------------------------------------------------------+
int start()
  {
   int i, shift, cnt; //counted_bars=IndicatorCounted();
   double TYVar, ZYVar, TIndicatorVar, ZIndicatorVar, M, N, AY, 
          AIndicator, cfl, cfl1;
//----
   if(Bars <= ndot) 
       return(0);
//----
   shift = CountBars - ndot - 1;
//----
   while(shift >= 0)
     {
       cfl1 = cfl;  
       TYVar = 0;
       ZYVar = 0;
       N = 0;
       M = 0;
       TIndicatorVar = 0;
       ZIndicatorVar = 0;
       //----
       for(cnt = ndot; cnt >= 1; cnt--) // n=5 -  ?? ???? ??????
         {
           ZYVar = ZYVar + (High[shift+cnt-1] + Low[shift+cnt-1]) / 
                            2*(ndot - cnt + 1);
           TYVar = TYVar + (High[shift+cnt-1] + Low[shift+cnt-1]) / 2;
           N = N + cnt*cnt; //????? 55
           M = M + cnt; //????? 15
           ZIndicatorVar = ZIndicatorVar + iMA(NULL, 0, ndot, 3, 
                           MODE_SMMA, PRICE_MEDIAN, 
                           shift + cnt - 1)*(ndot - cnt + 1);
           TIndicatorVar = TIndicatorVar + iMA(NULL, 0, ndot, 3, 
                           MODE_SMMA, PRICE_MEDIAN, 
                           shift + cnt - 1);
         }
       AY = (TYVar + (N - 2*ZYVar)*ndot / M) / M;
       AIndicator = (TIndicatorVar + (N - 2*ZIndicatorVar)*ndot / 
                     M) / M;
       //----
       if(Symbol() == "EURUSD" || Symbol() == "GBPUSD" || 
          Symbol() == "USDCAD" || Symbol() == "USDCHF" || 
          Symbol() == "EURGBP" || Symbol() == "EURCHF" || 
          Symbol() == "AUDUSD" || Symbol() == "EURAUD" || 
          Symbol() == "GBPCHF" || Symbol() == "NZDUSD")
         {
           cfl = (-1000)*MathLog(AY / AIndicator);
         }
       else 
         {
           cfl = (1000)*MathLog(AY / AIndicator);
         }
       //----
       if(cfl > cfl1) 
         {
           Work[shift] = cfl;
           Up[shift] = cfl; 
           Dw[shift] = 0.0;
         }
       else 
         {
           Work[shift] = cfl;
           Dw[shift] = cfl; 
           Up[shift] = 0.0;
         }
       shift--;
     }
   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_NONE
Implements a curve of type DRAW_HISTOGRAM

Indicators Used:

Moving average indicator


Custom Indicators Used:

Order Management characteristics:

Other Features: