期货无息配资 Heikiun Ashi指标解析:文华版与MT4版源码对比

发布日期:2024-12-09 22:43    点击次数:83

期货无息配资 Heikiun Ashi指标解析:文华版与MT4版源码对比

炒股配资是指投资者通过向配资平台借入资金,放大自己的本金,从而提高投资收益率的一种方式。配资平台提供杠杆,让投资者可以以较小的本金撬动更大的资金,进行股票交易。

图片

周末有位朋友问起Heikiun Ashi指标,当时在外地没怎么回复,今天在这里与大家一起分享文华版与MT4版源码的不同,有兴趣学编写指标的朋友一起来探讨下。

Heikiun Ashi指标Heikiun Ashi指标称平均棒图或平滑蜡烛图,通过计算每个时间周期的开盘价、最高价、最低价和收盘价,生成新的蜡烛图,以更清晰地展现价格趋势。这种指标有助于过滤市场噪音,凸显主要趋势,建议用于大周期看趋势。Heikiun Ashi指标并不建议单独作为期货、外汇或者黄金的交易决策的依据,投资者应当与其他技术分析指标、基本面分析和市场情绪等因素相结合,进行综合判断。MT4版本

图片

文华6版本

图片

源  码  下方分享的Heikiun Ashi指标源码为主图K线形态,是根据常见的方式改写。仅作为策略思路拓展,不建议直接用于期货等投资实盘中(投资有风险,入市须谨慎)。交易员可以根据艾云策略所提供的指标源码,结合平时的交易经验进行改编,形成自己的交易策略。

文华版:适用于文华6、7、8等软件

M:=3;XXOPEN:=(REF(OPEN,M)+REF(CLOSE,M))/2;XXCLOSE:=(HIGH+LOW+CLOSE+OPEN)/4;XXHIGH:=MAX1(XXOPEN,XXCLOSE,HHV(HIGH,M));XXLOW:=MIN1 (XXOPEN,XXCLOSE,LLV(LOW,M));STICKLINE(XXCLOSE>XXOPEN,XXCLOSE ,XXOPEN ,8,1 ),COLORRED;DRAWLINE(XXCLOSE>XXOPEN,XXHIGH ,XXCLOSE>XXOPEN,XXCLOSE,COLORRED );DRAWLINE(XXCLOSE>XXOPEN,XXOPEN ,XXCLOSE>XXOPEN,XXLOW ,COLORRED);STICKLINE(XXCLOSE<=XXOPEN,XXCLOSE ,XXOPEN ,8,0 ),COLORFFFF66;DRAWLINE(XXCLOSE<=XXOPEN,XXOPEN ,XXCLOSE<=XXOPEN,XXHIGH,COLORFFFF66);DRAWLINE(XXCLOSE<=XXOPEN,XXCLOSE ,XXCLOSE<=XXOPEN,XXLOW,COLORFFFF66);

MT4版:

#property indicator_chart_window

#property indicator_buffers 4

#property indicator_color1 Red

#property indicator_color2 White

#property indicator_color3 Red

#property indicator_color4 White

#property indicator_width1 1

#property indicator_width2 1

#property indicator_width3 3

#property indicator_width4 3

//---

input color ExtColor1 = Red;    // Shadow of bear candlestick

input color ExtColor2 = White;  // Shadow of bull candlestick

input color ExtColor3 = Red;    // Bear candlestick body

input color ExtColor4 = White;  // Bull candlestick body

//--- buffers

double ExtLowHighBuffer[];

double ExtHighLowBuffer[];

double ExtOpenBuffer[];

double ExtCloseBuffer[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//|------------------------------------------------------------------|

void OnInit(void)

  {

   IndicatorShortName("Heiken Ashi");

   IndicatorDigits(Digits);

//--- indicator lines

   SetIndexStyle(0,DRAW_HISTOGRAM,0,1,ExtColor1);

   SetIndexBuffer(0,ExtLowHighBuffer);

   SetIndexStyle(1,DRAW_HISTOGRAM,0,1,ExtColor2);

   SetIndexBuffer(1,ExtHighLowBuffer);

   SetIndexStyle(2,DRAW_HISTOGRAM,0,3,ExtColor3);

   SetIndexBuffer(2,ExtOpenBuffer);

   SetIndexStyle(3,DRAW_HISTOGRAM,0,3,ExtColor4);

   SetIndexBuffer(3,ExtCloseBuffer);

//---

   SetIndexLabel(0,"Low/High");

   SetIndexLabel(1,"High/Low");

   SetIndexLabel(2,"Open");

   SetIndexLabel(3,"Close");

   SetIndexDrawBegin(0,10);

   SetIndexDrawBegin(1,10);

   SetIndexDrawBegin(2,10);

   SetIndexDrawBegin(3,10);

//--- indicator buffers mapping

   SetIndexBuffer(0,ExtLowHighBuffer);

   SetIndexBuffer(1,ExtHighLowBuffer);

   SetIndexBuffer(2,ExtOpenBuffer);

   SetIndexBuffer(3,ExtCloseBuffer);

//--- initialization done

  }

//+------------------------------------------------------------------+

//| Heiken Ashi                                                      |

//+------------------------------------------------------------------+

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,pos;

   double haOpen,haHigh,haLow,haClose;

//---

   if(rates_total<=10)

      return(0);

//--- counting from 0 to rates_total

   ArraySetAsSeries(ExtLowHighBuffer,false);

   ArraySetAsSeries(ExtHighLowBuffer,false);

   ArraySetAsSeries(ExtOpenBuffer,false);

   ArraySetAsSeries(ExtCloseBuffer,false);

   ArraySetAsSeries(open,false);

   ArraySetAsSeries(high,false);

   ArraySetAsSeries(low,false);

   ArraySetAsSeries(close,false);

//--- preliminary calculation

   if(prev_calculated>1)

      pos=prev_calculated-1;

   else

     {

      //--- set first candle

      if(open[0]<close[0])

        {

         ExtLowHighBuffer[0]=low[0];

         ExtHighLowBuffer[0]=high[0];

        }

      else

        {

         ExtLowHighBuffer[0]=high[0];

         ExtHighLowBuffer[0]=low[0];

        }

      ExtOpenBuffer[0]=open[0];

      ExtCloseBuffer[0]=close[0];

      //---

      pos=1;

     }

//--- main loop of calculations

   for(i=pos; i<rates_total; i++)

     {

      haOpen=(ExtOpenBuffer[i-1]+ExtCloseBuffer[i-1])/2;

      haClose=(open[i]+high[i]+low[i]+close[i])/4;

      haHigh=MathMax(high[i],MathMax(haOpen,haClose));

      haLow=MathMin(low[i],MathMin(haOpen,haClose));

      if(haOpen<haClose)

        {

         ExtLowHighBuffer[i]=haLow;

         ExtHighLowBuffer[i]=haHigh;

        }

      else

        {

         ExtLowHighBuffer[i]=haHigh;

         ExtHighLowBuffer[i]=haLow;

        }

      ExtOpenBuffer[i]=haOpen;

      ExtCloseBuffer[i]=haClose;

     }

//--- done

   return(rates_total);

  }

//+------------------------------------------------------------------+

艾云策略网站期货无息配资

 https://www.aiycl.cn温馨提示:投资有风险,入场需谨慎! 本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报。