Why the second line-object is not auto-updated as programmed !
Don't keep deleting the lines, you just need to move them . . read the Documentation about Object Functions
In particular ObjectSet()
RaptorUK:
Don't keep deleting the lines, you just need to move them
And always test your return codesDon't keep deleting the lines, you just need to move them
void HLine(string name, double P0, color clr){ // #define WINDOW_MAIN 0 if (!Show.Objects) return; if (ObjectMove( name, 0, Time[0], P0 )){} else if (!ObjectCreate( name, OBJ_HLINE, WINDOW_MAIN, Time[0], P0 )) Alert("ObjectCreate(",name,",HLINE) failed: ", GetLastError() ); if (!ObjectSet(name, OBJPROP_COLOR, clr )) // Allow color change Alert("ObjectSet(", name, ",Color) [1] failed: ", GetLastError() ); if (!ObjectSetText(name, PriceToStr(P0), 10)) Alert("ObjectSetText(",name,") [3] failed: ", GetLastError()); }from my code
Well you started off ok
if (ObjectFind("Topline")==-1) { ObjectCreate("Topline",OBJ_HLINE,0,30,Top); LastTop=Top; } if (LastTop!=Top) { ObjectDelete("Topline"); LastTop=Top; }
You used "Topline" in all three cases.
Then you went NUTS
if (ObjectFind("Bottom")==-1) { ObjectCreate("BottomBline",OBJ_HLINE,0,30,Bottom); LastBottom=Bottom; } if (LastBottom!=Bottom) { ObjectDelete("Bottomline"); LastBottom=Bottom; }
and used