Download MetaTrader 5

Each order has its own exit strategy, how to implement that?

To add comments, please log in or register
katexing
29
katexing  
Hi,

I'm using classes to reduce clutter. I am trying to make each order (each ticket) be able to store their own exit strategy prices after running exit checks. 

i have a Class called CTicket and each instance of CTicket has their own corresponding instance of class CExitStrategy where it stores the settings, exit prices etc. How do i implement it? is it CTicket : public CExitStrategy or  CExitStrategy : public CTicket? or do i pass the instance of CTicket into CExitStrategy's methods or vice versa?

Inside the CExitStrategy class I would have methods like RefreshExitPrices(), CanExit() etc. And these are pertaining to each ticket. How do i implement it? 

Thanks for all the help.

sokramm
55
sokramm  

An object of Class CTicket will create an object of class CExitStrategy. That is all you need, no other relation between the classes required. CTicket will modify his CExitStrategy object as required calling the methods needed to perform the operations. CExitStrategy will have class variables that will "belong" to the respective CTicket that created the Exit object and will store the required Exit Strategy information for that CTicket object. CTicket just calls CExit methods to get CExit into the state or value needed at each moment.

Hope that helps, otherwise please show your code and we can further comment on it.

Regards

katexing
29
katexing  
sokramm:

An object of Class CTicket will create an object of class CExitStrategy. That is all you need, no other relation between the classes required. CTicket will modify his CExitStrategy object as required calling the methods needed to perform the operations. CExitStrategy will have class variables that will "belong" to the respective CTicket that created the Exit object and will store the required Exit Strategy information for that CTicket object. CTicket just calls CExit methods to get CExit into the state or value needed at each moment.

Hope that helps, otherwise please show your code and we can further comment on it.

Regards

Thanks for the help.

Ya, that seemed like the most viable method. Thanks!!

katexing
29
katexing  

Another question:

So I have

Class CTicket 

{

private: 

  CExitStrategy e_exitStrats;

..... (some more variables) 


and later i created an array of CTickets.

if after initializing an array of 5 CTickets, can I just resize my array to 4? Do i need to do some procedure to release the memory for the released instance of CTicket or e_exitStrats?

Thanks.

To add comments, please log in or register