How do I learn to create graphical objects? MQL4. - page 5

 

I tried to transfer the EA code to the script.

The lines overlapped in the script, I do not understand why they do not work in the Expert Advisor?

Who has managed to draw objects in the sub-window of the chart when starting visualization of the Expert Advisor?


 
forexman77:

I tried to transfer the EA code to the script.

The lines overlap in the script, I don't understand why they don't work in the EA?

Who has managed to draw objects in the sub-window of the chart when starting visualization of the Expert Advisor?


Specify the number of the subwindow of the indicator in which you are going to draw.
 
Artyom Trishkin:
Specify the indicator subwindow number in which you are going to draw.

This way it gives out -1 in the EA. In the script, everything is fine, the picture above. I read your article about AD indicator, a lot of times, I don't understand it yet. As always the reason is in some small thing.

As far as I understand, the window is not detected in the EA for some reason, error 4206.

 
forexman77:

This way it gives out -1 in the EA. In the script, everything is fine, the picture above. I read your article about AD indicator, a lot of times, I don't understand it yet. As always the reason is in some small thing.

As far as I understand the window is not detected in the EA for some reason, error 4206.

The indicator window needs time to be created. The indicator window can be drawn not earlier than the first call of OnCalculate(). Do you want to draw everything in OnInit()?
 
Karputov Vladimir:
The indicator window needs time to be created. In the indicator window, you can draw not earlier than the first call of OnCalculate(). Do you want to draw everything in OnInit()?
No. Only after a trade is opened, i.e. the opening lines of the position go first, when it is opened the rendering starts.

Here is the code in the EA.

string   shortName="fraktalSDV"; 
long   chart_ID=0;        // ID графика
int win_idx=ChartWindowFind(chart_ID,shortName);
string nameobj=TimeToStr(Time[0]);       
            //--- сбросим значение ошибки
            ResetLastError();
            //--- создадим трендовую линию по заданным координатам
           if(!ObjectCreate(chart_ID,nameobj,OBJ_TREND,win_idx,Time[index],maximum1,Time[1],TRENDmax[1]))
            {
            Print(__FUNCTION__,
                  ": не удалось создать линию тренда! Код ошибки = ",GetLastError());
            return(0);
            }
ObjectSet(nameobj,OBJPROP_RAY,false); 

There is a line in the indicator itself:

IndicatorShortName("fraktalSDV");

 
forexman77:

This way it gives out -1 in the EA. In the script, everything is fine, the picture above. I read your article about AD indicator, a lot of times, I don't understand it yet. As always the reason is in some small thing.

As far as I understand the window is not detected in the EA for some reason, error 4206.

It does not find the indicator subwindow. Look for the indicator window by the short indicator name - the one you see at the top-left of the indicator window. You must not have entered the whole name to search for it.
 
Artyom Trishkin:
It does not find the indicator subwindow. Look for the indicator subwindow by the short indicator name - the one you see at the top-left of the indicator window. You probably don't put in the whole name to search for it.

string shortName="fraktalSDV";

I call it this way. I tried to call the name of the indicator in the Expert Advisor and unset it, it didn't work so far.

Here is the indicator itself. I will delete it later.

 
forexman77:

string shortName="fraktalSDV";

I call it this way. I tried to call the name of the indicator in the Expert Advisor, it did not work so far.

Try in

int win_idx=ChartWindowFind(chart_ID,shortName);

I should not put the search of the indicator window, but one (is there only one window on the chart?)

If it works, then return the window search to

long   chart_ID=0;        // ID графика

type in

long   chart_ID=ChartID();
 
Artyom Trishkin:

Try to

enter one instead of the indicator window search (is there one window on the chart?)

At the top of the chart itself with quotes and at the bottom in the separator of the indicator.
 
forexman77:
At the top is the chart itself with the quotes and at the bottom in the separatum is the indicator.
So do as they tell you ;) You have to look for the error...
Reason: