Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 834

 

Good afternoon!

Could you please tell me how I can briefly write an expression that rounds an integer (number of points) to a given precision, e.g. 5.

I understand that if I want to round to 10, I use NormalizeDouble(point_val, 4) / Point = NormalizeDouble(0.00175, 4) = 0.0018 / 0.0001 = 180.

How do I round to the nearest 5 points?

 
alexeymosc:

Good afternoon!

Could you please tell me how I can briefly write an expression that rounds an integer (number of points) to a given precision, e.g. 5.

I understand that if I want to round to 10, I use NormalizeDouble(point_val, 4) / Point = NormalizeDouble(0.00175, 4) = 0.0018 / 0.0001 = 180.

How do I round to the nearest 5 points?

In whole points MathRound(X/5)*5 if needed, then multiply by Point.
 
evillive:
In whole points MathRound(X/5)*5, if necessary, then multiply by Point.
Thank you!
 

How can you find the highs, lows of the previous day on a five-minute chart without using a daily chart?

 
iHigh() - iLow() with appropriate parameters.
 
AlexeyVik:
iHigh() - iLow() with appropriate parameters.
But, this is only possible through daily chart data.
 
woin2110:
But, this is only possible with the daily chart data.

With iHighest(),iLowest(), how many M5 bars in a day is known, the offset to the end of the previous day, I think, can also be calculated.

    Max = high[iHighest(NULL, 0, MODE_HIGH, P, sh)];
    Min = low[iLowest( NULL, 0, MODE_LOW , P, sh)];

Где P - сколько баров считать
    sh - смещение до начала отсчёта (последний бар прошлого дня), считает в сторону возрастания номера бара, т.е. вглубь истории
 
woin2110

Also, as an option in case there may be no bars, sh and P from the post above can be calculated by applying the number of seconds in a day. For example, something like this. From the attached outline version of the code, in general, the principle should be clear.

There is a link to a very good article in that post.
 
It's all about the dumb broker who draws Monday as a Sunday candle on the daily chart, but instead of Monday some xxx artist drew his own candle. Now I think how to use correct data of previous days. I have to make an Expert Advisor for all brokers. And especially to find the fucking minimum and maximum of the last working day.