Questions from Beginners MQL5 MT5 MetaTrader 5 - page 481
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Does anyone have a code example that draws some icons, e.g. arrows on the indicator chart, when the lines cross, if there are two, or when the "0" line is crossed, or any other criteria? Preferably at the top and bottom of the self-scaling indicator window.
Press "Load". Only the last 2048 bars are automatically loaded, the rest have to be kicked.
That's how it came out after "Load" ...
Hello!
Maybe someone has an example code that draws some icons, such as arrows on the indicator chart, when crossing the lines, if there are two, or when crossing "0" line, or any other criteria? Preferably at the top and bottom of the self-scaling indicator window.
Here's one from my turkey, maybe it'll help. The code is for MT4, just as it is. It also works with logs.
Вот из моего индюка, может, поможет. Код для МТ4, выкладываю, как есть. Там еще работа с логами.
In your example it's through objects. I wonder if it's possible to do it through arrays, so that when I change scale, they are always at the top and bottom boundaries of the window?
Alexey Volchanskiy:
Thank you Alexey for your feedback!
In your example, it is through objects. I wonder if it is possible to do it through arrays, so that when I change scale, they are always at the top and bottom of the window?
I don't understand about the arrays. See the comments, I added
Further, if you need to draw on the upper border, do the following
And you should read the editor's help; it is described here in details with examples
MQL4 Reference / Standard constants, enumerations and structures / Chart constants / Examples of working with charts
I don't understand about the arrays. See the comments, I added
Further, if you need to draw on the upper border, do the following
And you should read the editor's help; it is described here in details with examples
MQL4 Reference / Standard constants, enumerations and structures / Chart constants / Examples of working with charts
Changing
Objects should be forcedly redrawn at a given distance from the window borders
With the change
objects will have to be forced to be redrawn at a given distance from the window borders
The old objects will remain in their places - at the old prices. If you need to move them to the boundaries, you will have to redraw them manually. I don't know your problem completely.
You can use OnChartEvent to track window changes.
The old objects will remain in their places - at the old prices. If you need to move them to the boundaries, you have to redraw them by hand. I just don't know your task completely.
You can use OnChartEvent to track window changes.
There is a line of any oscillator in the indicator window, which is moving relatively "0" with different amplitude.
The actual problem is:
- At "0" crossing from bottom to top, draw an arrow at the bottom border of the indicator window,
- At "0" crossing from the top downwards, to draw an arrow near the upper border of the indicator window,
- at self-scaling of the oscillator chart in the indicator window, the arrows should automatically remain at their borders of the indicator window.
I.e., scrolling the chart backwards and forwards through the history or changing its horizontal scale, the arrows always remain at the boundaries of the indicator window.
At first glance, the task seems as simple as three kopecks. BUT! ....
There is a line of any oscillator in the indicator window, which rotates relatively "0" with different amplitude.
The actual problem is:
- At "0" crossing from bottom to top, draw an arrow at the bottom border of the indicator window,
- At "0" crossing from the top downwards, to draw an arrow near the upper border of the indicator window,
- at self-scaling of the oscillator chart in the indicator window, the arrows should automatically remain at their borders of the indicator window.
I.e., scrolling the chart backwards and forwards through the history or changing its horizontal scale, the arrows always remain at the boundaries of the indicator window.
The task is and is quite simple.
When the window is changed or scrolled,OnChartEvent is called, it passes an event without parameters:
CHARTEVENT_CHART_CHANGEchart change event
If this event occurs, we determine the left and right visible bar and within these limits find all arrows in the indicator window. If it is found, we move it to the desired boundary. When creating arrows, give them names such as UpArrow***** and DownArrow***** to avoid troubles related to the analysis. Then just in case, call ChartRedraw.