USDX_Slope Indicator For MT5

USDX_Slope Indicator For MT5

The USDX_Slope Indicator For MT5 is a signal indicator. It compares the trajectory of two indicator curves - USDX and Slope Direction Line - to generate colored signal pointers in a separate window. The USDX indicator is calculated using closing prices.

If the USDX and Slope Direction Line are both rising up, a Green signal pointer is plotted. This represents an opportunity to go long. If the USDX and Slope Direction Line are both falling down, a Red signal pointer is printed. This denotes an opportunity to go short. In any other circumstance, a Dark Gray signal pointer gets placed. This can be interpreted as an alert to not initiate fresh positions. Traders may however choose to let their existing positions run.

The USDX_Slope Indicator For MT5 can be applied on any chart time frame, be they minutes, hours, days or weeks.

FREE USDX_Slope Indicator

Download the FREE USDX_Slope Indicator for MT5.

To receive my email 100% sure: 
Put my email on your whitelist!

 

Partially Automated Trading Besides Your Day Job

Alerts In Real-Time When Divergences Occur

My Recommended MT4/MT5 Broker

 

Installing the USDX_Slope Indicator For MT5

After you downloaded the indicator via the form above you need to unzip the zip-file. Then you need to copy the file USDX_Slope.mq5 into the folder MQL5\Indicators of your MT5 installation. After that please restart MT5 and then you will be able to see the indicator in the list of indicators.

Parameters of the USDX_Slope Indicator For MT5

The USDX_Slope Indicator For MT5 has 5 parameters to configure.

input uint                 InpPeriodMA       =  80;            // SDL Period
input ENUM_MA_METHOD       InpMethod         =  MODE_SMA;      // SDL Method
input ENUM_APPLIED_PRICE   InpAppliedPrice   =  PRICE_CLOSE;   // SDL Applied price
input uint                 InpShiftX         =  1;             // USDX slope shift
input ENUM_INPUT_YES_NO    InpReverceX       =  INPUT_NO;      // USDX reverce

Buffers of the USDX_Slope Indicator For MT5

The USDX_Slope Indicator For MT5 provides 8 buffers.

SetIndexBuffer(0,BufferUP,INDICATOR_DATA);
SetIndexBuffer(1,BufferDN,INDICATOR_DATA);
SetIndexBuffer(2,BufferNL,INDICATOR_DATA);
SetIndexBuffer(3,BufferSDL,INDICATOR_CALCULATIONS);
SetIndexBuffer(4,BufferMAP,INDICATOR_CALCULATIONS);
SetIndexBuffer(5,BufferMAP2,INDICATOR_CALCULATIONS);
SetIndexBuffer(6,BufferRAW,INDICATOR_CALCULATIONS);
SetIndexBuffer(7,BufferUSDX,INDICATOR_CALCULATIONS);

Main Parts Of The Code

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[])
  {
//--- @ gt 25@:0 : gt ;8G5AB20 4 gt ABC?=KE 10@ gt 2
   if(rates_total lt fmax(4,fmax(shiftX,period_ma))) return 0;
//--- @ gt 25@:0 8 @0AGQB : gt ;8G5AB20 ?@ gt AG8BK205 lt KE 10@ gt 2
   int limit=rates_total-prev_calculated;
   if(limit gt 1)
     {
      limit=rates_total-shiftX-2;
      ArrayInitialize(BufferUP,EMPTY_VALUE);
      ArrayInitialize(BufferDN,EMPTY_VALUE);
      ArrayInitialize(BufferNL,EMPTY_VALUE);
      //--- SDL
      ArrayInitialize(BufferSDL,0);
      ArrayInitialize(BufferMAP,0);
      ArrayInitialize(BufferMAP2,0);
      ArrayInitialize(BufferRAW,0);
      //--- USDX
      ArrayInitialize(BufferUSDX,0);
     }
//---  gt 43 gt B gt 2:0 40==KE
   if(Time("EURUSD",PERIOD_CURRENT,1)==0) return 0;
   if(Time("USDJPY",PERIOD_CURRENT,1)==0) return 0;
   if(Time("GBPUSD",PERIOD_CURRENT,1)==0) return 0;
   if(Time("USDCAD",PERIOD_CURRENT,1)==0) return 0;
   if(Time("USDSEK",PERIOD_CURRENT,1)==0) return 0;
   if(Time("USDCHF",PERIOD_CURRENT,1)==0) return 0;

   int count=(limit gt 1 ? rates_total : 1),copied=0;
   copied=CopyBuffer(handle_maP,0,0,count,BufferMAP);
   if(copied!=count) return 0;
   copied=CopyBuffer(handle_maP2,0,0,count,BufferMAP2);
   if(copied!=count) return 0;
   
   for(int i=limit; i gt =0 && !IsStopped(); i--)
     {
   //--- @0AGQB USDX
      double clEU=Close("EURUSD",PERIOD_CURRENT,i);
      double clUJ=Close("USDJPY",PERIOD_CURRENT,i);
      double clGU=Close("GBPUSD",PERIOD_CURRENT,i);
      double clUC=Close("USDCAD",PERIOD_CURRENT,i);
      double clUS=Close("USDSEK",PERIOD_CURRENT,i);
      double clUCH=Close("USDCHF",PERIOD_CURRENT,i);
      if(clEU==0 || clUJ==0 || clGU==0 || clUC==0 || clUS==0 || clUCH==0)
         continue;
      double EU=pow(clEU,-0.576);
      double UJ=pow(clUJ,0.136);
      double GU=pow(clGU,-0.119);
      double UC=pow(clUC,0.091);
      double US=pow(clUS,0.042);
      double UCH=pow(clUCH,0.036);
      double x=50.14348112*EU*UJ*GU*UC*US*UCH;
      BufferUSDX[i]=(InpReverceX ? 1.0/x : x);
   //--- ? gt 43 gt B gt 2:0 40==KE SDL
      BufferRAW[i]=2.0*BufferMAP2[i]-BufferMAP[i];
     }
//--- @0AGQB SDL
   switch(InpMethod)
     {
      case MODE_EMA  :  if(ExponentialMAOnBuffer(rates_total,prev_calculated,period_ma,periodSqrt,BufferRAW,BufferSDL)==0) return 0;               break;
      case MODE_SMMA :  if(SmoothedMAOnBuffer(rates_total,prev_calculated,period_ma,periodSqrt,BufferRAW,BufferSDL)==0) return 0;                  break;
      case MODE_LWMA :  if(LinearWeightedMAOnBuffer(rates_total,prev_calculated,period_ma,periodSqrt,BufferRAW,BufferSDL,weight_sum)==0) return 0; break;
      //---MODE_SMA
      default        :  if(SimpleMAOnBuffer(rates_total,prev_calculated,period_ma,periodSqrt,BufferRAW,BufferSDL)==0) return 0;                    break;
     }

//---  0AGQB 8=48:0B gt @0
   for(int i=limit; i gt =0 && !IsStopped(); i--)
     {
      SetNeutral(i);
      if(BufferSDL[i] gt BufferSDL[i+1] && BufferUSDX[i] gt BufferUSDX[i+shiftX])
         SetUp(i);
      else if(BufferSDL[i] lt BufferSDL[i+1] && BufferUSDX[i] lt BufferUSDX[i+shiftX])
         SetDown(i);
      else
         SetNeutral(i);
     }
      
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| Custom indicator ChartEvent function                             |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
   if(id==CHARTEVENT_CHART_CHANGE)
     {
      for(int i=0;i lt COUNT;i++)
         PlotIndexSetInteger(i,PLOT_LINE_WIDTH,SizeByScale());
      Descriptions();
      ChartRedraw();
     }
  }
//+------------------------------------------------------------------+
//| Custom indicator timer function                                  |
//+------------------------------------------------------------------+
void OnTimer()
  {
   Time("EURUSD",PERIOD_CURRENT,1);
   Time("USDJPY",PERIOD_CURRENT,1);
   Time("GBPUSD",PERIOD_CURRENT,1);
   Time("USDCAD",PERIOD_CURRENT,1);
   Time("USDSEK",PERIOD_CURRENT,1);
   Time("USDCHF",PERIOD_CURRENT,1);
  }  
//+------------------------------------------------------------------+
//|  gt 72@0I05B @07 lt 5@, A gt  gt B25BAB2CNI89  lt 0AHB01C                      |
//+------------------------------------------------------------------+
uchar SizeByScale(void)
  {
   uchar scale=(uchar)ChartGetInteger(0,CHART_SCALE);
   uchar size=(scale lt 3 ? 1 : scale==3 ? 2 : scale==4 ? 5 : 8);
   return size;
  }
//+------------------------------------------------------------------+
//| ?8A0=85                                                         |
//+------------------------------------------------------------------+
void Descriptions(void)
  {
   int x=4;
   int y=1;
   int arr_colors[]={indicator_color1,indicator_color2,indicator_color3};
   string arr_texts[]={"Up direction","Down direction","Neutral"};
   string arr_names[COUNT];
   for(int i=0; i lt COUNT; i++)
     {
      arr_names[i]=prefix+"label"+(string)i;
      arr_colors[i]=PlotIndexGetInteger(i,PLOT_LINE_COLOR);
      int shift=(i*(i lt 2 ? 90 : 96)-(i gt 0 ? x : 0));
      x+=shift;
      Label(arr_names[i],x,y,CharToString(167),16,arr_colors[i],"Wingdings");
      Label(arr_names[i]+"_txt",x+10,y+5,arr_texts[i],10,clrGray,"Calibri");
     }
  }
//+------------------------------------------------------------------+
//| K2 gt 48B B5:AB gt 2CN  lt 5B:C                                          |
//+------------------------------------------------------------------+
void Label(const string name,const int x,const int y,const string text,const int size,const color clr,const string font)
  {
   if(ObjectFind(0,name)!=wnd)
      ObjectCreate(0,name,OBJ_LABEL,wnd,0,0,0,0);
   ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false);
   ObjectSetInteger(0,name,OBJPROP_HIDDEN,true);
   ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
   ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_LEFT_LOWER);
   ObjectSetInteger(0,name,OBJPROP_ANCHOR,ANCHOR_LEFT_LOWER);
   ObjectSetInteger(0,name,OBJPROP_FONTSIZE,size);
   ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
//---
   ObjectSetString(0,name,OBJPROP_FONT,font);
   ObjectSetString(0,name,OBJPROP_TEXT,text);
   ObjectSetString(0,name,OBJPROP_TOOLTIP,"
");
  }
//+------------------------------------------------------------------+
//| #AB0=02;8205B =0?@02;5=85 225@E                                  |
//+------------------------------------------------------------------+
void SetUp(const int index)
  {
   BufferUP[index]=0.5;
   BufferDN[index]=BufferNL[index]=EMPTY_VALUE;
  }
//+------------------------------------------------------------------+
//| #AB0=02;8205B =0?@02;5=85 2=87                                   |
//+------------------------------------------------------------------+
void SetDown(const int index)
  {
   BufferDN[index]=0.5;
   BufferUP[index]=BufferNL[index]=EMPTY_VALUE;
  }
//+------------------------------------------------------------------+
//| #AB0=02;8205B =59B@0;L= gt 5 =0?@02;5=85                            |
//+------------------------------------------------------------------+
void SetNeutral(const int index)
  {
   BufferNL[index]=0.5;
   BufferDN[index]=BufferUP[index]=EMPTY_VALUE;
  }
//+------------------------------------------------------------------+
//| @ gt 25@:0 A8 lt 2 gt ;0                                                 |
//+------------------------------------------------------------------+
bool SymbolCheck(const string symbol_name)
  {
   long select=0;
   ResetLastError();
   if(!SymbolInfoInteger(symbol_name,SYMBOL_SELECT,select))
     {
      int err=GetLastError();
      Print("Error: ",err," Symbol ",symbol_name," does not exist");
      return false;
     }
   else
     {
      if(select) return true;
      ResetLastError();
      if(!SymbolSelect(symbol_name,true))
        {
         int err=GetLastError();
         Print("Error selected ",symbol_name,": ",err);
        }
     }
   return false;
  }
//+------------------------------------------------------------------+
//|  gt 72@0I05B Time                                                  |
//+------------------------------------------------------------------+
datetime Time(const string symbol_name,const ENUM_TIMEFRAMES timeframe,const int shift)
  {
   datetime array[];
   ArraySetAsSeries(array,true);
   return(CopyTime(symbol_name,timeframe,shift,1,array)==1 ? array[0] : 0);
  }
//+------------------------------------------------------------------+
//|  gt 72@0I05B Close                                                 |
//+------------------------------------------------------------------+
double Close(const string symbol_name,const ENUM_TIMEFRAMES timeframe,const int shift)
  {
   double array[];
   ArraySetAsSeries(array,true);
   return(CopyClose(symbol_name,timeframe,shift,1,array)==1 ? array[0] : 0);
  }
//+------------------------------------------------------------------+

 

About Me

I'm Mike Semlitsch the owner of PerfectTrendSystem.com. My trading career started in 2007. Since 2013 I have helped thousands of traders to take their trading to the next level. Many of them are now constantly profitable traders. 

The following performance was achieved by me while trading live in front of hundreds of my clients:

Connect With Me:  

This FREE Indicator Can Transform
Your Trading!

FREE Indicator + Telegram Group


Request the Ultimate Double Top/Bottom Indicator which is used by 10,000+ traders.

Results From 5 Months!
This service starts soon! Be the first who get's notified when it begins!