诚信为本
量力而为
当前位置:峰汇在线 > MetaTrader 4 > MT4指标 > 正文

牛市力量指标 Bulls.mq4

Bulls指标是MT4自带的牛市力量指标。

图表:Bulls指标

源码:

//+------------------------------------------------------------------+
//|                                                        Bulls.mq4 |
//|                       Copyright @2005, MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
#property copyright "Copyright @2005, MetaQuotes Software Corp."
#property link      "http://www.125808047.com/"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Silver

extern int BullsPeriod=13;

double BullsBuffer[];
double TempBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit(void)
  {
   string short_name;

   IndicatorBuffers(2);
   IndicatorDigits(Digits);

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

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

  Comment("www.125808047.com");
  }
//+------------------------------------------------------------------+
//| Bulls Power                                                      |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   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]=iMA(NULL,0,BullsPeriod,0,MODE_EMA,PRICE_CLOSE,i);

   i=Bars-counted_bars-1;
   while(i>=0)
     {
      BullsBuffer[i]=High[i]-TempBuffer[i];
      i--;
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » 牛市力量指标 Bulls.mq4
上一篇:
下一篇:
分享到: 更多 (0)

如您觉得此文不错请扫码打赏!

支付宝扫一扫打赏

微信扫一扫打赏