MA crossover. i need help with my ea

 

hi, i'm having a problem with my ea. the point of the strategy is that when the ema of 9, the ema of 8 and the ema of 13 periods cross the sma of 20 there will be an operation (only one at a time) but when compiling it does not give me errors but in strategy tester does not open operations does nothing. If someone can help me detect what is missing or what is the error, it would be very helpful

The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
The idea of ​​automated trading is appealing by the fact that the trading robot can work non-stop for 24 hours a day, seven days a week. The robot does not get tired, doubtful or scared, it's is totally free from any psychological problems. It is sufficient enough to clearly formalize the trading rules and implement them in the algorithms, and...
 
Please edit your post and
use the code button (Alt+S) when pasting code

I know that it is not obvious, but topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I will move your topic to the MQL4 and Metatrader 4 section.
 
  1.    if(Volume[0] > 1) return(0);

    For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart,) volume is unreliable (miss ticks,) Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
              New candle - MQL4 programming forum #3 2014.04.04

    I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
              Running EA once at the start of each bar - MQL4 programming forum 2011.05.06

  2.  if(((EMARed1 && EMAYellow1 && EMAOliveDrab1) < (SMAYellow1)
    
    That will never do what you want. True = non-zero and false = zero so you get:
    if( 3 < 2 < 1 )
    if( false < 1 )
    if(     0 < 1 )
    if(     true  )
    if( 3 > 2 > 1 )
    iftrue > 1 )
    if(     1 > 1 )
    if(     false )
    
 
William Roeder:
  1. For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart,) volume is unreliable (miss ticks,) Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
              New candle - MQL4 programming forum #3 2014.04.04

    I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
              Running EA once at the start of each bar - MQL4 programming forum 2011.05.06

  2. That will never do what you want. True = non-zero and false = zero so you get:

So what could I do to make it do exactly what I want: that when the emas (it does not matter the order which first crosses) crosses the sma, an operation opens. excuse me i'm new to mql4

 
chanito18gonzalez: So what could I do to make it do exactly what I want: that when the emas (it does not matter the order which first crosses) crosses the sma,

So code that. (There are at least two different ways.)

Reason: