Stop clearing previous CreatedObjects
It does not. It draws one object. Objects must have unique names.
It does not. It draws one object. Objects must have unique names.
OK how do I fix that then? put the names in an array?
Right I've solved my own problem (with help from Williams suggestion). Didnt need to use an array either.
int x; string name; void OnTick() { for (x=100; x>0; x--) { double OpenPrice=Open[x]; name="Text_Object"; name=name+x; //Add value to Text_Object to make name unique ObjectCreate(name, OBJ_TEXT, 0, 0, 0, 0, 0); ObjectSetText(name, "X"); ObjectSet(name, OBJPROP_COLOR, Blue); ObjectSet(name, OBJPROP_TIME1, Time[0]-x*Period()*60); ObjectSet(name, OBJPROP_PRICE1, OpenPrice); Comment("Bar=",x,"\nObject Unique Name: ",name); // slow the code execution for testing Sleep(200); } return; }
-
Close, but you used as-series indexes. When a new bar start you will try to create name+0 but you have already used that name.
To make the names unique, either use time or non-series index (Bars-1-index).
-
You used Time[0] (a constant) for all objects.
Hi
This should be simple, my code just draws an X under the OpenPrice of the last 100 candles.
My code does this but it keeps clearing the previous X's I would like it to keep them on screen,
as in I would like all 100 X's to stay on the screen. Thanks