0
(0)
Naam:
HVR [ ru | cn ]
Skrywer: Die skrywer (2008.02.11 10:02)
Afgelaai: 1206
Aflaai:
HVR 1
HVR.mq4 (2.9 Kb) Beskou
Skrywer: Albert, (idea and code into MQL2 - podval)

HVR indicator.

HVR 2
1 kommentaar lewer Om 'n nuwe opmerking te plaas, asseblief teken aan of registreer

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

//+------------------------------------------------------------------+ 
//|                                                          HVR.mq4 | 
//|      Kopiereg © 2005, Albert,(idea and code into MQL2 - podval) | 
//|      Refactored © 2010, Brewmanz (byvoeg 2 HVR lines)               | 
//|                                                                  | 
//+------------------------------------------------------------------+ 
#property indicator_separate_window
//----
//#property indicator_minimum 0
//#property indicator_maximum 3
#property 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[];
//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
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 + ")");
//---- 
//---- 
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
   {
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;
   vir(int ix=ixLimit; ix>=0; ix--)
   {
      as(ix+PeriodLong >= Bars)
         aanhou;
      meanVeryShort=0;
      meanShort=0;
      meanLong=0;
      vir(int i=0; i<PeriodLong; ek++)
      {
         double myLog=MathLog(Naby[ix+i]/Naby[ix+i+1]);
         xLong[i]=myLog;
         meanLong+=myLog;
         as(i<PeriodShort)
         {
            xShort[i]=myLog;
            meanShort+=myLog;
         }
         as(i<PeriodVeryShort)
         {
            xVeryShort[i]=myLog;
            meanVeryShort+=myLog;
         }
      }

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

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

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

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

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

Hoe nuttig was hierdie pos nie?

Klik op 'n ster om dit te gradeer!

Gemiddelde gradering 0 / 5. Stemmetelling: 0

Geen stemme tot dusver nie! Wees die eerste om hierdie plasing te beoordeel.

Ons is jammer dat hierdie plasing nie vir jou nuttig was nie!

Kom ons verbeter hierdie pos!

Vertel ons hoe ons hierdie pos kan verbeter?



Skrywer: Forex Wiki-span
Ons is 'n span hoogs ervare Forex Handelaars [2000-2023] wat daaraan toegewy is om die lewe op ons eie terme te leef. Ons primêre doelwit is om finansiële onafhanklikheid en vryheid te verkry, en ons het selfonderrig nagestreef en uitgebreide ondervinding in die Forex-mark opgedoen as ons manier om 'n selfvolhoubare leefstyl te bereik.