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

ATR买卖信号指标 buy_sell.mq4

buy_sell指标是ATR的一种优化。

图表:buy_sell指标

源码:

//+------------------------------------------------------------------+
//|                                                     buy_sell.mq4 |
//|                                                           "pip"  |
//+------------------------------------------------------------------+
#property copyright "pupok"
#property link      "http://www.125808047.com/"

#property indicator_chart_window
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_buffers 2

int Range=14;
int ATR=60;
double ExtHistoBuffer[];
double ExtHistoBuffer2[];

void OnInit(void)
{
   SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID);
   SetIndexBuffer(0, ExtHistoBuffer);
   SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID);
   SetIndexBuffer(1, ExtHistoBuffer2);
   SetIndexArrow(1,159);
   SetIndexArrow(0,159);
  Comment("www.125808047.com"); 
}

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[])
  {
  ExtHistoBuffer[0] = EMPTY_VALUE;
  ExtHistoBuffer2[0] = EMPTY_VALUE;

  int counted = IndicatorCounted();
  if (counted < 0) return (-1);
  
  if (counted > 0) counted--;
  int limit = Bars-counted;
  
  for (int i=limit; i >= 0; i--)
  {
double ma=iMA(NULL,0,Range,0,0,4,i);
double ma1=iMA(NULL,0,Range,0,0,4,i+1);

double dma;
     dma=iATR(NULL, 0, ATR, i);
    if (ma>ma1) 
      ExtHistoBuffer[i] =ma-dma;

    if (ma<ma1)
      ExtHistoBuffer2[i] =ma+dma ;
  }
return(rates_total);
}
打赏
版权所有转载请注明标题及链接:峰汇在线 » ATR买卖信号指标 buy_sell.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏