Request for help with Magicnumbers'

 

Hi All,

Firstly, I would like to thank all the people who have helped others such as me.... Complete newbies!

I have spent the last month or so using the forum to teach myself this MQL malarky but have now encountered an issue which is confusing me no end; MagicNumbers.

I'm not looking for the code to be written for me (but wouldn't object if it's its' simple enough for me to understand) but rather some help or direction to finding sample code or instruction which might show me how to do what I am looking for.

Basically, for this experimental EA I have written some code that:

  1. sets up a number of trades and will sell when profit equals 10 units.
  2. only 50 positions can be opened at any one time.

What I am looking to do (eventually) is to have the first 25 trades open when set criteria are met. If that cycle failed to reach a profit I would like to run an identical cycle when the criteria are met a second time. I figure that the first 25 would have one MN, and the second 25 trades have a different number.

What I am having trouble with is getting the EA to calculate the profit and sell the positions based on MN's. If some helpful chap could point me in the right direction to finding what I am looking for I would be grateful. I have attached my EA (with most of the excess data removed) if it will help with my request.

Regards

Phil.

 
You assign the same magic number to all orders. If you want to differentiate your positions by magic number you need to assign different magic numbers to different orders and keep track of them to see which ones you want close.
Reason: