Simple sma ea - not placing orders!

 

Hello everyone,

Going through the first steps of MQL4 programing and starting from something simple (code attached).

Compiling shows 0 errors and no warnings. When I run it on the backtester (during 1 full month) it only places a single BUY order which it closes immediately after opening.

I've tried many changes for the last week but not resolving.

Could anyone have a look and show me the solution?

Thanks in advance for your hints.

Cheers!

Files:
 
Mario Vasconcelos:

Hello everyone,

Going through the first steps of MQL4 programing and starting from something simple (code attached).

Compiling shows 0 errors and no warnings. When I run it on the backtester (during 1 full month) it only places a single BUY order which it closes immediately after opening.

I've tried many changes for the last week but not resolving.

Could anyone have a look and show me the solution?

Thanks in advance for your hints.

Cheers!

You have an issue with the ticket number... also check at what prices you buy/sell ...also when closing orders and use OrderSelect() use OrderClosePrice() instead of Ask/Bid

 
Daniel Cioca #:

You have an issue with the ticket number... also check at what prices you buy/sell ...also when closing orders and use OrderSelect() use OrderClosePrice() instead of Ask/Buy.. 

Hi Daniel thanks for the hints.

I'm going to have a look at them!

Cheers