Help please, Add a number to end of a MA line

 

This is the code I have

  SetIndexLabel(1, "MA " + TimeFrame + " First line");  


I would like to add a number to the end of the MA line to disgusting it from other MA lines


------------------------------------- 5  (in the example the number 5)


I added this code, and it almost works, yet not correct, help appreciated 😊

 
  ObjectCreate(" 1stLine ",OBJ_TEXT,0,0,0);
  ObjectSet(" 1stLine ",OBJPROP_TIME1,Time[0]+(1*Period()*60));
  ObjectSet(" 1stLine ",OBJPROP_PRICE1,firstLine[0]);
  ObjectSetText(" 1stLine",DoubleToStr(5,Digits),18,"Arial",White);

 
if (ObjectFind("1stLine") < 0)
   ObjectCreate("1stLine", OBJ_TEXT, 0, 0, 0);
ObjectSet("1stLine", OBJPROP_TIME1, Time[0]);
ObjectSet("1stLine", OBJPROP_PRICE1, firstLine[0]);
ObjectSetText("1stLine", "   1", 18, "Arial", White);
 

 Thank you Nagisa Unada, much appreciated 😊


 This is what I now have


  SetIndexLabel(1, "FastTMA " + TimeFrame + " Upper line");
  if (ObjectFind("1Upp") < 0)
  ObjectCreate("1Upp", OBJ_TEXT, 0, 0, 0);
  ObjectSet("1Upp", OBJPROP_TIME1, Time[0]);
  ObjectSet("1Upp", OBJPROP_PRICE1, upperBand[0]);
  ObjectSetText("1Upp", "   1", 18, "Arial", White);


 Yet when I place the indicator on the chart the number 1 does not appear, but if I compile the indicator while on the chart the number 1 is now visible?


 I have attached the indicator so you can look at the complete code, hoping that will make it easier for you 😊

Files:
 
   string obj_name = "1Upp";
   if (ObjectFind(obj_name) < 0)
      ObjectCreate(obj_name, OBJ_TEXT, 0, 0, 0);
   ObjectSet(obj_name, OBJPROP_TIME1, Time[0]);
   ObjectSet(obj_name, OBJPROP_PRICE1, upperBand[0]);
   ObjectSetText(obj_name, "   1", 18, "Arial", White);
   
   obj_name = "1Low";
   if (ObjectFind(obj_name) < 0)
      ObjectCreate(obj_name, OBJ_TEXT, 0, 0, 0);
   ObjectSet(obj_name, OBJPROP_TIME1, Time[0]);
   ObjectSet(obj_name, OBJPROP_PRICE1, lowerBand[0]);
   ObjectSetText(obj_name, "   2", 18, "Arial", White);
   
   if (ATRMultiplier != ATRMultiplier2)
   {
      obj_name = "2Upp";
      if (ObjectFind(obj_name) < 0)
         ObjectCreate(obj_name, OBJ_TEXT, 0, 0, 0);
      ObjectSet(obj_name, OBJPROP_TIME1, Time[0]);
      ObjectSet(obj_name, OBJPROP_PRICE1, upperBand2[0]);
      ObjectSetText(obj_name, "   3", 18, "Arial", White);
      
      obj_name = "2Low";
      if (ObjectFind(obj_name) < 0)
         ObjectCreate(obj_name, OBJ_TEXT, 0, 0, 0);
      ObjectSet(obj_name, OBJPROP_TIME1, Time[0]);
      ObjectSet(obj_name, OBJPROP_PRICE1, lowerBand2[0]);
      ObjectSetText(obj_name, "   4", 18, "Arial", White);
   }

Insert this just before "manageAlerts();".

If the values of "ATRMultiplier" and "ATRMultiplier2" are different, 4 lines will be displayed.

However, if you only need two, there is no need to add the second half.

 

Thank you Nagisa Unada, working perfectly, greatly appreciated 😊


So much clearer to have the MA lines numbered, thank you again for your generous help 👍😊

 

Why did you display my icon?

If you put it in by mistake, delete it.
 
Nagisa Unada #:Why did you display my icon? If you put it in by mistake, delete it.
Its the website (not the OP) that added your profile avatar and profile link automatically, because the OP referenced you. It happens to everyone when they are referenced in a posted.
 
Oh, I see, he probably just copied and pasted my name.
 
Nagisa Unada #:
Oh, I see, he probably just copied and pasted my name.

I have deleted it.

Reason: