I created different codes for mql4 but one thing I'd like to learn
how to create an inscription on the graph using comment or ObjectCreate ("label_object", OBJ_LABEL, 0, 0, 0)
I can not seem to shows the message (uploading and activating the program)
OK so you have created an object at pixel position 0, 0 but it does not have any text in it, you haven't set the colour, size or font.
Use ObjectSetText() and ObjectSet()
no i write, the program run correctly in a becktesting mode..
i (think)to have correctly sett the position and the size ecc of the object..
but it go only in the becktestmode and no when active expert advisor...
no i write, the program run correctly in a becktesting mode..
i (think)to have correctly sett the position and the size ecc of the object..
but it go only in the becktestmode and no when active expert advisor...
Ah I see, it works in the Strategy Tester but not on a Live/Demo chart.
You should test it again on Live/Demo, when you think it should have created the Object right click on your chart and select Objects List (Ctrl + B) see if you can find the Object, if you can find the Object in the list double click the Object and check it's parameters to see where it is located and if it's other properties are correct or incorrect, the location or other properties, if incorrect, may give you some idea of what is causing your problem.
in order to have a working program to compare
( that designs some message on the graphic , and not only in becktesting mode)
in order to have a working program to compare
is not a sicret!!
#property link ""
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
if(!ObjectCreate("text_object", OBJ_TEXT, 0, D'2004.02.20 12:30', 1.0045))
{
Print("error: can't create text_object! code #",GetLastError());
return(0);
}
// new label object
ObjectCreate("label_object", OBJ_LABEL, 0, 0, 0);
ObjectSet("label_object", OBJPROP_XDISTANCE, 200);
ObjectSet("label_object", OBJPROP_YDISTANCE, 100);
ObjectSetText("label_object","asdasd",16,"Arial");
// it's position
ObjectSet("label_object",OBJPROP_CORNER,0);
ObjectSet("label_object",OBJPROP_XDISTANCE,100);
ObjectSet("label_object",OBJPROP_YDISTANCE,100);
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
if(!ObjectCreate("text_object", OBJ_TEXT, 0, D'2004.02.20 12:30', 1.0045))
{
Print("error: can't create text_object! code #",GetLastError());
return(0);
}
// new label object
if(!ObjectCreate("label_object", OBJ_LABEL, 0, 0, 0))
{
Print("error: can't create label_object! code #",GetLastError());
return(0);
}
ObjectSet("label_object", OBJPROP_XDISTANCE, 200);
ObjectSet("label_object", OBJPROP_YDISTANCE, 100);
ObjectSetText("label_object","asdasd",16,"Arial");
// it's position
ObjectSet("label_object",OBJPROP_CORNER,0);
ObjectSet("label_object",OBJPROP_XDISTANCE,100);
ObjectSet("label_object",OBJPROP_YDISTANCE,100);
return(0);
}
//+------------------------------------------------------------------+
is not a sicret!!
<CODE DELETED>
is not a sicret!!
Read this: https://www.mql5.com/en/forum/144875
You can't create an Object that already exists . . . when yo look on a live chart are you scrolling back to 2004 to find your text Object ? that is where you are placing it . . . D'2004.02.20
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
how to create an inscription on the graph using comment or ObjectCreate ("label_object", OBJ_LABEL, 0, 0, 0)
I can not seem to shows the message (uploading and activating the program)
while if I simulate the same program I can see the message on my chart!!
is a problem that I hope I have explained well!maybe a problem with my metatreder options?
i need help!