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:
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(); }
A Code block to detect A "New Candle/Bar" using bars history (very effective way)
If you only want to execute your code blocks "only once per bar" it's important to check if there is new bar arrived or not.
Candle Analysis Report
This script helps traders understand the distribution and range of candles in a specific period, which can be useful for making trading decisions such as determining which historical values to use for Take Profit or Stop Loss.
Code blocks for "Counters" like Count "X" time and pass
Here are some examples of codes for set counters based on "Count"
Simple Yet Effective Breakout Strategy
A simple yet effective donchian channel breakout strategy. This strategy is timeless!