Download MetaTrader 5

How to pass an instance of a Class to another Class

To add comments, please log in or register
katexing
37
katexing  

Hi,

I am trying to modularize my EA with Classes because it's getting bloated with many lines of codes. I want to put all my exit strategies into a Class (Class ExitStrategies), which will calculate and store the exit prices every time a new bar is formed and detect if the prices are hit. Then i will make 2 instances: 1 for Short orders and 1 for Long orders.

Then I realised I have so many settings that i need to pass into the Class. And since i am making 2 instances, i have to pass the exact same settings to 2 instances. Can I create a new Class just to store the settings (ExitStrategySettings)? But how do i pass that initialized object to the 2 instances so that they can retrieve?

Thanks for any help. 

Alain Verleyen
Moderator
35039
Alain Verleyen  
With a pointer.
katexing
37
katexing  
Alain Verleyen:
With a pointer.
Found the solution. Thanks!
To add comments, please log in or register