#property copyright "Copyright © FiatFap (http://www.forexfactory.com/fiatfap)"
#property link      "http://fxnewsalert.com"
#property indicator_chart_window
             
string objSymbol = "n";
int boxSize = 8;
int yDist = 1;      
int xDist = 1;
int TFarray[] = {1,5,15,30,60,240,1440,10080,43200};
//===================================================================================================
//===================================================================================================

int init()
{         
   ObjectCreate("rsi_"+1, OBJ_LABEL, 0, 0, 0);
   ObjectSetText("rsi_"+1, objSymbol, boxSize, "Wingdings", Silver);
   ObjectSet("rsi_"+1, OBJPROP_CORNER, 1);
   ObjectSet("rsi_"+1, OBJPROP_BACK, true);
   ObjectSet("rsi_"+1, OBJPROP_XDISTANCE, xDist);
   ObjectSet("rsi_"+1, OBJPROP_YDISTANCE, yDist);

   ObjectCreate("rsi_"+5, OBJ_LABEL, 0, 0, 0);
   ObjectSetText("rsi_"+5, objSymbol, boxSize, "Wingdings", Silver);
   ObjectSet("rsi_"+5, OBJPROP_CORNER, 1);
   ObjectSet("rsi_"+5, OBJPROP_BACK, true);
   ObjectSet("rsi_"+5, OBJPROP_XDISTANCE, xDist);
   ObjectSet("rsi_"+5, OBJPROP_YDISTANCE, yDist+8);
   
   ObjectCreate("rsi_"+15, OBJ_LABEL, 0, 0, 0);
   ObjectSetText("rsi_"+15, objSymbol, boxSize, "Wingdings", Silver);
   ObjectSet("rsi_"+15, OBJPROP_CORNER, 1);
   ObjectSet("rsi_"+15, OBJPROP_BACK, true);
   ObjectSet("rsi_"+15, OBJPROP_XDISTANCE, xDist);
   ObjectSet("rsi_"+15, OBJPROP_YDISTANCE, yDist+16);
   
   ObjectCreate("rsi_"+30, OBJ_LABEL, 0, 0, 0);
   ObjectSetText("rsi_"+30, objSymbol, boxSize, "Wingdings", Silver);
   ObjectSet("rsi_"+30, OBJPROP_CORNER, 1);
   ObjectSet("rsi_"+30, OBJPROP_BACK, true);
   ObjectSet("rsi_"+30, OBJPROP_XDISTANCE, xDist);
   ObjectSet("rsi_"+30, OBJPROP_YDISTANCE, yDist+24);
   
   ObjectCreate("rsi_"+60, OBJ_LABEL, 0, 0, 0);
   ObjectSetText("rsi_"+60, objSymbol, boxSize, "Wingdings", Silver);
   ObjectSet("rsi_"+60, OBJPROP_CORNER, 1);
   ObjectSet("rsi_"+60, OBJPROP_BACK, true);
   ObjectSet("rsi_"+60, OBJPROP_XDISTANCE, xDist);
   ObjectSet("rsi_"+60, OBJPROP_YDISTANCE, yDist+32);
   
   ObjectCreate("rsi_"+240, OBJ_LABEL, 0, 0, 0);
   ObjectSetText("rsi_"+240, objSymbol, boxSize, "Wingdings", Silver);
   ObjectSet("rsi_"+240, OBJPROP_CORNER, 1);
   ObjectSet("rsi_"+240, OBJPROP_BACK, true);
   ObjectSet("rsi_"+240, OBJPROP_XDISTANCE, xDist);
   ObjectSet("rsi_"+240, OBJPROP_YDISTANCE, yDist+40);
   
   ObjectCreate("rsi_"+1440, OBJ_LABEL, 0, 0, 0);
   ObjectSetText("rsi_"+1440, objSymbol, boxSize, "Wingdings", Silver);
   ObjectSet("rsi_"+1440, OBJPROP_CORNER, 1);
   ObjectSet("rsi_"+1440, OBJPROP_BACK, true);
   ObjectSet("rsi_"+1440, OBJPROP_XDISTANCE, xDist);
   ObjectSet("rsi_"+1440, OBJPROP_YDISTANCE, yDist+48);  
    
   ObjectCreate("rsi_"+10080, OBJ_LABEL, 0, 0, 0);
   ObjectSetText("rsi_"+10080, objSymbol, boxSize, "Wingdings", Silver);
   ObjectSet("rsi_"+10080, OBJPROP_CORNER, 1);
   ObjectSet("rsi_"+10080, OBJPROP_BACK, true);
   ObjectSet("rsi_"+10080, OBJPROP_XDISTANCE, xDist);
   ObjectSet("rsi_"+10080, OBJPROP_YDISTANCE, yDist+56);
   
   ObjectCreate("rsi_"+43200, OBJ_LABEL, 0, 0, 0);
   ObjectSetText("rsi_"+43200, objSymbol, boxSize, "Wingdings", Silver);
   ObjectSet("rsi_"+43200, OBJPROP_CORNER, 1);
   ObjectSet("rsi_"+43200, OBJPROP_BACK, true);
   ObjectSet("rsi_"+43200, OBJPROP_XDISTANCE, xDist);
   ObjectSet("rsi_"+43200, OBJPROP_YDISTANCE, yDist+64);  
      
   //highlight h4, daily, weekly
   ObjectCreate("rsiHighlight_"+240, OBJ_LABEL, 0, 0, 0);
   ObjectSetText("rsiHighlight_"+240, "4", 6, "Arial", Black);
   ObjectSet("rsiHighlight_"+240, OBJPROP_CORNER, 1);
   ObjectSet("rsiHighlight_"+240, OBJPROP_BACK, true);
   ObjectSet("rsiHighlight_"+240, OBJPROP_XDISTANCE, 10);
   ObjectSet("rsiHighlight_"+240, OBJPROP_YDISTANCE, yDist+41); 
   
   ObjectCreate("rsiHighlight_"+1440, OBJ_LABEL, 0, 0, 0);
   ObjectSetText("rsiHighlight_"+1440, "d", 6, "Arial", Black);
   ObjectSet("rsiHighlight_"+1440, OBJPROP_CORNER, 1);
   ObjectSet("rsiHighlight_"+1440, OBJPROP_BACK, true);
   ObjectSet("rsiHighlight_"+1440, OBJPROP_XDISTANCE, 10);
   ObjectSet("rsiHighlight_"+1440, OBJPROP_YDISTANCE, yDist+49); 
   
   ObjectCreate("rsiHighlight_"+10080, OBJ_LABEL, 0, 0, 0);
   ObjectSetText("rsiHighlight_"+10080, "w", 6, "Arial", Black);
   ObjectSet("rsiHighlight_"+10080, OBJPROP_CORNER, 1);
   ObjectSet("rsiHighlight_"+10080, OBJPROP_BACK, true);
   ObjectSet("rsiHighlight_"+10080, OBJPROP_XDISTANCE, 10);
   ObjectSet("rsiHighlight_"+10080, OBJPROP_YDISTANCE, yDist+57); 
   
   //Sentiment
   ObjectCreate("rsiSentiment", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("rsiSentiment", "l", boxSize, "Wingdings", Silver);
   ObjectSet("rsiSentiment", OBJPROP_CORNER, 1);
   ObjectSet("rsiSentiment", OBJPROP_BACK, true);
   ObjectSet("rsiSentiment", OBJPROP_XDISTANCE, 1);
   ObjectSet("rsiSentiment", OBJPROP_YDISTANCE, 75); 
   
return(0);
}

//===================================================================================================

int deinit() {return(0);}

//===================================================================================================

int start()
{
   /*
   static datetime candle.temp;
      
   if(candle.temp != iTime(NULL,TFarray[0],0))
   {   
      for (int i=0; i<ArraySize(TFarray); i++) RSISignals(TFarray[i]);
      candle.temp = iTime(NULL,TFarray[0],0);
   }
   */
   for (int i=0; i<ArraySize(TFarray); i++) RSISignals(TFarray[i]);
   Sentiment();
   
return(0);
}

//===================================================================================================
void Sentiment()
{
   ObjectSetText("rsiSentiment", "l", 20, "Wingdings", Silver);
   if (ObjectGet("rsi_"+240,OBJPROP_COLOR) == Red && ObjectGet("rsi_"+1440,OBJPROP_COLOR) == Red && ObjectGet("rsi_"+10080,OBJPROP_COLOR) == Red) ObjectSetText("rsiSentiment", "l", 20, "Wingdings", Red);
   if (ObjectGet("rsi_"+240,OBJPROP_COLOR) == Lime && ObjectGet("rsi_"+1440,OBJPROP_COLOR) == Lime && ObjectGet("rsi_"+10080,OBJPROP_COLOR) == Lime) ObjectSetText("rsiSentiment", "l", 20, "Wingdings", Lime);

return(0);
}
//===================================================================================================

void RSISignals(int timeframe)
{   
   ObjectSetText("rsi_"+timeframe, objSymbol, boxSize, "Wingdings", Silver);
   
	double c_val, p_val, delta_val;
	double	ValueChange_1=2.5, ValueChange_2=4.75;

   color	colorCodeSUP=Lime,
		   colorCodeSDN=Red,
		   colorCodeWUP=Green,
		   colorCodeWDN=Orange;
			
			c_val = iRSI(Symbol(), timeframe, 3, PRICE_CLOSE, 0);
			p_val = iRSI(Symbol(), timeframe, 3, PRICE_CLOSE, 1);
			delta_val = MathAbs(c_val - p_val);
			
			if(c_val - p_val > 0)
			{
				if(delta_val > ValueChange_2)
				{

					ObjectSetText("rsi_"+timeframe, objSymbol, boxSize, "Wingdings", colorCodeSUP);					
				} 
				if(delta_val > ValueChange_1 && delta_val < ValueChange_2)
				{

					ObjectSetText("rsi_"+timeframe, objSymbol, boxSize, "Wingdings", colorCodeWUP);
				} 
			}
			if(c_val - p_val < 0)
			{
				if(delta_val > ValueChange_2)
				{

					ObjectSetText("rsi_"+timeframe, objSymbol, boxSize, "Wingdings", colorCodeSDN);
				} 
				if(delta_val > ValueChange_1 && delta_val < ValueChange_2)
				{

					ObjectSetText("rsi_"+timeframe, objSymbol, boxSize, "Wingdings", colorCodeWDN);
				}
			} 
			
return(0);
}


