0
(0)
Tên:
HVR [ ru | cn ]
Tác giả: Người viết (2008.02.11 10:02)
Đã tải xuống: 1206
Tải xuống:
HVR 1
HVR.mq4 (2.9 Kb) Xem
Tác giả: Albert, (idea and code into MQL2 - podval)

HVR indicator.

HVR 2
1 bình luận Để gửi bình luận mới, Xin vui lòng đăng nhập hoặc đăng ký

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

//+------------------------------------------------------------------+ 
//|                                                          HVR.mq4 | 
//|      Bản quyền © 2005, Albert,(idea and code into MQL2 - podval) | 
//|      Refactored © 2010, Brewmanz (thêm vào 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 + ")");
//---- 
//---- 
   trở lại(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;
   vì(int ix=ixLimit; ix>=0; ix--)
   {
      nếu như(ix+PeriodLong >= Bars)
         continue;
      meanVeryShort=0;
      meanShort=0;
      meanLong=0;
      vì(int i=0; Tôi<PeriodLong; i++)
      {
         double myLog=MathLog(Đóng[ix+i]/Đóng[ix+i+1]);
         xLong[Tôi]=myLog;
         meanLong+=myLog;
         nếu như(Tôi<PeriodShort)
         {
            xShort[Tôi]=myLog;
            meanShort+=myLog;
         }
         nếu như(Tôi<PeriodVeryShort)
         {
            xVeryShort[Tôi]=myLog;
            meanVeryShort+=myLog;
         }
      }

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

      hvVeryShort=0;
      vì(i=0; Tôi<PeriodVeryShort; i++)
         hvVeryShort+=(xVeryShort[Tôi] - meanVeryShort)*(xVeryShort[Tôi] - meanVeryShort);
      hvVeryShort=MathSqrt(hvVeryShort/(PeriodVeryShort-1)) * kVolfactor;

      hvShort=0;
      vì(i=0; Tôi<PeriodShort; i++)
         hvShort+=(xShort[Tôi] - meanShort)*(xShort[Tôi] - meanShort);
      hvShort=MathSqrt(hvShort/(PeriodShort-1)) * kVolfactor;

      hvLong=0;
      vì(i=0; Tôi<PeriodLong; i++)
         hvLong+=(xLong[Tôi] - meanLong)*(xLong[Tôi] - meanLong);
      hvLong=MathSqrt(hvLong/(PeriodLong-1)) * kVolfactor;

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

Bài đăng này hữu ích như thế nào?

Bấm vào một ngôi sao để đánh giá nó!

Đánh giá trung bình 0 / 5. Số phiếu bầu: 0

Không có phiếu bầu cho đến nay! Hãy là người đầu tiên đánh giá bài viết này.

Chúng tôi xin lỗi vì bài đăng này không hữu ích cho bạn!

Hãy để chúng tôi cải thiện bài đăng này!

Hãy cho chúng tôi biết cách chúng tôi có thể cải thiện bài đăng này?



Tác giả: Nhóm ngoại hối Wiki
Chúng tôi là một nhóm gồm các Nhà giao dịch ngoại hối giàu kinh nghiệm [2000-2023] những người cống hiến để sống cuộc sống theo cách riêng của chúng ta. Mục tiêu chính của chúng tôi là đạt được sự độc lập và tự do về tài chính, và chúng tôi đã theo đuổi việc tự học và có được nhiều kinh nghiệm trong thị trường ngoại hối như là phương tiện của chúng tôi để đạt được lối sống bền vững.