Scaling out of a position

 

This can not possibly be a new problem but I have not found a good solution searching.

I am "porting" an MT4 EA that takes 4 positions, theLimit for a  last one running a trailing stop. This is straightforward in MQL4

So I start with opening a position "Buy" with 0.8 lots, stoploss entered, no takeprofit in order to scale out with four  0.2 positions. 

So I turn to a suggested soluition of using "Sell Limit" to scale out. First problem in usiing the "CTrade" Class it seem to be that "price"

should be specified as a distance, not a level. Well it can be handled. Next problem is that the trade might not reach the specified level but instead go to StopLoss.

So I have to monitor the trades and in case of it going to SL I have to cancel the pending orders. 

Or have I missed something?  It seems I have to keep a lot of information in global variables in order to have control in case there is an interruption

Quite an increase in complexity compared to MT4. Especially since it is an"MultiCurrency" EA.

I might as well keep monitoring all trades constantly and just do partial closes. Maybe

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants - Documentation on MQL5
 
ingvar_e:

This can not possibly be a new problem but I have not found a good solution searching.

I am "porting" an MT4 EA that takes 4 positions, theLimit for a  last one running a trailing stop. This is straightforward in MQL4

So I start with opening a position "Buy" with 0.8 lots, stoploss entered, no takeprofit in order to scale out with four  0.2 positions. 

So I turn to a suggested soluition of using "Sell Limit" to scale out. First problem in usiing the "CTrade" Class it seem to be that "price"

should be specified as a distance, not a level. Well it can be handled. Next problem is that the trade might not reach the specified level but instead go to StopLoss.

So I have to monitor the trades and in case of it going to SL I have to cancel the pending orders. 

Or have I missed something?  It seems I have to keep a lot of information in global variables in order to have control in case there is an interruption

Quite an increase in complexity compared to MT4. Especially since it is an"MultiCurrency" EA.

I might as well keep monitoring all trades constantly and just do partial closes. Maybe

You don't miss anything. Either use "sell limit" and cancel pending order if SL is triggered, or monitor the trades and do partial closes.

 

Thanks  angevoyageur.

Understand german?

"Warum etwas einfach machen wenn man es so schön kompliziert machen kann"

I am not German but this phrase has some beauty to it  :-)

 
ingvar_e:

Thanks  angevoyageur.

Understand german?

"Warum etwas einfach machen wenn man es so schön kompliziert machen kann"

I am not German but this phrase has some beauty to it  :-)

Yes we have such expression in French too