Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1885

 
Maxim Kuznetsov #:

both on the... my reply has been deleted.

Something is confusing - your post from this thread is not in the deleted ones.

 
Vladimir Karputov #:

Something's confusing - your post from this thread isn't in the deleted ones.

I looked too. Didn't find it.

 

OK, I'll duplicate that... in response tohttps://www.mql5.com/ru/forum/160683/page1884#comment_27290699

CalcAngleTrend has nothing to do with it. Somewhere else the coefAngle is incorrectly counted or there are further crooked calculations

ps/ and perhaps the concept of "slope" is generally misinterpreted. It is not expressible in degrees or radians (without a curvature type of space) and the atan function returns a physically incorrect value.

 
Mihail Matkovskij #:

It's all about the formula for calculating the angle. The code shows that only one coordinate is used to calculate it and some coefficient, the purpose of which is unclear. What is that? Please elaborate on what data you are using to calculate the angle.

That's right it's a vector
and one value is used because delta change divided by 1 (One) will be delta.
the variable coefAngle is an int constant equal to 2.
I checked all data input to the function is exactly the same.
 
Maxim Kuznetsov #:

OK, I'll duplicate that... in response tohttps://www.mql5.com/ru/forum/160683/page1884#comment_27290699

CalcAngleTrend has nothing to do with it. Somewhere else the coefAngle is incorrectly counted or there are further crooked calculations

ps/ and perhaps the concept of "slope" is generally misinterpreted. It is not expressed in degrees or radians (without a curvature-of-space type of overshoot) and the atan function returns a physically incorrect value.

the coefficient is a constant, it does not change
there are no calculations except for this function, the function obtained the delta value by averaging the vectors values over several points, roughly speaking reduction to a segment of 2x points, with a period of 1 unit

It is clear that this is not a full realization of vectors, it is more for "more or less" adequate expressive result.
technically, one can do with a simple application of a multiplying coefficient and that's it...

Anyway, I don't see the reason for this function to work at all(

The only possibility is that there is something wrong with the type conversion in the expression itself in the process of calculation,

 
Владимир Казаков write an Expert Advisor, and when I test it a strange thing happens...

I have a function

What's the situation, I start one instance of the EA running on a chart, and run the second one in the debug mode on the same chart with MT4
The input data for the function is the same, but the output data is different!!!? I just don't understand something, it seems...(

advise which way to dig for information!!!

PS: calculated the difference of exactly 2.5 times the output

Decomposed the expressions into actions... ...and, oh, my goodness, the results are all the same!?

double CalcAngleTrend(double d)
 {
Print("d: ", d, " coefAngle: ", (double) coefAngle);
  double
    a = (double) (d*pow(10,_Digits-2));
Print("(d*pow(10,_Digits-2)): ", a);
    double rad = (double) (180/M_PI);
Print("rad: ", rad);
    a = (double) (atan(a));
Print("(atan(a)): ", a);
    a = (double) (a*rad*(double) coefAngle);
Print("(a*rad*(double) coefAngle): ", a);
  return(NormalizeDouble(a, ANGLE_DIGITS));
 }

Hence, I guess the casting of types is not working as I would like it

anyone who knows and understands can clarify what the problem was?!
) in order to avoid repeating mistakes))

PS: here's the same expression in this format works the same way

  double a = (double) ((d*pow(10,_Digits-2))*(180/M_PI)*(double) coefAngle);

Exclusion method was a foolproof double for the int.

I hope I got it right.

 
Владимир Казаков #:

Decomposed the expressions into actions... and, oh my god, the results are the same!!!?

So all the same with the reduction of types something does not work as I would like

of experts and understanders can someone explain what was the problem?!
Well, not to repeat errors)))

PS: here's the same expression in this format works the same way

Exclusion method was a foolproof double for the int.

I hope I got it right.

double a = (double) ((d*pow(10,_Digits-2))*(180/M_PI)*(double) coefAngle);
double a = (double) ((d*pow(10,_Digits-2))*(180.0/M_PI)*(double) coefAngle);
 

Greetings, could you advise me on a robot, mt5.

I need the indices in the array to coincide with the value of the shift relative to the current bar, like in indicator buffers.

How to do this?

 
Andrey Sokolov #:

Greetings, could you advise me on a robot, mt5.

I need the indices in the array to coincide with the value of the shift relative to the current bar, like in indicator buffers.

How to do it?

ArraySetAsSeries

 
Vitaly Muzichenko #:

ArraySetAsSeries

Thank you. Does this not only work in indicators but also in robots?

Reason: