A question for MQL connoisseurs - page 3 1234567891011 New comment [Deleted] 2010.08.15 15:37 #21 Somewhere I got the advice to always check if an object exists before using ObjectCreate (or ObjectSet? I don't remember) In general, I use this variant if (ObjectFind("AsignalGF")==-1) {ObjectCreate("AsignalGF",OBJ_LABEL,0,0,0,0,0); ObjectSet("AsignalGF",OBJPROP_CORNER,1); ObjectSet("AsignalGF",OBJPROP_XDISTANCE,12*1); ObjectSet("AsignalGF",OBJPROP_YDISTANCE,1*5); ObjectSetText("AsignalGF",CharToStr(110),38,"Wingdings",DimGray);} keekkenen 2010.08.15 15:38 #22 leonid553: Good afternoon. Spent half a day already and can't figure it out. Please advise what may be the error here ? Could it be in INIT function ?the error could be 1. If you call WindowFind() in init() or in a function that is called in init 2. windowFind() and you have #property indicator_chart_window declared, since windowFind() is called for subwindow 3. there is no indicator with the name you are looking for in the window ObjectCreate question [WARNING CLOSED!] Any newbie Any questions from newcomers [Deleted] 2010.08.15 15:47 #23 keekkenen: 3. the indicator with the name you are looking for is not in the window mmm... what do you mean object? keekkenen 2010.08.15 16:22 #24 Abzasc: mmm... what do you mean object? what does this have to do with the object ? The object is secondary, because it is trying to be rendered in a window which does not exist, besides, if the object is created, there will be no error, if the object is created secondarily, ObjectCreate() will return false ObjectCreate bug Any questions from newcomers Problems with ObjectCreate [Deleted] 2010.08.15 16:36 #25 keekkenen: what does this have to do with the object ? The object is secondary, because it is trying to be rendered in a window that doesn't exist, besides, if the object is created, no error will occur, if the object is created secondarily, ObjectCreate() will return false Got it, thanks :) Leonid Borsky 2010.08.15 18:19 #26 keekkenen: error can be 1. if you call WindowFind() in init() or in function which is called in init 2. windowFind() and you have #property indicator_chart_window declared, because windowFind() is called for subwindow 3. the indicator with the name you are looking for is not present in the window 1. No, I call the function in START : object("Symbol1", Symbol_1, 11, Color_1, 5); 2. You have declared #property indicator_separate_window 3. So how can an indicator be missing if its window is present ? Here is the function itself : void object(string name, string _text, int fontsize, color color_, int value) { // задаем окно индикатора ObjectCreate(name+ WindowExpertName(), OBJ_LABEL, WindowFind(WindowExpertName()), 0, 0); // задаем текстовую метку в окне ObjectSetText(name+ WindowExpertName(), _text, fontsize, "Times New Roman", color_); ObjectSet(name+ WindowExpertName(), OBJPROP_CORNER, 1);//задаем правый угол ObjectSet(name+ WindowExpertName(), OBJPROP_XDISTANCE, 4);//задаем х-координату ObjectSet(name+ WindowExpertName(), OBJPROP_YDISTANCE, value);//задаем у-коордтнату } I don't call anything at all in INIT. Maybe I should add something there as well? Any rookie question, so Questions from Dummies. Scope of global variables Leonid Borsky 2010.08.15 18:27 #27 Abzasc:Somewhere I got the advice to always check if an object exists before using ObjectCreate (or ObjectSet? I don't remember) In general, I use this variant. What name should I specify in (ObjectFind("AsignalGF") - What should I set the name of the indicator or the name (array) of the line drawn by the indicator? [Deleted] 2010.08.15 18:31 #28 leonid553: Which name should I set in (ObjectFind("AsignalGF") - indicator name or the (array) name of the line drawn by the indicator? The name of the object that is created/changed. Leonid Borsky 2010.08.15 18:50 #29 I think I got it. I set the name of the object in the function. ObjectCreate(name+ WindowExpertName(), OBJ_LABEL, WindowFind(WindowExpertName()), 0, 0); [Deleted] 2010.08.15 19:09 #30 leonid553: I set the name of the object in the function. ObjectCreate(name+ WindowExpertName(), ....); Yeah, that's what we're looking for. 1234567891011 New comment
Somewhere I got the advice to always check if an object exists before using ObjectCreate (or ObjectSet? I don't remember)
In general, I use this variant
Good afternoon.
Spent half a day already and can't figure it out.
Please advise what may be the error here ? Could it be in INIT function ?the error could be
1. If you call WindowFind() in init() or in a function that is called in init
2. windowFind() and you have #property indicator_chart_window declared, since windowFind() is called for subwindow
3. there is no indicator with the name you are looking for in the window
3. the indicator with the name you are looking for is not in the window
mmm... what do you mean object?
what does this have to do with the object ?
The object is secondary, because it is trying to be rendered in a window which does not exist,
besides, if the object is created, there will be no error, if the object is created secondarily, ObjectCreate() will return false
what does this have to do with the object ?
The object is secondary, because it is trying to be rendered in a window that doesn't exist,
besides, if the object is created, no error will occur, if the object is created secondarily, ObjectCreate() will return false
error can be
1. if you call WindowFind() in init() or in function which is called in init
2. windowFind() and you have #property indicator_chart_window declared, because windowFind() is called for subwindow
3. the indicator with the name you are looking for is not present in the window
1. No, I call the function in START : object("Symbol1", Symbol_1, 11, Color_1, 5);
2. You have declared #property indicator_separate_window
3. So how can an indicator be missing if its window is present ?
Here is the function itself :
I don't call anything at all in INIT. Maybe I should add something there as well?Somewhere I got the advice to always check if an object exists before using ObjectCreate (or ObjectSet? I don't remember)
In general, I use this variant.
What name should I specify in (ObjectFind("AsignalGF") -
What should I set the name of the indicator or the name (array) of the line drawn by the indicator?
Which name should I set in (ObjectFind("AsignalGF") -
indicator name or the (array) name of the line drawn by the indicator?
I think I got it. I set the name of the object in the function.
ObjectCreate(name+ WindowExpertName(), OBJ_LABEL, WindowFind(WindowExpertName()), 0, 0);
I set the name of the object in the function. ObjectCreate(name+ WindowExpertName(), ....);