1

I hope someone guides me,

I want to calculate the lowest moving average level during a certain number of candles, as well as the highest moving average level during a certain number of candles.

That is, I want the moving average top and the moving average bottom, not the price.

How do I write a function that returns these values ​​to me?

Thank you for your interest and help

hre007
  • 11
  • 1

1 Answers1

1

You should try to attempt to write the code yourself, you will learn a lot more and get more help along the way when you hit any problems.

int startCandle=1;
int endCandle=100;
double highest=NULL, lowest=NULL;
for(int i=startCandle; i<=endCandle; i++)
{
   double ma=iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, i);
   if(highest==NULL){highest=ma; lowest=highest;}
   if(ma>highest) highest=ma;
   if(ma<lowest) lowest=ma;
}
PaulB
  • 1,262
  • 1
  • 6
  • 17