Hello!
To delete the old line, use ObjectDelete("somename"); I have not worked with objects myself, but found a bit of code in an indicator I recently downloaded.
To delete the old line, use ObjectDelete("somename"); I have not worked with objects myself, but found a bit of code in an indicator I recently downloaded.
datetime T1,T2; int B1, B2; // bar index on the chart (the bar# you'd use to access the bar). double PP, PP2; // price values ... T1=Time[B1]; T2=Time[B2]; ObjectCreate("TL1",OBJ_TREND,0,T2,PP2,T1,PP); ObjectSet("TL1",OBJPROP_COLOR,Lime); ObjectSet("TL1",OBJPROP_WIDTH,2); ObjectSet("TL1",OBJPROP_STYLE,STYLE_SOLID);
This snippet practically creates a line with the name TL1 from B1/PP to B2/PP2.
If you do an ObjectDelete("TL1"); before that and then create it for new.
Or use an ObjectFind() to find your existing line and use ObjectSet() to modify the points and prices there.
Hope this helps.
Markus
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I know I have to use ObjectCreate, but I don't fully understand how to use it. I would really appreciate it if someone could post the code for something simple like, "If EMA1 crosses EMA2, draw a vertical line at the bar of the cross". Also, how do you delete the old line when a new cross occurs.
If I had that code I know that I'd be able to modify it to fit more complex parameters.
Thanks to anybody that can help.