- "Help me add more levels to this indicator."
- Indicators with alerts/signal
- Drawing a line based on a price level
it's very easy to spot what the problem is by using GetLastError
if(!ObjectCreate(top40, OBJ_HLINE, 0, 0, closeprice+hirange)) Alert(GetLastError());
the error you get (4204) means
4204 |
ERR_NO_OBJECT_NAME |
No object name |
one more thing
i believe you don't want the HLine to be drawn at 41.68744 (closeprice+hirange) am i right ?
extern double closeprice = 1.68744; extern double lowrange = 0.00025; extern double hirange = 0.00040; extern color LineColor = Gray;
No, I don't want it to increment to that number. I updated to the intended result.
My line of code is not within an "if" statement, like you have it. Do I need to do it that way?
I'm playing with the code more and no improvement. I established the name of the object by creating a string "top40" (w/o quotations). ObjectCreate takes the first parameter for the name of the object, which I stated as "top40", so why would I get an error 'no object name'?
Thx for your help :-)
int start() { string a="top40"; ObjectCreate(a, OBJ_HLINE, 0, 0, closeprice+hirange); ObjectSet(a, OBJPROP_STYLE, STYLE_SOLID); ObjectSet(a, OBJPROP_WIDTH, 2); ObjectSet(a, OBJPROP_COLOR, LineColor); Alert(GetLastError()); }I think I was declaring the string variable incorrectly. I had "string top40;" and now I have "string a=top40;" ...I now get an error 4200?
int start() { string a="top40"; ObjectDelete(a); // <--new line added to compensate for 4200 error "object already exists" ObjectCreate(a, OBJ_HLINE, 0, 0, closeprice+hirange); ObjectSet(a, OBJPROP_STYLE, STYLE_SOLID); ObjectSet(a, OBJPROP_WIDTH, 2); ObjectSet(a, OBJPROP_COLOR, LineColor); Alert(GetLastError()); }The new line "Object Delete" should delete any previous instances of this. But now after compiling I get error "0", which is not in the documentation https://docs.mql4.com/constants/errorswarnings/errorcodes
wait--wait---wait!!! I think I figured it out...I'll post the working code next...WOO-HOO!!!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use