Study this short code and it might help you. Everything is implemented in Canvas.
The good thing about Canvas is that for MT4 and MT5 the code will be almost the same.
Hello, dear programmers!
Please give your best advice:
...
Thank you ))
Draw on canvas:

- www.mql5.com
You are thinking correctly.
//подсчитывает количество пунктов цены в одном пикселе double GetPointsInPixel(long eChartId, int eWindow) { double eMin=EMPTY_VALUE; ChartGetDouble(eChartId,CHART_PRICE_MIN,eWindow,eMin); if(eMin==EMPTY_VALUE) return(0); double eMax=EMPTY_VALUE; ChartGetDouble(eChartId,CHART_PRICE_MAX,eWindow,eMax); if(eMax==EMPTY_VALUE) return(0); long ePixels=-1; ChartGetInteger(eChartId,CHART_HEIGHT_IN_PIXELS,eWindow,ePixels); if(ePixels<=0) return(0); return(double(eMax-eMin)/ePixels); }
double eIndent=GetPointsInPixel(eChartId,eWindow);
Then add or subtract this value to the required price, when the events change:
-change of timeframe,
-Increase/decrease of a chart,
-shrinking of the price scale.
Study this short code and it might help you. Everything is implemented in Canvas.
The good thing about Canvas is that for MT4 and MT5 the code will be almost the same.
OK, Thank you )
Oops... Nikolai beat me to it...
... ))))))The main thing is that the thoughts are the same ))))
Thanks )))))
You are thinking correctly.
double eIndent=GetPointsInPixel(eChartId,eWindow);
Then add or subtract this value to the required price, when the events change:
-change of timeframe,
-Increase/decrease of a chart,
-shrinking/shrinking of the price scale.
Thank you ))))))))
Vitaliy Kostrubko:
You are thinking correctly.
double eIndent=GetPointsInPixel(eChartId,eWindow);
Then add or subtract this value to the required price, when the events change:
-change of timeframe,
-Increase/decrease of a chart,
-shrinking/shrinking of the price scale.
Thank you ))))))))
And tell that woeful consultant that he needs to start learning the language, not the ****coders examples.
And tell that woeful consultant that he needs to start learning the language, not the ****coders examples.
Copy )))))
... Time shows, that even 10 years of programming experience with a variety of EAs (different levels of complexity) == it's not enough to know the whole field of coding)
because during these 10 years you can become a super-professional in 2/3 of programming language ... and don't know 1/3 of it at all))
so no need to be offended)) but it's up to you to master this 1/3 part == it's an individual matter)).
.... he's just more interested in "Cunning ALGORITHMs that bring PROFIT... and writing "cartoons" is not his interest ...
But your example I will show him for sure)).
Thanks ))))
Take it )))))
... Time shows that even 10 years of programming experience with the most various EAs (different levels of complexity) == it's not enough to know the TOTAL coding area)
because during these 10 years you can become a super-professional in 2/3 of programming language ... and don't know 1/3 of it at all))
so no need to be offended)) but it's up to you to master this 1/3 part == it's an individual matter)).
.... he's just more interested in "Cunning ALGORITHMs that bring PROFIT... and "cartoons" are not his interest ...
But your example I will show him for sure )).
Thanks ))))
You don't have to refer to me. That option, although I used it, I did not voice it. I was only supporting my namesake in his opinion.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello Dear programmers!
Please give your advice:
We make an Expert Advisor in the form of an indicator! Its task - to search for a PATTERN on the chart, and over the bars to write text (multi-line (!), such as
line #1 "signal name"
line #2 "% probability"
line #3 "icon" (arrow)
The problem is that IF you set a FIXED distance between lines = e.g. 25 pips, everything is fine on m5 ... but on H1 = the lines get too far apart (this is the problem with fixed text (!!!)
Please advise - HOW can we make "automatic calculation" of the distance between lines when the TF changes or the "height" of the graph when the graph is shifted slightly to the left, or by height (????!!!)
..... only one thing comes to mind:
1) "get" the current chart height (min. and max. price) :
2) Max Price - Min. Price = "chart height in pips" and we always take it as 100%.
3) instead of "fixed distance between the lines (25 pips) - specify the distance in Percent (e.g. 2% of the chart height from point 2))
..... talked to a programmer - he says == DO NOT MOVE OBJECTS ... well, you can't ....... after flipping the chart == reposition the multi-line text so it won't overlap each other == you have to delete all text after flipping the chart == delete all text, and rewrite it anew, taking into account the new elevation of the chart (point 2) (!)
..... then I keep pondering == OK, what if = do the drawing ONLY in the SCREEN GUIDE ???!
It says = ok, NEW signals will be written Correct, but those that are left = = = OR again fit back on top of each other, or vice versa = stretch even wider (up and down each other) because "you can not move the already drawn objects, but need only delete them, and redraw anew (!)
Question to you = Has anyone already encountered such a ??????? how have solved this problem ??? )))
(so that at any scale and height of the chart = multiline text returns to normal line spacing (if measured with a ruler visually == 3mm by eye ) ... i.e. line spacing should be DYNAMIC) ????? )))))))))
I just do not want to make the entire inscription in ONE line, and at an angle of 45° (!) , because it is visually more convenient to make the text HORIZONTAL, and in 2-3 lines :)
Please advise (share your experiences)
Thanks )).