Download MetaTrader 5
To add comments, please log in or register
How to launch your trading signal and become a provider
Stan4o1
118
Stan4o1 2015.12.15 23:32 
Hi Guys I`m here with a problem again. In my EA I calculate an average level, i named AvgLevel  and i am using it for signals.
if( Ask > AvgLevel &&  Open[1]<Close[1] && Open[1]<AvgLevel ) 
This is a small part of the signal check, but this code without the last  part shown bellow trades. With it, it does not. Can you help me ?
Open[1]<AvgLevel
Keith Watford
Moderator
9597
Keith Watford 2015.12.15 23:53  
Print the value of AvgLevel to make sure that it is being calculated properly. Possibly it equals zero.
Stan4o1
118
Stan4o1 2015.12.16 08:46  
  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?
Carl Schreiber
6578
Carl Schreiber 2015.12.16 09:15  
Stan4o1:
This is how I calculate it. Is it wrong?
If you use the debugger you can check yourself!
Stan4o1
118
Stan4o1 2015.12.16 12:32  
I used it then, it shows everything is ok, but the EA doesn`t trade in the shown case
Keith Watford
Moderator
9597
Keith Watford 2015.12.16 12:35  
Stan4o1:
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;

 .

Stan4o1
118
Stan4o1 2015.12.16 12:47  

Thanks for the help, but how to print the result

Keith Watford
Moderator
9597
Keith Watford 2015.12.16 13:08  
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.
Stan4o1
118
Stan4o1 2015.12.16 13:10  

Oohh right my bad i forgot about this

whroeder1
14457
whroeder1 2015.12.16 13:13  
Stan4o1: but how to print the result
RTFM Print - MQL4 Documentation or PrintFormat - MQL4 Documentation
/
To add comments, please log in or register