Page 1 of 1

Creating Objects in Indicators

Posted: Sat Nov 18, 2017 7:10 am
by adamhartley
I'm trying to add some code to my FT3 indicator to create some objects but am struggling so I have a couple of questions:

1. Is it even possible to create objects within indicators or can this only be done within strategies? The fact that the functions are listed in the Indicators API Help would lead me to believe that it can be done but I'm struggling. As things weren't working I ended up copying the very simple supplied example code to create a vertical line and even that didn't work, with the ObjectCreate function returning false every time and printing out my error message.

Code: Select all

   char* names[] = { "Line0", "Line1", "Line2", "Line3", "Fibo1",
      "Fibo2", "Fibo3", "Fibo4", "Text1" };

   if (!ObjectExists(names[0]))
   {
      if (ObjectCreate(names[0], obj_VLine, 0, Time(index), 0))
      {
         ObjectSet(names[0], OBJPROP_STYLE, psSolid);
         ObjectSet(names[0], OBJPROP_COLOR, clRed);
         ObjectSet(names[0], OBJPROP_WIDTH, 1);
      }
      else
         Print("Failed to created vertical line");
   }


2. There doesn't seem to be an obj_Rectangle type defined - I'm actually trying to create Rectangles but ended up trying lines just to try to get something working. Is there a way of doing this?

TIA


Adam