Referencing the last three trades

 

Hello.

I have most of my code down for my EA but I am uncertain as to how I can reference my last three trades.

I need something to the effect of- 

if(conditions of last three trades are met)

...my code...

else

...rest of code

 

Im particularly interested in the "conditions of last three trades are met" part. How can I reference my previous trades. Thank you sooo much for help or a lead to another thread. Sorry if this thread has already been opened or discussed.

 

Mac 

 
mountainman:

Hello.

I have most of my code down for my EA but I am uncertain as to how I can reference my last three trades.

You need to loop through the Open orders and/or the Order History to find the last three trades belonging to your EA . . . .   distinguishing between Symbol and Magic Number if used . . . if the last three trades you are talking about are all closed trades then you just need to look at the Order history. 
 

A loop that breaks once the last three trades have been analysed i.e. if a certain variable x >3 . After the loop selects a trade save the values you want for later use.

Reason: