Print the value of AvgLevel to make sure that it is being calculated properly. Possibly it equals zero.
int HighLevelIndex = iHighest(NULL,0,MODE_HIGH,LevelsPeriodicity,1); int LowLevelIndex = iLowest (NULL,0,MODE_LOW,LevelsPeriodicity,1); double HighLevel = High[HighLevelIndex]; double LowLevel = Low[LowLevelIndex]; double AvgLevel = (HighLevel - LowLevel)/2;This is how I calculate it. Is it wrong?
I used it then, it shows everything is ok, but the EA doesn`t trade in the shown case
Stan4o1:
This is how I calculate it. Is it wrong?
This is how I calculate it. Is it wrong?
If you had printed the result as I advised, you would have found your problem
double AvgLevel = (HighLevel - LowLevel)/2;
should be
double AvgLevel = (HighLevel + LowLevel)/2;
.
Thanks for the help, but how to print the result
Print(DoubleToStr(AvgLevel,Digits));I find it hard to believe that you can write the code that you have posted, but are unable to code a simple print statement.
Oohh right my bad i forgot about this
Stan4o1: but how to print the result
| RTFM Print - MQL4 Documentation
or PrintFormat - MQL4 Documentation |

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
Open[1]<AvgLevel