Closing opposite trades at a time with some profit

 

Hi guys,

I was hoping someone could help me out. I am till learning  mql codes and trying to make EA for mt4

I'm taking 10 number of trades in one direction with same lot size let's say Buy with 0.01 Lot and all are in loss .Now I open one trade in opposite direction ie Sell with 0.1 Lot (Sum of 10 buy lots).

I am trying to make function for closing latest opposite trade ie Buy of 0.1 Lot when profit of 10 pips along with very  first sell trade of 0.01 with loss but I will get average profit of 10 pips. I am not able to make code for closing first and last trade at a time with 10 pips profit. I hope some will help me for coding please.

 
Jagdish Vasave -: I was hoping someone could help me out. I am till learning  mql codes and trying to make EA for mt. I'm taking 10 number of trades in one direction with same lot size let's say Buy with 0.01 Lot and all are in loss .Now I open one trade in opposite direction ie Sell with 0.1 Lot (Sum of 10 buy lots).I am trying to make function for closing latest opposite trade ie Buy of 0.1 Lot when profit of 10 pips along with very  first sell trade of 0.01 with loss but I will get average profit of 10 pips. I am not able to make code for closing first and last trade at a time with 10 pips profit. I hope some will help me for coding please.
  1. If it is about MT4 or MQL4 you should in the future post in correct section of the forum — MQL4 and MetaTrader 4. The moderators will move this thread for you in due time.
  2. It sounds like you trying to create some kind of "Hedging" recovery of trades or "Grid" like functionality. That is a waste of trading costs. You can achive better results by just using the net equivalent of a single position (see the math below).
  3. In order to understand your issue and to offer more guidance, you should show your coding attempt. Without it we cannot offer much help. 

Forum on trading, automated trading systems and testing trading strategies

Any great idea about HEDGING positions welcome here

Fernando Carreiro, 2018.09.17 21:17

For those of you that want to learn to see the "light" and not fall into the trap of "hedging" and Grid strategies, here is the basic math:

How to Calculate the Net Resulting Equivalent Order:


Learn to do your research properly! Do not be blinded by false promises. Do the math!



Reason: