Quick question about "StringConcatenate"

To add comments, please log in or register
Black_Jack822
57
Black_Jack822  

Hi All. Quick question about this indicator, it shows RSI value on chart window in 6 digits format, what do I have to change or add to make it show only 2 first digits?

------------------------------------------------

#property indicator_chart_window

extern int Periods=14;
extern int Price=PRICE_CLOSE;
extern int Shift=0;

int init()
  {
      if(ObjectFind("M4X - RSI")!=0)
          {
              ObjectCreate("M4X - RSI",OBJ_LABEL,0,0,0,0,0);
              ObjectSet("M4X - RSI",OBJPROP_XDISTANCE,260);
              ObjectSet("M4X - RSI",OBJPROP_YDISTANCE,1);
          }
      if(ObjectFind("M4X - RSI")==0)
          {
                string sVal=StringConcatenate(dRSI ());
                if(dRSI()>50 && dRSI()<=70)
                    {
                        ObjectSetText("M4X - RSI",sVal,8,"Tahoma",Lime);
                    }
                else if(dRSI()<50 && dRSI()>=30)
                    {
                        ObjectSetText("M4X - RSI",sVal,8,"Tahoma",White);
                    }
              else if(dRSI()>70 || dRSI()<30)
                  {
                      ObjectSetText("M4X - RSI",sVal,8,"Tahoma",Gold);
                  }
              else
                  {
                      ObjectSetText("M4X - RSI",sVal,8,"Tahoma",CLR_NONE);
                  }
          }
  }

int deinit()
  {
      ObjectDelete("M4X - RSI");
  }

int start()
  {
        int iIndicatorCounted=IndicatorCounted();
        if(iIndicatorCounted<0)
            {
                return(-1);
            }
        int iLimit=Bars-iIndicatorCounted;
        for(int i=iLimit;i>=0;i--)
            {
                string sVal=StringConcatenate(dRSI());
                if(dRSI()>50 && dRSI()<=70)
                    {
                        ObjectSetText("M4X - RSI",sVal,8,"Tahoma",Lime);
                    }
                else if(dRSI()<50 && dRSI()>=30)
                    {
                        ObjectSetText("M4X - RSI",sVal,8,"Tahoma",White);
                    }
              else if(dRSI()>70 || dRSI()<30)
                  {
                      ObjectSetText("M4X - RSI",sVal,8,"Tahoma",Gold);
                  }
              else
                  {
                      ObjectSetText("M4X - RSI",sVal,8,"Tahoma",CLR_NONE);
                  }
            }
  }

double dRSI()
    {
        return(iRSI(NULL,0,Periods,Price,Shift));
    }
Alexander Voronkov
27526
Alexander Voronkov  
Blackjack822:

Hi All. Quick question about this indicator, it shows RSI value on chart window in 6 digits format, what do I have to change or add to make it show only 2 first digits?


Hi,

Use this:  NormalizeDouble();

Alain Verleyen
36131
Alain Verleyen  
Blackjack822:

Forum on trading, automated trading systems and testing trading strategies


Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.


Black_Jack822
57
Black_Jack822  
Alain Verleyen:

Thank you and apologize, I'm new in this, still learning ;)
Black_Jack822
57
Black_Jack822  
Alexander Voronkov:

Hi,

Use this:  NormalizeDouble();

Thank you it worked :)
I've got one more question I'm new in this stuff, can you have a look and tell me if I've done it the long way around? or is there an easier way to do it?
#property indicator_chart_window

extern int Periods=14;
extern int Price=PRICE_CLOSE;
extern int Shift=6;

int init()
  {
        if(ObjectFind("M4X - RSI")!=0)
                {
                        ObjectCreate("M4X - RSI",OBJ_LABEL,0,0,0,0,0);
                        ObjectSet("M4X - RSI",OBJPROP_XDISTANCE,260);
                        ObjectSet("M4X - RSI",OBJPROP_YDISTANCE,1);
                
                }
  }

int start()
  {
                int iIndicatorCounted=IndicatorCounted();
                if(iIndicatorCounted<0)
                        {
                                return(-1);
                        }
                int iLimit=Bars-iIndicatorCounted;
                for(int i=iLimit;i>=0;i--)
                        {
                           
                                double sVal=(dRSI());
                                
                                
                                if(dRSI()>50 && dRSI()<=70)
                                        {
                                                ObjectSetText("M4X - RSI", "RSI=" + DoubleToString  (sVal,0),8,"Tahoma",White);
                                        }
                                else if(dRSI()<50 && dRSI()>=30)
                                        {
                                                ObjectSetText("M4X - RSI", "RSI=" + DoubleToString (sVal, 0),8,"Tahoma",White);
                                        }
                        else if(dRSI()>70 || dRSI()<30)
                                {
                                        ObjectSetText("M4X - RSI", "RSI=" + DoubleToString (sVal, 0),8,"Tahoma",White);
                                }
                        else
                                {
                                        ObjectSetText("M4X - RSI", "RSI=" + DoubleToString (sVal, 0),8,"Tahoma",CLR_NONE);
                                }
                        }
  }

double dRSI()
        {
                return(iRSI(NULL,0,Periods,Price,Shift));
        }
        
Alexander Voronkov
27526
Alexander Voronkov  
Blackjack822:
Thank you it worked :)
I've got one more question I'm new in this stuff, can you have a look and tell me if I've done it the long way around? or is there an easier way to do it?
#property indicator_chart_window

extern int                Periods=14;
extern ENUM_APPLIED_PRICE Price=PRICE_CLOSE;
extern int                Shift=6;

//-------------------------------------------------|

int init()
{
   if(ObjectFind("M4X - RSI")!=0)
   {
      ObjectCreate("M4X - RSI",OBJ_LABEL,0,0,0,0,0);
      ObjectSet("M4X - RSI",OBJPROP_XDISTANCE,260);
      ObjectSet("M4X - RSI",OBJPROP_YDISTANCE,1);
   }
   return(0);
}

//-----------------------------------------|

double dRSI()
{
   return(iRSI(NULL,0,Periods,Price,Shift));
}

//-----------------------------------------|

int start()
{
   int iIndicatorCounted=IndicatorCounted();
   if(iIndicatorCounted<0)
   {
      return(-1);
   }

   string text;
   double sVal;
   color  cRSI;

   sVal =(dRSI());

   if(dRSI()>50 && dRSI()<=70)
   {
      text = StringConcatenate( "RSI=", DoubleToString(sVal,0));
      cRSI = clrWhite;
   }
   else if(dRSI()<50 && dRSI()>=30)
   {
      text = StringConcatenate( "RSI=", DoubleToString(sVal,0));
      cRSI = clrWhite;
   }
   else if(dRSI()>70 || dRSI()<30)
   {
      text = StringConcatenate( "RSI=", DoubleToString(sVal,0));
      cRSI = clrWhite;
   }
   else
   {
      text = "";
      cRSI = clrNONE;
   }

   ObjectSetText("M4X - RSI",text,8,"Tahoma",cRSI);
   return(0);
}
)
Black_Jack822
57
Black_Jack822  
Alexander Voronkov:
)
Thank you it makes things more clear.
I wanna ask you something else. I'm using script to hide all the drawings from the chart (fibo, sup. res. etc.) but it also hides the indicator that you've help me with (and I don't want that) but it leaves different one that I've also have on the chart. I've tried to compare both indicators to find some code which prevent one indicator from being hide but no luck and I'm stuck.
Can you help?
To add comments, please log in or register