Why not use iHighest and iLowest? https://docs.mql4.com/series/iHighest
Yes of course! Use the right tool for the right job.
double apexBars(int Nbars, string highLow) { double barApex; if(highLow == "Low") barApex = Low[iLowest(NULL,0,MODE_LOW,Nbars,0)]; if(highLow == "High") barApex = High[iHighest(NULL,0,MODE_HIGH,Nbars,0)]; Print("Index:",Nbars," highLow:",highLow," barApex:",barApex); return(barApex); }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
This function will find the High or Low of some number of bars. I was pulling my hair out debugging this thing. The High part of the function worked great but the Low part of function always return 0. Then I realized that The variable barApex was not initially defined and so was set to 0. It was hard to find a Low price lower than 0!
-- enjoy.