0
(0)
Nomen:
HVR [ ru | cn ]
Author: Scriptor (2008.02.11 10:02)
Downloaded: 1206
Download:
HVR 1
HVR.mq4 (2.9 Kb) Visum
Author: Albert, (idea and code into MQL2 - podval)

HVR indicator.

HVR 2
1 comment Ut post novum comment, quaeso log in or * mandare

The following code displays both 6 & 10 HVR with 100 (all periods as params). Also for more periods on chart.

//+------------------------------------------------------------------+ 
//|                                                          HVR.mq4 | 
//|      Copyright © 2005, Albert,(idea and code into MQL2 - podval) | 
//|      Refactored © 2010, Brewmanz (addere 2 HVR lines)               | 
//|                                                                  | 
//+------------------------------------------------------------------+ 
#property indicator_separate_window
//----
//#property indicator_minimum 0
//#property indicator_maximum 3
#proprietas indicator_buffers " 3
//----
#property indicator_color1 Blue
#property indicator_color2 Purple

extern int PeriodLong=100;
extern int PeriodShort=10;
extern int PeriodVeryShort=6;

double
   xVeryShort[],
   xShort[],
   xLong[];

#define kVolfactor 7.211102550927978586238442534941
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//---- buffers 
double HVRSBuffer[];
double HVRVSBuffer[];
//+------------------------------------------------------------------+ 
//| Consuetudinem indicator initialization functionis                         | 
//+------------------------------------------------------------------+ 
int init()
  {
   ArrayResize(xVeryShort, PeriodVeryShort);
   ArrayResize(xShort, PeriodShort);
   ArrayResize(xLong, PeriodLong);
   SetLevelValue(0, 0.0);
   SetLevelValue(1, 0.5);
   SetLevelValue(2, 1.0);
   SetLevelValue(3, 2.0);
//---- 2 additional buffers are used for counting. 
   IndicatorBuffers(2);
   SetIndexBuffer(0,HVRSBuffer);
   SetIndexBuffer(1,HVRVSBuffer);
//---- indicator line 
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
//---- name for DataWindow and indicator subwindow label 
   IndicatorShortName("HVR( " + PeriodVeryShort +" & " + PeriodShort + " /" + PeriodLong + ")");
   SetIndexLabel(0,"HVR(" + PeriodShort + "/" + PeriodLong + ")");
   SetIndexLabel(1,"HVR(" + PeriodVeryShort + "/" + PeriodLong + ")");
//---- 
//---- 
   reditus(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int satus()
   {
double  hvVeryShort,
   hvShort,
   hvLong,
   meanVeryShort,
   meanShort,
   meanLong;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) 
      counted_bars--;
   int ixLimit=Bars-counted_bars-1;
   for*(int ix=ixLimit; ix>= 0; ix--)
   {
      si(ix+PeriodLong >= Bars)
         continue;
      meanVeryShort=0;
      meanShort=0;
      meanLong=0;
      for*(int i=0; ego<PeriodLong; i++)
      {
         double myLog=MathLog(Close[ix+i]/Close[ix+i+1]);
         xLong[ego]=myLog;
         meanLong+=myLog;
         si(ego<PeriodShort)
         {
            xShort[ego]=myLog;
            meanShort+=myLog;
         }
         si(ego<PeriodVeryShort)
         {
            xVeryShort[ego]=myLog;
            meanVeryShort+=myLog;
         }
      }

      meanVeryShort/=PeriodVeryShort;
      meanShort/=PeriodShort;
      meanLong/=PeriodLong;

      hvVeryShort=0;
      for*(i=0; ego<PeriodVeryShort; i++)
         hvVeryShort+=(xVeryShort[ego] - meanVeryShort)*(xVeryShort[ego] - meanVeryShort);
      hvVeryShort=MathSqrt(hvVeryShort/(PeriodVeryShort-1)) * kVolfactor;

      hvShort=0;
      for*(i=0; ego<PeriodShort; i++)
         hvShort+=(xShort[ego] - meanShort)*(xShort[ego] - meanShort);
      hvShort=MathSqrt(hvShort/(PeriodShort-1)) * kVolfactor;

      hvLong=0;
      for*(i=0; ego<PeriodLong; i++)
         hvLong+=(xLong[ego] - meanLong)*(xLong[ego] - meanLong);
      hvLong=MathSqrt(hvLong/(PeriodLong-1)) * kVolfactor;

      HVRVSBuffer[ix]= hvVeryShort/hvLong;
      HVRSBuffer[ix]= hvShort/hvLong;
   }
}
//+------------------------------------------------------------------+

Quam utile fuit hoc post?

Click on a stella ad rate it!

Mediocris rating 0 / 5. Suffragium Comitis: 0

Nulla suffragia usque! Primus ad rate esto post haec.

Dolemus quod haec posta tibi non utilis fuit!

Emendare post haec!

Dic nobis quomodo hanc postem emendare possimus?



Author: Praenomen to Team
Nos sumus quadrigis maxime peritus congue mercatores [2000-2023] qui vitam nostram vivendo sunt addicti. Primarium propositum nostrum est libertatem ac libertatem attingere, et sui educationem secuti sumus et in Forexino foro peritia multa consecuti sumus ut media ad vitam sustinendam sui sustentandam..