Need Help

 

Hi Guys,

 

iam new here and hopefully in the correct forum for my question.

I have programmed an MQL4 script for MetaTrader 4 but somehow it is not working correct. It does not open a Buy or Sell order when the signal is coming.

It would be very helpful if someone with more experience could help me. Iam searching for more than a week but do not find any bug in the code.

 

Thank you and BR

tMAE 

Files:
 

Probably a bracket problem.

     if((ma4old>=ma18 && ma4<ma18)||(ma4old>=ma9 && ma4<ma9)) && ma4<ma18 && ma9<ma18)
     {
 

Thank you for your reply Ernst.

I do not fully understand your post. 

My code is:

//--- sell conditions

     if((ma4old>ma18 && ma4<=ma18)||(ma4old>ma9 && ma4<=ma9 && ma4<ma18 && ma9<ma18))

     { 

 

So i want to open a Short order when ma4 is crossing ma18 from top to bottom OR when ma4 is crossing ma9 from top to bottom when ma4 and ma9 are both under ma18.

Thank you for your help. 

 
tMAE:

Thank you for your reply Ernst.

I do not fully understand your post. 

My code is:

//--- sell conditions

     if((ma4old>ma18 && ma4<=ma18)||(ma4old>ma9 && ma4<=ma9 && ma4<ma18 && ma9<ma18))

     { 

 

So i want to open a Short order when ma4 is crossing ma18 from top to bottom OR when ma4 is crossing ma9 from top to bottom when ma4 and ma9 are both under ma18.

Thank you for your help. 

The first four conditions should be separated from the last two.

((ma4old>ma18 && ma4<=ma18)||(ma4old>ma9 && ma4<=ma9)) && 
 

Thank you for your reply.

Sorry but I dont get it. Why should they be separated from the last two?

 (ma4old>ma9 && ma4<=ma9) this should only trigger a sell order when also ma4 and ma9 is under ma18.

 
tMAE:

Thank you for your reply.

Sorry but I dont get it. Why should they be separated from the last two?

 (ma4old>ma9 && ma4<=ma9) this should only trigger a sell order when also ma4 and ma9 is under ma18.

Ok I see. The limits may be too small.

      res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,30,Ask+150*Point,0,"",MAGICMA,0,Red);
 

Hello Ernst.

Thank you again for your reply. I also posted my problem in the german forum here and it seems like that they found the bug.

It seems like that MQL has a problem with my if-expression.

 

Now I changed them to:

if(ma4old>ma18 && ma4<=ma18)

     {

      res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,Ask+30*Point,0,"",MAGICMA,0,Red);

      return;

     }

     

     if(ma4old>ma9 && ma4<=ma9 && ma4<ma18 && ma9<ma18)

     {

      res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,Ask+30*Point,0,"",MAGICMA,0,Red);

      return;

     } 

 

and it seems to work.

 

Thank you for your time and help.

 

tMAE 

Reason: