Download MetaTrader 5

Need Help

To add comments, please log in or register
Do you keep a blog? Place a link to MQL5.community there and make money!
tMAE
48
tMAE 2016.08.29 11:00 

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 

Ernst Van Der Merwe
4731
Ernst Van Der Merwe 2016.08.29 11:13  

Probably a bracket problem.

     if((ma4old>=ma18 && ma4<ma18)||(ma4old>=ma9 && ma4<ma9)) && ma4<ma18 && ma9<ma18)
     {
tMAE
48
tMAE 2016.08.29 11:17  

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. 

Ernst Van Der Merwe
4731
Ernst Van Der Merwe 2016.08.29 11:31  
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)) && 
tMAE
48
tMAE 2016.08.29 11:35  

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.

Ernst Van Der Merwe
4731
Ernst Van Der Merwe 2016.08.29 11:54  
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);
tMAE
48
tMAE 2016.08.29 12:00  

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 

To add comments, please log in or register