Partial TPs using base classes

 

I'm using standard library's base classes for creating an EA. After opening a new position, I'd like to post some pending orders for partial TPs, as well as a stop order. The doubt is what is the more elegant way of doing this using the standard library's base classes?

At this moment I just coded a new CExpertSignal. By reading the docs, I believe the most appropriate place for implementing this requirement is in the OnTrade() event handler of a custom CExpert implementation. Is this understanding correct or there are better approaches?

 

I think you need to create an heir from the CExpert class and rewrite the bool method CExpert :: Processing (void)

 
Vladimir Karputov:

I think you need to create an heir from the CExpert class and rewrite the bool method CExpert :: Processing (void)


So, the idea is to override the CExpert::Processing() method, by using basically the same algorithm but with a small change. In the end of the algorithm (https://www.mql5.com/en/docs/standardlibrary/expertclasses/expertbaseclasses/cexpert/cexpertprocessing), if CheckOpen() returns true then I'd place the pending TP orders and the stop one.

Thanks Vladimir, that should also work fine as long as the position opening is always made by means of instant execution orders.

Documentation on MQL5: Standard Library / Strategy Modules / Base classes for Expert Advisors / CExpert / Processing
Documentation on MQL5: Standard Library / Strategy Modules / Base classes for Expert Advisors / CExpert / Processing
  • www.mql5.com
Standard Library / Strategy Modules / Base classes for Expert Advisors / CExpert / Processing - Reference on algorithmic/automated trading language for MetaTrader 5