[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 238

 
charter:
How do I draw a trend channel programmatically?
https://www.mql5.com/ru/code/9734
 
Thank you very much.
 

It turned out to be wrong.

Reworked the script into a separate function. It doesn't want to work.

It can only work as a script that needs to be thrown on the chart in the place where you want it to draw.

And I would like the EA to draw the trend lines itself.

 
charter:

It turned out to be wrong.

Reworked the script into a separate function. It doesn't want to work.

It can only work as a script that needs to be placed on the chart in the place where you want it to draw.

I would like the EA to draw the trend lines itself.


It's not difficult, if you look into the logic of the script. What is going on there? After all, the same should be done in the Expert Advisor. First, we calculate 2 coordinates for setting the line. Second, the trend line is an object. Therefore, in order to set this object on the chart, we need to use the ObjectCreate function. In fact, the MetaEditor's Help should help identify all functions that begin with the word Object - this will eliminate a lot of questions. Take a look here
 
Thank you Victor, I'll look into it.
 

I don't save objects, lines, channels, shapes and the like as soon as I switch to another timeframe, this was not the case before, and now I have to redraw it again with every switch. I don't know what to do with that, I just do not know how to do it.

 
trachtorbek:

I don't save objects, lines, channels, shapes and the like as soon as I switch to another timeframe, this was not the case before, and now I have to redraw it again with every switch. I have no such problems before, now I have to redraw it every time I move to another timeframe.

Do you have some kind of lame indicator or expert that cleans all the objects.
 
sergeev:
you have some kind of screwy indicator or expert that cleans all objects.


And how can this be fixed?

 
drknn:

It is not difficult, if you look into the logic of the script. What is going on there? Well, the same thing must be done in the Expert Advisor. First, we calculate 2 coordinates for fixing the line. Second, the trend line is an object. Therefore, in order to set this object on the chart, we need to use the ObjectCreate function. In fact, the MetaEditor's Help should help identify all functions that begin with the word Object - this will eliminate a lot of questions. Take a look here

The difficulty is finding the points through which the line will later be drawn.

It is not difficult to draw lines when you can see these points. How do you "see" them programmatically?

 
charter:

It's not hard to draw lines when you see these points. How do you "see" them programmatically?

iHighest and iLowest to help you, and read the ZZ algorithm

ZS:not the easiest task, the code will be small, but the algorithm is complex, I can not find the code, but that's how I searched for a peak at High: High[iHighest(NULL,0,MODE_HIGH,i)

Reason: