2010年9月9日 星期四

自製指標 : Days Interval


自製指標 : Days Interval

就是類似多少天突破就買賣的指標

這裡是設定 20 天

計算的方法是用當天的 Close 減去 20 天之前的 Close

所以你說看到的數字如果是 正數 就表示當天比 20 天前 上升 了多少點

所以你說看到的數字如果是 負數 就表示當天比 20 天前 下降 了多少點

喜歡玩 突破 的人可以在看到數字由 負數區間 突破到 正數區間 的時候就 買入

就是這麼簡單咯

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//+------------------------------------------------------------------+
//|                                                        Bulls.mq4 |
//|                      Copyright ?2005, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+

#property copyright "Copyright ?2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Silver

//---- input parameters

extern int BullsPeriod=20;

//---- buffers

double BullsBuffer[];
double TempBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int init()
{
   string short_name;

   //---- 1 additional buffer used for counting.

   IndicatorBuffers(2);
   IndicatorDigits(Digits);

   //---- indicator line

   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,BullsBuffer);
   SetIndexBuffer(1,TempBuffer);

   //---- name for DataWindow and indicator subwindow label

   short_name="Days_Interval("+BullsPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);

   return(0);
}

//+------------------------------------------------------------------+
//| Bulls Power                                                      |
//+------------------------------------------------------------------+

int start()
{
   int i,counted_bars=IndicatorCounted();

   if(Bars<=BullsPeriod) return(0);
  
   int limit=Bars-counted_bars;
  
   if(counted_bars>0) limit++;
  
   for(i=0; i<limit; i++)
      TempBuffer[i]=Close[i+BullsPeriod];
      i=Bars-counted_bars-1;
      while(i>=0)
     {
         BullsBuffer[i]=Close[i]-TempBuffer[i];
         i--;
   }
   return(0);
}

沒有留言:

張貼留言