//+------------------------------------------------------------------+
//|                                                     TDIAngle.mq4 |
//|                                  Copyright © 2011, Stason      S |
//+------------------------------------------------------------------+
#property copyright "Copyright © 20011, StasonS"


#property indicator_chart_window

extern color font_color = Red;
extern int font_size = 14;
extern string font_face = "Arial";
extern int corner = 0; //0 - for top-left corner, 1 - top-right, 2 - bottom-left, 3 - bottom-right
extern int spread_distance_x = 700;
extern int spread_distance_y = 10;
extern bool normalize = false; //If true then the spread is normalized to traditional pips

double TdiGreen, PrevTdiGreen, TdiDegrees;
int n_digits = 2;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   //Checking for unconvetional Point digits number
 
   
   ObjectCreate("TDIAngle", OBJ_LABEL, 0, 0, 0);
   ObjectSet("TDIAngle", OBJPROP_CORNER, corner);
   ObjectSet("TDIAngle", OBJPROP_XDISTANCE, spread_distance_x);
   ObjectSet("TDIAngle", OBJPROP_YDISTANCE, spread_distance_y);
   
   
   
   
   ObjectSetText("TDIAngle", "TDI<: " + DoubleToStr(NormalizeDouble(GetTdiDegrees(), 2), n_digits) + " Deg.", font_size, font_face, font_color);
   GetTdi();
   return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
   ObjectDelete("TDIAngle");
   return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   RefreshRates();
   GetTdi();
   
   ObjectSetText("TdiAngle", "TDI<: " + DoubleToStr(NormalizeDouble(GetTdiDegrees(), 2), n_digits) + " Deg.", font_size, font_face, font_color);
return(0);
}

void GetTdi()
{
   
/*
extern int RSI_Period = 13;         //8-25
extern int RSI_Price = 0;           //0-6
extern int Volatility_Band = 34;    //20-40
extern int RSI_Price_Line = 2;      
extern int RSI_Price_Type = 0;      //0-3
extern int Trade_Signal_Line = 7;   
extern int Trade_Signal_Type = 0;   //0-3
*/   
   
   TdiGreen = iCustom(NULL, 0, "TDI_RT", 13, 0, 34, 2, 0, 7, 0,  4, 0);
   PrevTdiGreen = iCustom(NULL, 0, "TDI_RT", 13, 0, 34, 2, 0, 7, 0,  4, 1);
  

}//Endvoid GetTdi()


double GetTdiDegrees()

{
TdiDegrees = (MathArctan(TdiGreen - PrevTdiGreen)*180)/3.1415;
return(TdiDegrees);

}
//+------------------------------------------------------------------+