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

Synergy_APB2.mq4

Synergy_APB2 指标可以代替蜡烛图。是传统Heiken Ashi指标的一种优化。

图表:Synergy_APB2 指标

源码:

//+------------------------------------------------------------------+
//|                                                 Synergy_APB2.mq4 |
//|                                        Copyright @2009, CompassFX|
//+------------------------------------------------------------------+
#property copyright "Copyright @2009, CompassFX"
#property link      "http://www.125808047.com"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 DodgerBlue
#property indicator_color3 Red
#property indicator_color4 DodgerBlue
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 3
#property indicator_width4 3

double g_ibuf_100[];
double g_ibuf_104[];
double g_ibuf_108[];
double g_ibuf_112[];
int gi_116 = 0;

int OnInit(void)
{
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID);
   SetIndexBuffer(0, g_ibuf_100);
   SetIndexLabel(0, "HA_0");
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID);
   SetIndexBuffer(1, g_ibuf_104);
   SetIndexLabel(1, "HA_1");
   SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID);
   SetIndexBuffer(2, g_ibuf_108);
   SetIndexLabel(2, "HA_Open");
   SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_SOLID);
   SetIndexBuffer(3, g_ibuf_112);
   SetIndexLabel(3, "HA_Close");
   SetIndexDrawBegin(0, 10);
   SetIndexDrawBegin(1, 10);
   SetIndexDrawBegin(2, 10);
   SetIndexDrawBegin(3, 10);
   SetIndexBuffer(0, g_ibuf_100);
   SetIndexBuffer(1, g_ibuf_104);
   SetIndexBuffer(2, g_ibuf_108);
   SetIndexBuffer(3, g_ibuf_112);
   Comment("www.125808047.com");
   return(INIT_SUCCEEDED);
}

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[])
  {
   double ld_0;
   double ld_8;
   double ld_16;
   double ld_24;
   if (Bars <= 10) return (0);
   gi_116 = IndicatorCounted();
   if (gi_116 < 0) return (-1);
   if (gi_116 > 0) gi_116--;
   for (int li_32 = Bars - gi_116 - 1; li_32 >= 0; li_32--) {
      ld_24 = NormalizeDouble((Open[li_32] + High[li_32] + Low[li_32] + Close[li_32]) / 4.0, Digits);
      ld_24 = (ld_24 + Close[li_32]) / 2.0;
      ld_0 = (g_ibuf_108[li_32 + 1] + (g_ibuf_112[li_32 + 1])) / 2.0;
      ld_8 = MathMax(High[li_32], MathMax(ld_0, ld_24));
      ld_16 = MathMin(Low[li_32], MathMin(ld_0, ld_24));
      if (ld_0 < ld_24) {
         g_ibuf_100[li_32] = ld_16;
         g_ibuf_104[li_32] = ld_8;
      } else {
         g_ibuf_100[li_32] = ld_8;
         g_ibuf_104[li_32] = ld_16;
      }
      g_ibuf_108[li_32] = ld_0;
      g_ibuf_112[li_32] = ld_24;
   }
   return (rates_total);
}
打赏
版权所有转载请注明标题及链接:峰汇在线 » Synergy_APB2.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏