Get the support and resistance levels of a Moving Average in MQL4

 

Hello forum, good day.

How can the lowest/highest point in each of the previous wave of a Moving average be detected counting from the current bar in MQL4? In other words, it would be like getting the support and resistance levels of a Moving Average instead of getting them from the price levels of the bars/candles.

Your help will be much appreciated.

 

Best regards and thank you in advance,

codeMolecules 

 
something like use MA on M1 timeFrame and gets high and low
 
codeMolecules:

Hello forum, good day.

How can the lowest/highest point in each of the previous wave of a Moving average be detected counting from the current bar in MQL4? In other words, it would be like getting the support and resistance levels of a Moving Average instead of getting them from the price levels of the bars/candles.

Your help will be much appreciated.

 

Best regards and thank you in advance,

codeMolecules 

These points can be detected.
 
codeMolecules:

Hello forum, good day.

How can the lowest/highest point in each of the previous wave of a Moving average be detected counting from the current bar in MQL4? In other words, it would be like getting the support and resistance levels of a Moving Average instead of getting them from the price levels of the bars/candles.

Your help will be much appreciated.

 

Best regards and thank you in advance,

codeMolecules 

You have to walk the value of MA in the previous n candles and stored in two variables, comparing, highest value and lowest
 
josemiguel1812:
You have to walk the value of MA in the previous n candles and stored in two variables, comparing, highest value and lowest

Hello josemiguel1812, good day.

I think that the following code only gets one support and one resistance:

 

int    bars_count = 100;
double MA_Lowest  = 0,
       MA_Highest = 0;

for ( int i = 0; i < bars_count; i++ )
  {
    double MA = iMA( NULL, 0, MA_Period, 0, MA_Method, MA_Price, i );

    if ( MA_Lowest == 0 || MA < MA_Lowest ) MA_Lowest = MA;
    if ( MA_Highest == 0 || MA > MA_Highest ) MA_Highest = MA;
  }


What I need is to get the lowest and highest value of each wave (3 waves for example); would it be better to store the values inside an Array and then retrieve the highest and lowest values? Your help will be much appreciated.

 

Best regards,

codeMolecules 

Reason: