Download MetaTrader 5
To add comments, please log in or register
Do you want to write a technical indicator? Find solution in MQL5 Reference!
mtandkids
40
mtandkids 2014.07.25 04:51 

Hello Everybody.  I am messing around with my first EA but I do not have the knowledge to do what I am trying to do.

 I am trying to add a section to my EA that will do the following action:

 Look at all open trades (All trades are long, no short positions in the EA)

If the trades are showing a negative profit

~Add all entry positions and divide by the number of open trades

 

For example if I have open positions at

1.3500 and 1.3300

and the curent market is at 1.3200

This section of the EA would do the following:

1.3500 + 1.3300 = 2.6800

2.6800 / 2 (open positions) = 1.3400

So it makes 1.3400 the new take profit of both (or all) open positions.

 

Is this even possible?

Thank you for all your help. 

Rodrigo Malacarne
Moderator
9593
Rodrigo Malacarne 2014.07.25 05:23  
mtandkids:

Hello Everybody.  I am messing around with my first EA but I do not have the knowledge to do what I am trying to do.

Is this even possible?

Thank you for all your help. 

It's not clear if your question is related to MT4 or MT5... However, in case it's related to MT5, please take a look at function PositionGetDouble, specifically the option POSITION_PRICE_OPEN.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Position Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Position Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Position Properties - Reference on algorithmic/automated trading language for MetaTrader 5
/
To add comments, please log in or register