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

ATR信号 FX Sniper’s Chandelier.mq4

FX Sniper’s Chandelier 指标创建小圆点指示ATR信号。

图表:FX Sniper's Chandelier 指标

源码:

//+------------------------------------------------------------------+
//|                                       FX Sniper's Chandelier.mq4 |
//+------------------------------------------------------------------+
#property copyright ""
#property link      "http://www.125808047.com"

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

double Buffer1[];
double Buffer2[];
extern int ATR_Period = 10;
extern double Chandelier_Factor = 1.25;
extern int Entry_Bar = 1;
bool iSL = true;
extern bool LONG = true;
extern double Initial_SL_Factor = 0.75;
int i;
double lprice[],hprice[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{ 
   IndicatorBuffers(4);
   SetIndexBuffer(0,Buffer1);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,159);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,159);
   SetIndexBuffer(1,Buffer2);
   SetIndexLabel(0,"L Stop");
   SetIndexLabel(1,"S Stop");
   SetIndexBuffer(2,lprice);
   SetIndexBuffer(3,hprice);
   Comment("www.125808047.com");
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
   void OnDeinit(const int reason)
  {
  for (i=Bars;i >=0;i--)
   {
   Buffer1[i] = EMPTY_VALUE;
   Buffer2[i] = EMPTY_VALUE;
   }
  }
//====================================================================
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();
if (LONG==true)
//=================================  LONG =============================
{
   if (iSL == true)
   {
   Buffer1[Entry_Bar]= Open[Entry_Bar] - Initial_SL_Factor * iATR(NULL,0,ATR_Period,Entry_Bar);
   iSL = false;
   }
   else
   {
      for( i=Entry_Bar-1;i>=0;i--)
      {
         if (High[i] <= High[i+1])
         Buffer1[i]= Buffer1[i+1];
         else
         {
         if (Buffer1[i+1] >= High[i] - Chandelier_Factor * iATR(NULL,0,ATR_Period,i+1))
            Buffer1[i] = Buffer1[i+1];
         else    
            Buffer1[i]= High[i] - Chandelier_Factor * iATR(NULL,0,ATR_Period,i+1);
         }
      }   
    }
}   
//=================== SHORT ==========================
else
      {
         if (iSL == true)
         {
            Buffer2[Entry_Bar]= Low[Entry_Bar] + Initial_SL_Factor * iATR(NULL,0,ATR_Period,Entry_Bar);
            iSL = false;
         }
         else
         {
            for( i=Entry_Bar-1;i>=0;i--)
            {
               if (Low[i] >= Low[i+1])
               Buffer2[i]= Buffer2[i+1];
               else
               {
                  if(Buffer2[i+1] <= Low[i] + Chandelier_Factor * iATR(NULL,0,ATR_Period,i+1))
                  Buffer2[i]=Buffer2[i+1];
                  else
                  Buffer2[i]= Low[i] + Chandelier_Factor * iATR(NULL,0,ATR_Period,i+1);
               }
            }
         }

      }       
   return(rates_total);
  }
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » ATR信号 FX Sniper’s Chandelier.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏