Out-of-nowhere trades

 

Hello MT5 community,

I'm building up an expert advisor from scratch and I'm trying to experience the basics first.

I have code creating only "BUY" orders at beginning of each period (current at every 4 hours) as follows:


Although I only create BUY orders, I see SELL operations as well, as depicted in the next figure (see the red arrows):


And when I investigate the "Results" tab of "Strategy Tester" after the execution, the total number of long trades are as much as the number of red arrows in the chart. So, I feel that I misinterpret the chart. What am I missing here?

Thanks in advance...

 
Suat Gonul:

Hello MT5 community,

I'm building up an expert advisor from scratch and I'm trying to experience the basics first.

I have code creating only "BUY" orders every 4 hours as follows:


Although I only create BUY orders, I see SELL operations as well, as depicted in the next figure (see the red arrows):


And when I investigate the "Results" tab of "Strategy Tester" after the execution, the total number of long trades are as much as the number of red arrows in the chart. So, I feel that I misinterpret the chart. What am I missing here?

Thanks in advance...

In your idea what happens when a SL or TP is reached ?
 
Alain Verleyen:
In your idea what happens when a SL or TP is reached ?

Actually, I didn't take an explicit action considering this case. I thought (I might be wrong) the order would be closed automatically when SL or TP is reached. Currently, I just create orders. Complete code is attached.

Files: