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

另类SAR指标 HiLo_Activator.mq4

HiLo_Activator指标根据价格高低点算法创建另类SAR。

图表:HiLo_Activator指标

源码:

//+------------------------------------------------------------------+
//|                                               HiLo_Activator.mq4 |
//|                                Copyright @2004, Poul_Trade_Forum |
//|                                                         Aborigen |
//+------------------------------------------------------------------+
#property copyright "Poul Trade Forum"
#property link      "http://www.125808047.com/"

#property indicator_chart_window
#property indicator_buffers 2

extern int R=3;

double HighBuffer[];
double LowBuffer[];
double VALUE1,VALUE2,VALUE11,VALUE22;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit(void)
  {
   string short_name;
   SetIndexStyle(0,DRAW_ARROW,EMPTY,1,Blue);
   SetIndexStyle(1,DRAW_ARROW,EMPTY,1,Red);
   SetIndexArrow(0, 0x9F);
   SetIndexArrow(1, 0x9F);
   SetIndexBuffer(0,HighBuffer);
   SetIndexBuffer(1,LowBuffer);
   SetIndexEmptyValue(0,0);
   SetIndexEmptyValue(1,0);
   short_name="HiLo";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
   SetIndexDrawBegin(0,10);
   SetIndexDrawBegin(1,10);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
   void OnDeinit(const int reason)
  {
   ObjectsDeleteAll(0);
   Comment("www.125808047.com");
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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    counted_bars=IndicatorCounted(),i,shift,Swing;
   i=(Bars-counted_bars)-1;
   for(shift=i; shift>=0;shift--)
     {
      VALUE1=iMA(NULL,0,R,0,MODE_SMA,PRICE_HIGH,shift+1);
      VALUE2=iMA(NULL,0,R,0,MODE_SMA,PRICE_LOW,shift+1);
      if (Close[shift+1]<VALUE2)Swing=-1;
      if (Close[shift+1]>VALUE1)Swing=1;
      if (Swing==1) { HighBuffer[shift]=VALUE2; LowBuffer[shift]=0;  }
      if (Swing==-1) { LowBuffer[shift]=VALUE1; HighBuffer[shift]=0; }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » 另类SAR指标 HiLo_Activator.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏