TRUE Forex

Просмотр кода форекс индикатора !Retracement Finder.mq4

//+------------------------------------------------------------------+
//|                                          !Retracement Finder.mq4 |
//|                                  Copyright © 2011, John Wustrack |
//|                                        john_wustrack@hotmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, John Wustrack"
#property link      "john_wustrack@hotmail.com"

#property indicator_separate_window

#property indicator_buffers 3
#property indicator_color1 LightGray
#property indicator_color2 Blue
#property indicator_color3 Red
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2

extern int xi_Period = 8;
extern double xd_Level = 50;
extern bool xb_Show_Diff = true;
extern bool xb_Show_CB_Diff = true;
extern double xd_Min_Distance_Pips = 2.4;
extern int xi_MA = 10;
extern string ExInd1 = "0=SMA,1=EMA,2=SMMA,3=LWMA";
extern int xi_MA_Method = 0;
extern string ExInd2 = "0=Close,1=Open,2=High,3=Low";
extern string ExInd3 = "4=Median,5=Typical,6=Weighted";
extern int xi_MA_Price = 4;
extern color xc_Text = LightGray;

double IB_Wait[];
double IB_Bull[];
double IB_Bear[];

int gi_Window;
string gs_Ind_Name;
int gi_PipsDecimal;
double gd_Min_Distance_Pts;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 

   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID);
   SetIndexBuffer(0,IB_Wait);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID);
   SetIndexBuffer(1,IB_Bull);
   SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID);
   SetIndexBuffer(2,IB_Bear);
   IndicatorDigits(Digits-1);
   gs_Ind_Name = "Retracement Finder (" + xi_Period + ")";
   IndicatorShortName(gs_Ind_Name);
   
   gi_PipsDecimal = Get_Pips_Decimal();
   gd_Min_Distance_Pts = Convert_2_Pts(xd_Min_Distance_Pips);
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
   int    counted_bars=IndicatorCounted();
   if (counted_bars < 0) return (-1);
   if (counted_bars > 0) counted_bars--;
   int limit = Bars-counted_bars;
   double ld_CCI;
   double ld_MA;
   double ld_Diff_Pts;
   double ld_Diff_Pips;
   
   for (int i=limit; i>=0; i--)
      {
      IB_Wait[i]=EMPTY_VALUE;
      IB_Bull[i]=EMPTY_VALUE;
      IB_Bear[i]=EMPTY_VALUE;
      
      ld_CCI = iCCI(NULL,0,xi_Period,PRICE_TYPICAL,i);
      ld_MA = iMA(NULL,0,xi_MA,0,xi_MA_Method,xi_MA_Price,i);
      if (ld_CCI>=xd_Level && Close[i]>ld_MA && Close[i]>=Open[i] && Low[i]<=ld_MA + gd_Min_Distance_Pts*Point)
         IB_Bull[i]=ld_CCI;
      else
         if (ld_CCI<=xd_Level*(-1)&& Close[i]<ld_MA && Close[i]<=Open[i] && High[i]>=ld_MA - gd_Min_Distance_Pts*Point)
            IB_Bear[i]=ld_CCI;
         else
            IB_Wait[i]=ld_CCI;
      }
      
   // If we are to show differences - do it
   if (xb_Show_Diff)
      {
      ld_MA = iMA(NULL,0,xi_MA,0,xi_MA_Method,xi_MA_Price,1);
      ld_CCI = iCCI(NULL,0,xi_Period,PRICE_TYPICAL,1);
      if (ld_CCI>0)
         ld_Diff_Pts=Low[1]-ld_MA;
      else
         ld_Diff_Pts=ld_MA-High[1];
      if (ld_Diff_Pts<0) ld_Diff_Pts=0;
      ld_Diff_Pips = Convert_2_Pips(ld_Diff_Pts);
      Object_Create("!Retrace.Diff",10,5,DoubleToStr(ld_Diff_Pips,gi_PipsDecimal));
      }

   if (xb_Show_CB_Diff)
      {
      ld_MA = iMA(NULL,0,xi_MA,0,xi_MA_Method,xi_MA_Price,0);
      ld_CCI = iCCI(NULL,0,xi_Period,PRICE_TYPICAL,0);
      if (ld_CCI>0)
         ld_Diff_Pts=Low[0]-ld_MA;
      else
         ld_Diff_Pts=ld_MA-High[0];
      if (ld_Diff_Pts<0) ld_Diff_Pts=0;
      ld_Diff_Pips = Convert_2_Pips(ld_Diff_Pts);
      Object_Create("!Retrace.Diff_CB",10,20,DoubleToStr(ld_Diff_Pips,gi_PipsDecimal));
      }
      
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| create objects                                                   |
//+------------------------------------------------------------------+
void Object_Create(string name,int x,int y,string text=" ",int size=12,
                  string font="Arial",color colour=CLR_NONE)
  {
//----
   
   if (colour==CLR_NONE) colour=xc_Text;
   gi_Window = WindowFind(gs_Ind_Name);
      
   ObjectCreate(name,OBJ_LABEL,gi_Window,0,0,0,0);
   ObjectSet(name,OBJPROP_CORNER,1);
   ObjectSet(name,OBJPROP_COLOR,colour);
   ObjectSet(name,OBJPROP_XDISTANCE,x);
   ObjectSet(name,OBJPROP_YDISTANCE,y);
   
   ObjectSetText(name,text,size,font,colour);

//----
  }
//+------------------------------------------------------------------+
//| convert to points                                                |
//+------------------------------------------------------------------+
double Convert_2_Pts(double pd_Pips)
  {
//----
   double pd_Points=pd_Pips;  // Default - no conversion
   
     if (Digits == 5 || (Digits == 3 && StringFind(Symbol(), "JPY") != -1)) 
        pd_Points=pd_Pips*10;
        
     if (Digits == 6 || (Digits == 4 && StringFind(Symbol(), "JPY") != -1)) 
        pd_Points=pd_Pips*100;
//----
   return(pd_Points);
  }
//+------------------------------------------------------------------+
//| convert to pips                                                  |
//+------------------------------------------------------------------+
double Convert_2_Pips(double pd_Points)
  {
//----
   double pd_Pips=pd_Points/Point;  // Default - no conversion
   
     if (Digits == 5 || (Digits == 3 && StringFind(Symbol(), "JPY") != -1)) 
        {
        pd_Pips=pd_Points/Point/10;
        }
        
     if (Digits == 6 || (Digits == 4 && StringFind(Symbol(), "JPY") != -1)) 
        {
        pd_Pips=pd_Points/Point/100;
        }
//----
   return(pd_Pips);
  }
//+------------------------------------------------------------------+
//| get the pips decimal places                                      |
//+------------------------------------------------------------------+
int Get_Pips_Decimal()
  {
//----
   int pi_PipsDecimal = 0;  // Default - no decimals
   
     if (Digits == 5 || (Digits == 3 && StringFind(Symbol(), "JPY") != -1)) 
        {
        pi_PipsDecimal = 1;
        }
        
     if (Digits == 6 || (Digits == 4 && StringFind(Symbol(), "JPY") != -1)) 
        {
        pi_PipsDecimal = 2;
        }
//----
   return(pi_PipsDecimal);
  }
//+------------------------------------------------------------------+

Комментарии к исходному коду форекс индикатора !Retracement Finder.mq4
В целях безопасности и борьбы со спамом в тексте комментариев запрещено размещать html-теги и ссылки. Благодарим за понимание.

  • X
  • 0% загружено
« индикатор !Ret Setup.mq4
индикатор !SuperADX.mq4 »