# Calculating price moves as a percentage

12

Hi all,

I'm wondering if anyone can help. I'm looking for a way to code in MQL4 that allows me to calculate the movement in price, as a percentage, from a recent high or low to the current price.

I am aware if the iHigh and iHighest functions in MQL4, but the problem with these is time frames. For example, the FTSE 100 made a high of 7000 two days ago. It is now trading at 6930, so has fallen by 1% from it's recent high. But looking at another example, what if the high of 7000 was made two weeks ago, and what if within that two week period, the FTSE 100 fell from 7000 to 6700, rose to 6965, and then fell to 6930. The most recent high would be 6965, but looking at a two week period, iHighest would return 7000 as the highest high.

Is there a way in MQL4 I can code to give me the most recent true high, regardless of how long ago this was made, and then to show me how much the current price has moved from that most recent high?

I hope I've made the problem clear, I would really appreciate anyone's input on this.

17047

Ponsbury: Is there a way in MQL4 I can code to give me the most recent true high, regardless of how long ago this was made,
1. Contradictory statement. Either you want the all time high ("true high, regardless of how long ago",) or you want "the most recent high" in the last N bars.
2. Of course there's a way, figure out which you want and code it. Percentage is just 100 * HH / current. Perhaps you want to modify 'Momentum' indicator by 'MetaQuotes' for MetaTrader 4 in the MQL5 Code Base
Moderator
35038

whroeder1:
1. Contradictory statement. Either you want the all time high ("true high, regardless of how long ago",) or you want "the most recent high" in the last N bars.
2. Of course there's a way, figure out which you want and code it. Percentage is just 100 * HH / current. Perhaps you want to modify 'Momentum' indicator by 'MetaQuotes' for MetaTrader 4 in the MQL5 Code Base
You probably mean 100 * Current / HH
Moderator
101552

Hi Ponsbury,

If you are the coder so you can look at the idea from the following indicator: Percentage - indicator for MetaTrader 4

Moderator
101552

Next indicator -

----------------

Price Increment source code - indicator for MetaTrader 4

The indicator calculates the price change on each bar and displays a histogram in the additional indicator window. Outputs 3 types of data: absolute price change, percentage and logarithmic.

12

Thank you - appreciate the feedback.