CoeffofLine

0
(0)
Name:
CoeffofLine
Author: Collector (2006.08.11 12:43)
Downloaded: 2766
Download:
CoeffofLine 1
 CoeffofLine.mq4 (3.1 Kb) View
CoeffofLine Indicator.
CoeffofLine 2
1 comment  To post a new comment, please log in or register

CoeffofLine_true :
//+------------------------------------------------------------------+
//| CoeffofLine_true.mq4 
//| Ramdass - Conversion only
//+------------------------------------------------------------------+

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2

extern int ndot = 5;
extern int CountBars=300;
//---- buffers
double Up[];
double Dw[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   IndicatorBuffers(3);
   SetIndexBuffer(0,Up);
   SetIndexBuffer(1,Dw);   
   SetIndexStyle(0,DRAW_HISTOGRAM,0,2); 
   SetIndexStyle(1,DRAW_HISTOGRAM,0,2);
//----
   IndicatorShortName("CoeffofLine_true(" + ndot + ")");   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| CoeffofLine_true                                                 |
//+------------------------------------------------------------------+
int start()
  {

   if (CountBars>=Bars) CountBars=Bars;
   SetIndexDrawBegin(0,Bars-CountBars+ndot+1);
   SetIndexDrawBegin(1,Bars-CountBars+ndot+1);
   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) {Up[shift]=cfl; Dw[shift]=0.0;}
    else {Dw[shift]=cfl; Up[shift]=0.0;}

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

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?



Author: Forex Wiki Team
We are a team of highly experienced Forex Traders [2000-2023] who are dedicated to living life on our own terms. Our primary objective is to attain financial independence and freedom, and we have pursued self-education and gained extensive experience in the Forex market as our means to achieve a self-sustainable lifestyle.