Problem with getting my indicator to work, can anyone help?

 

Hi,

I am trying to write an indicator and have run into a problem with getting it to compile. I would really appreciate any help anyone can give. The indicator checks that :-


MA's on 2 timeframes are aligned

the last 3 closed candles are all higher or lower than the previous candle

At least 1 candle of the 3 is larger than the ATR(14)

At least 1 candle wick touches the 6EMA

None of the 3 candle wicks are touching the 18EMA

None of the 3 candles closes below the 6EMA (Short) or above the 6EMA(Long)

Here is the sql file

Files:
MAAligned.mq4  8 kb
 
  1. Why did you post your MT4 question in the Root / MT5 Indicators section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. if(!iMA(0,15,6,0,MODE_EMA,PRICE_CLOSE,x)>iMA(0,15,18,0,MODE_EMA,PRICE_CLOSE,x)
    That doesn't do what you think it does. 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 )
    

  3. I'll help you with one.
          //Are the MA's aligned
          {
          if(!iMA(0,15,6,0,MODE_EMA,PRICE_CLOSE,x)>iMA(0,15,18,0,MODE_EMA,PRICE_CLOSE,x) 
          && !iMA(0,15,18,0,MODE_EMA,PRICE_CLOSE,x)>iMA(0,15,50,0,MODE_EMA,PRICE_CLOSE,x) 
          && !iMA(0,15,50,0,MODE_EMA,PRICE_CLOSE,x)>iMA(0,15,200,0,MODE_SMA,PRICE_CLOSE,x)
          && !iMA(0,60,6,0,MODE_EMA,PRICE_CLOSE,x)>iMA(0,60,18,0,MODE_EMA,PRICE_CLOSE,x)
          && !iMA(0,60,18,0,MODE_EMA,PRICE_CLOSE,x)>iMA(0,60,50,0,MODE_EMA,PRICE_CLOSE,x)
          && !iMA(0,60,50,0,MODE_EMA,PRICE_CLOSE,x)>iMA(0,60,200,0,MODE_SMA,PRICE_CLOSE,x))
                                                                                            
          }
    
    An if statement has the form if( … ) statement;
  4. The rest are even more trivial. Learn to code. Read the manual.
Reason: