Download MetaTrader 5

Create Objet

To add comments, please log in or register
Frenchytrader
389
Frenchytrader  

Hi all,

Here the code I use to insert data

  ObjectCreate("txt_0",OBJ_TEXT,0,TimeCurrent() -100, Close[0] + 140 * Point);   
   ObjectSetText("txt_0", "Example", 14, "Times New Roman", Orange);
   ObjectMove("txt_0", 0, TimeCurrent() - 100, Close[0] + 140 * Point);

I would need to insert data on screen which you be fixed.

If I don't use ObjectMove(..) function, while the chart is running, the data will disapear.

Can anyone could provide an example how to display fixed data?

Thank you

Carl Schreiber
7112
Carl Schreiber  

I am using something like this:

void showTxt(string line0) {
        static string lable1= "";
        ...
        if ( lable1 == "" )
                lable1 = plcTxtLabel("Lab1", 10, 5, 3);
        ObjectSetText(lable1, line0, 10, "Tahoma", clr);
        ..
}

string plcTxtLabel(string n, int x, int y, int corner) {
        n = idEA + n;
        ObjectDelete(n);
   ObjectCreate(n, OBJ_LABEL, 0, 0, 0);
   ObjectSet(n, OBJPROP_CORNER, corner);
   ObjectSet(n, OBJPROP_XDISTANCE, x);
   ObjectSet(n, OBJPROP_YDISTANCE, y);
   ObjectSet(n, OBJPROP_BACK, FALSE);
   return (n);
}

It is not really the original code so it is not tested nor compiled but might give you a hint..

Frenchytrader
389
Frenchytrader  
Thank you, but I can't use it
Toast
226
Toast  

As gooly has alluded to:

You are using OBJ_TEXT. These objects are fixed to a point in time. So as time progresses on the chart, your object will disappear off the screen to the left.

If you use OBJ_LABEL, you set the position relative to the window. This means the object does not move, even as time progresses.

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI  
Good. You are able to differentiate the object usage. :)
Frenchytrader
389
Frenchytrader  
I got it...Thank you
To add comments, please log in or register