Can anyone give me a ObjectCreate sample? I create one and it doesn't work. Thanks.

 

My code is, help me to make it work.

ObjectCreate("text_object", OBJ_TEXT, 0, Time[i], Close[i]);


ObjectSetText("text_object", "Hello world!", 10, "Times New Roman", Green);
ObjectSet("text_object", OBJPROP_XDISTANCE, 100);
ObjectSet("text_object", OBJPROP_YDISTANCE, 200);
 

string name = "text_object";

if(ObjectFind(name ) != -1) ObjectDelete(name);
ObjectCreate(name OBJ_LABEL, 0, 0, 0, 0, 0);
ObjectSetText(name, "Hello world!", 10, "Times New Roman", Green);
ObjectSet(name, OBJPROP_COLOR, Green);
ObjectSet(name, OBJPROP_CORNER, 0);
ObjectSet(name, OBJPROP_XDISTANCE, 100);
ObjectSet(name, OBJPROP_YDISTANCE, 200);

 

Thanks, and I need your another help:

How do I do to place the text a little bit to the right of current bar?

Should I modify the last two lines? And how to do it?

Thanks again.

 

string name = "text_object";

if(ObjectFind(name ) != -1) ObjectDelete(name);
ObjectCreate(name OBJ_TEXT, 0, 0, 0, 0, 0);
ObjectSetText(name, "Hello world!");
ObjectSet(name, OBJPROP_COLOR, Green);
ObjectSet(name, OBJPROP_TIME1, Time[0]+2*Period()*60);
ObjectSet(name, OBJPROP_PRICE1, Bid);

 

I can see the text shown there now. And my whole function it to show a text besides the bar which open price < close price, and I code like this:

But it only show one text on the chart. Thanks.

for(int i=0; i<limit; i++)

{
if(Open[i]<Close[i])
{
string name = "MODEA"+i;

if(ObjectFind(name) != -1) ObjectDelete(name);
ObjectCreate(name, OBJ_LABEL, 0, 0, 0, 0, 0);
ObjectSetText(name, name);
ObjectSet(name, OBJPROP_COLOR, Green);
ObjectSet(name, OBJPROP_CORNER, 0);
ObjectSet(name, OBJPROP_TIME1, Time[i]+2*Period()*60);
ObjectSet(name, OBJPROP_PRICE1, Bid);
}
}
 

if(ObjectFind(name) != -1) ObjectDelete(name);
ObjectCreate(name, OBJ_TEXT, 0, 0, 0, 0, 0);
ObjectSetText(name, name);
ObjectSet(name, OBJPROP_COLOR, Green);
ObjectSet(name, OBJPROP_TIME1, Time[i]+2*Period()*60);
ObjectSet(name, OBJPROP_PRICE1, High[i]);

 
It works! Thank you very much. You're my hero!
 

Thanks, phy, I need your more help.

I know the third parameter of ObjectCreate is window, 0 is the main chart window.

What should I do if I want the text displayed in the current indicator window?

 

Problem sovled:

ObjectCreate(name, OBJ_TEXT, WindowFind("MODEA"), 0, 0, 0, 0);

 

This is an older thread, so I hope no one minds.

My question is very similar, but more simple.


In backtesting, a line is drawn between open and closed positions.

I want to forward test my Grid and see these lines.

The Grid EA opens a bunch that it doesn't close.

How can I add that backtesting connect line to my EA?

 
almo1010:

This is an older thread, so I hope no one minds.

My question is very similar, but more simple.


In backtesting, a line is drawn between open and closed positions.

I want to forward test my Grid and see these lines.

The Grid EA opens a bunch that it doesn't close.

How can I add that backtesting connect line to my EA?


Use colors in your OrderSend and Orderclose functions

Reason: