Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1279
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
Poke your nose into a simple code that calculates the angle of price movement. The picture below shows it.
Poke your nose into a simple code that calculates the angle of price movement. The picture below shows it.
Well, you can calculate it with a tangent. And you don't need the angle itself, you just need to know the tangent.
And you don't really need an angle per se, you just need a tangent.
Exactly! And our tangent is called: speed.
In this example, the price has passed through 1884 points in 39 one-hour candles. The total speed of this wave is: 1884/(39/24) = 1159 pips per day.
And we don't need an angle, why do we need an angle? When we start stretching or flattening the graph, what will the angle look like then? Angles can be measured when the x- and y-axes have the same units. For instance, if you take a notebook with squares, draw a line along the diagonals of these squares, you will get 45 degrees. And what's up and what's to the right are centimetres. And here, what is one price point equal to? One hour, one day? Those are not comparable values.Exactly! And our tangent is called: speed.
In this example, the price has passed 1,884 points in 39 one-hour candles. The total speed of this wave is: 1884/(39/24) = 1159 pips per day.
And we don't need an angle, why do we need an angle? When we start stretching or flattening the graph, what will the angle look like then? Angles can be measured when the x- and y-axes have the same units. For instance, if you take a notebook with squares, draw a line along the diagonals of these squares, you will get 45 degrees. And what's up and what's to the right are centimetres. And here, what is one price point equal to? One hour, one day?Those are not comparable values.Why do we need to compare them? Kilometres and time are also not comparable, but that doesn't stop us from counting speed in km/hour.
If your tangent is speed, it will be that speed per unit time of the chart period. If price has moved 1884 pips in 39 hours, it will be 48 pips per hour. There is no need to convert it to days.
But you can also calculate "acceleration" as a ratio of current speed to the speed on the previous bar. And by collecting several of these values, the average acceleration can be determined.
And here, what does one price point equal? One hour, one day? The values are not comparable.
Well, distance is also measured in light years. So it's not a problem.
Let's introduce a constant speed. For example, 1 _Point for one 1 minute bar and bring the coordinate system to a price on both axes .
Then the angles will be the same on any timeframe.
The main thing is to correctly calculate the number of minute bars betweenx1and x2.
It is better to use minute bars rather than time as there are time holes in the form of weekends, low volatility, etc.
I agree 100%, because the candlestick can be stretched both horizontally and vertically. And there should be some standard for determining the angle (candlestick width in pixels and the number of points in a pixel).
Can I ask an off-topic question?
How do I correctly convert datatime to double so that the compiler won't swear (data loss due to incorrect conversion is possible)?
double A = Time[1];
Thanks in advance!
If you have 1884 pips in 39 hours, the speed is 48 pips per hour. And there is no need to convert that to days at all.
Yes, that's my assumption. Since I made the speed int (i.e. whole pips), I thought I would use a larger period, so that fractions of a pip in speed wouldn't matter too much and could be discarded. So I got points per day. Well, this agrees with the human biological clock. Tired, slept, got up in the morning: "What was the speed yesterday? It looks consistent, so that's the standard I set for myself. And then, of course, it's a matter of personal convenience.
Well, distance is also measured in light years. So that's not a problem.
Let's introduce a constant velocity. For example, 1 _Point for one 1 minute bar and bring the coordinate system to a price on both axes .
Yes, again the speed is obtained, only in units: points per minute. As for the weekends and holes, I took the following way: what candles are on the chart is the time interval, and what is absent (days/hours) is not there. Because if we take into account weekends, and the price stands still at that time, the speed will noticeably drop without any reason. But then again, this is to each his own:)
How to properly convert datatime to double, so that the compiler didn't swear (data loss due to incorrect conversion is possible).
Why would you store datatime in double? If you store different types of variables in the same array, and bring them here and there, consider replacing the usual array with a structure array:
Thank you very much !
Do the structures only work in mql 5 or already in mql 4 ?
Thank you very much !
Do structures work only in mql 5 or already in mql 4 ?
Not only structures work, but union too.