The library contains basic public methods to manage grids:
public:                     GridManager(ENUM_GRID_DIRECTION direction, double grid_initial_lot_size, int grid_gap_points, double grid_profit_percent);                     ~GridManager() {};   void              SetGridMagicNumber(ulong magic);   void              SetGridMaxDD(double max_dd_percent);   void              SetGridMultiplier(double lot_multiplier);   void              Start(void);   void              Update(void);   void              CloseGrid();   double            GridPnL();   int              CountPositions();
In above code:
- MaxDD stands for “maximum allowed drawdown”. This value is disabled by default but using the Set method will activate it. This is a value in %balance.
- Start method starts a new grid if it is not already running.
- Update checks for new entries and possible exits.
This is a sample code of EA operating based on GridManager Object:
#include <GridManager.mqh> GridManager *buy_grid; int OnInit() Â Â { Â Â buy_grid = new GridManager(GRID_BUY, 0.01, 100, 1); Â Â buy_grid.SetGridMagicNumber(100); Â Â buy_grid.SetGridMultiplier(1.5); Â Â buy_grid.SetGridMaxDD(5); Â Â return(INIT_SUCCEEDED); Â Â } void OnDeinit(const int reason) Â Â { Â Â delete buy_grid; Â Â } void OnTick(void) Â Â { Â Â bool buy_condition=true; Â Â if(buy_condition) Â Â Â Â Â Â buy_grid.Start(); Â Â buy_grid.Update(); Â Â }