A question for MQL connoisseurs - page 4

 
What the hell... I got into the "Question for MQL Expertise"... Sorry, if anything, I'm as good a programmer as a d.... but i'm always objective ! :)
 
leonid553:

I think I got it. I set the name of the object in the function.

ObjectCreate(name+ WindowExpertName(), OBJ_LABEL, WindowFind(WindowExpertName()), 0, 0);


It's not about objects...

You write it in init()

IndicatorShortName("CC-STOKS ");

You use WindowExpertName() as an indicator name in a rendering function...

Make up your mind, dear fellow (sorry for being familiar), either the indicator is called "CC-STOKS" (an alias), or it is named after the expert...

 

I'm talking about my...

Well, I don't see a check for an object.

 

Removed IndicatorShortName("CC-STOKS ") line;

Seems to work now.

//------------------------------------------

Checked it.

 string info =ObjectFind("Symbol1+WindowExpertName()");
     IndicatorShortName(info);     

The comment returns "-1".

And - it doesn't matter if the "alias" is there or if it's deleted.

 

Yes, it's working fine...

Thanks to everyone who helped and answered questions!

 

I've had a few beers, but you're blowing my mind...

make it clear what's going on...


or

1. no shortname and

static int WINDOW = -1;

int start(){
   if (WINDOW == -1) WINDOW = WindowFind( WindowExpertName() );
}

your init() as is

or set the shortname in your int()

string short = "CC-STOKS";

int init(){
   IndicatorShortName( short );
   // остальное прочее
}

int start(){
   if (WINDOW == -1) WINDOW = WindowFind( short );
}

and then when drawing objects, use WINDOW as the subwindow number

ObjectCreate(name + WindowExpertName(), OBJ_LABEL, WINDOWS, 0, 0);

the object function should look like this

void object(string name, int window, string text, color col, int corner,
            int x, int y, bool back = false, int fontsize = 9, 
            string fontname = "Tahoma") {
   if (ObjectFind(name)==-1)      
      ObjectCreate(name, OBJ_LABEL, window, 0, 0);
   ObjectSetText(name, text, fontsize, fontname, col);
   ObjectSet(name, OBJPROP_CORNER, corner);
   ObjectSet(name, OBJPROP_BACK,back);
   ObjectSet(name, OBJPROP_XDISTANCE, x);
   ObjectSet(name, OBJPROP_YDISTANCE, y);     
}

this way, all the key attributes are passed as parameters, and by the way, the object name should be formed outside the function ...

 
OK. Going through your instructions ...
 

Good afternoon. Please advise.

Is it possible to draw a triangle in the indicator window? If so, how to set coordinates?

I cannot find a way to set coordinates of a triangle in the mql help.

 
Rita:

Good afternoon. Please advise.

Is it possible to draw a triangle in the indicator window? If so, how to specify coordinates?

I cannot find a way to set coordinates of a triangle in the mql help.


ObjectCreate(имя_объекта, OBJ_TRIANGLE, 0, вершина1_время, вершина1_цена, вершина2_время, вершина2_цена, вершина3_времявершина3_цена);
If not in the main subwindow, use the corresponding subwindow number instead of 0: https://docs.mql4.com/ru/windows/WindowFind
 


ObjectCreate(name, OBJ_TRIANGLE, WindowFind(WindowExpertName(), Time[-1],vertex1_price,

Time[-5],vertex2_price,

Time[-7],vertex3_price, );

//--------------------------------------------------------------------------------------------------------------------------

I have set coordinates of triangle nodes by time (for example - by time of opening of future bars). The rest is not quite clear to me. It is not price that is displayed on the scale of the indicator window. It is the gradation of indicator values.

I need to "put" a triangle with rigidly fixed tops, regardless of the price.

And preferably, it should be rigidly fixed in the right (or lower) corner.

And I don't know how to set the coordinates of its vertices - on the vertical axis of the indicator scale: