Here is my code. I want that every times I change the property "line", the old horizontal line will be deleted and the new one will be created. How to change my code to make that happen?
One more thing: Sometime I start my code with value in property "line" it wont draw a line, and sometime does. And when I change the value of property "line" it wont create a new line. Does any one know why?
THANK YOU SO MUCH FOR YOUR TIME!!!
- Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes
- LRC custom code
- How to draw a horizontal Lines? Please Help
Pain : I want that every times I change the property "line", the old horizontal line will be deleted and the new one will be created. when I change the value of property "line" it wont create a new line.
- ObjectCreate creates a new line. Once it exists your create fails and the old one still exists. This you would have learned that had you checked the return code. What are Function return values ? How do I use them ? - MQL4 forum
- Choice A) ObjectDelete the original and create a new one.
- Choice B) move it to the new position
void HLine(string name, double P0, color clr){ #define iCB 0 if ( ObjectMove(name, 0, Time[iCB], P0) ){} #define WINDOW_MAIN 0 else if( !ObjectCreate( name, OBJ_HLINE, WINDOW_MAIN, Time[iCB], P0) ) AlertMe( "ObjectCreate(",name,",HLINE) failed: ", GetLastError() ); if( !ObjectSet(name, OBJPROP_COLOR, clr) ) // Allow color change AlertMe( "ObjectSet(", name, ",color) [1] failed: ", GetLastError() ); if( !ObjectSetText(name, PriceToStr(P0), 10) ) AlertMe( "ObjectSetText(",name,") [3] failed: ", GetLastError() ); } string PriceToStr(double p){ return( DoubleToStr(p, Digits) ); }
iTime(NULL,0,0)
Why are you using an expensive function call instead of the simplifier, predefined Time[0]

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