AB Universal Grid. Brief description of Input parameters.

AB Universal Grid. Brief description of Input parameters.

4 ноября 2025, 17:14
Aleksandr Blinov
0
85

The AB Universal Grid advisor allows you to implement most grid strategies. It's a great tool for those who actively use elements of grid strategies (such as averaging, martingale, and others) in their trading.

Version for MT5 https://www.mql5.com/en/market/product/145321
Version for MT4 https://www.mql5.com/en/market/product/147482

Input parameters.

========== Expert settings  

Watch mag
ic number

Select which magic numbers the advisor will see (drop-down list):

  • 1) only My – UG sees orders and positions only with its own magic number.
  • 2) All – UG sees all orders and positions
  • 3) My and Add magic number – UG sees orders and positions with its own magic number and an additional magic number from another advisor. Enter it below.
  • 4) My and Manual – UG sees orders and positions with their magic number and manual ones
___ Magic number (My)
Magic number
___ Add magic number
Additional magic number for option (3) (see above). Enter the magic number of another advisor here if you're using signals from another advisor.
Maximum spread for opening market orders, pips (0=off)
The advisor will not open a market trade if the spread is >= than this value.
 Info Panel  On/Off Info panel

 

========== Trading strategy settings

Trading strategy

Built-in strategies for opening first positions (drop-down list):

  • 0) OFF - Disabled. The Expert Advisor will not open new initial positions. It will only open "Grid" positions to complete existing positions. This mode can be used to pick up positions opened manually or by other Expert Advisors.
  • 1) Always on the market –If there are no BUY positions on the market, the EA will open the first position. The same applies to SELL positions.
Opening of the first
Select trading direction for the first position (drop-down list):
  • BUY and SELL
  • only BUY
  • only SELL

    According to the chosen strategy, positions will be opened only in the chosen direction.
Lot Mode
First position volume calculation mode (drop-down list):
  • Fixed – The first position will always be opened with a fixed lot (see parameter "___ First Lot")
  • Part of the free margin – For every full "___ Part of the free margin" will open "___ First Lot"
___ First Lot
First position lot
___ Part of the free margin
The value of free margin for opening  “___ First Lot
Stop Loss, pips (0=off)
Stop loss for the first position. Once set, it is not controlled by the advisor until a second position is opened in the same direction.
Take Profit, pips (0=off)
Take profit for the first position. Once set, it is not controlled by the advisor until a second position is opened in the same direction.


========== Risk Management

Max Lot EA (0=off) 
The maximum lot the advisor will open in one trade
 Close all at Drawdown  

Close all on drawdown (drop-down list):

  • Off – Disabled.
  • in the deposit currency – in the deposit currency. Below, enter the drawdown amount in the deposit currency at which the advisor will close all positions it sees (see parameter “Watch magic number”).
  • in the percentage of the balance – As a percentage of balance. Below, enter the drawdown value in % at which the advisor will close all positions it sees (see parameter “Watch magic number”).
 ___ Drawdown Value  The value for the selected mode.
 ___ Stop Trading after Drawdown  On/Off. Stop trading after closing all positions due to drawdown. To resume trading, restart the Expert Advisor.
 Close all at Profit  Close all on profit (drop-down list):
  • Off – Disabled.
  • in the deposit currency – in the deposit currency. Below, enter the profit amount in the deposit currency at which the advisor will close all positions it sees (see parameter “Watch magic number”).
  • in the percentage of the balance – As a percentage of balance. Below, enter the profit value in % at which the advisor will close all positions it sees (see parameter“Watch magic number”).
 ___ Profit Value  The value for the selected mode.
 ___ Stop Trading after Profit  On/OffStop trading after closing all positions at profit. To restart trading, you must restart the Expert Advisor.


========== Market Position Management

===== Trailing stop (TS) Режим Трейлинг стопа (выпадающий список)
  • Off - Disabled.
  • 1) Simple - Simple Trailing Stop from Breakeven for each direction
  • 2) Compensatory -Only profitable orders and the farthest losing order from their breakeven point are trailed. Allows you to unload your deposit faster. Most effective with aggressive martingale.
___ Distance TS, pips Distance in points from the current price for trailing stop
___ Start TS, pips
You can add a trailing stop start distance. This way, the trailing stop will not start at the breakeven point, but rather when it moves the specified distance. It's calculated using the following formula:
Switching distance TS = Distance TS, pipsStart TS, pips. For the mode"2) Compensatory" works only if there is 1 position in the market.
___ Step TS, pips Set the step for trailing stop.
===== Breakeven (BE) On/Off. Setting the breakeven (BE) taking into account swaps and commissions
___ Distance for transfer to BE, pips Distance in points for installing BE
___ Add pips to BE Add a few points to your breakeven if you want to take a small profit and avoid minor slippage.


 ========== Grid settings

On/Off the settings block "Grid settings"  OffThe functions in this settings block are ignored.
Grid New orders/positions
On/OffDisable grid generation. New grid positions will not be opened. This setting does not affect the opening of the first position for "Trading Strategy."
Grid Ban Max number Orders/Positions (0=off)
Prohibition of opening new grid positions if the specified number of positions in a given direction has been reached.
Grid Ban Max volume Orders/Positions (0=off)
Prohibition of opening new grid positions if the specified volume has been reached in a given direction.
===== Grid STEP mode 

Grid step calculation mode (drop-down list):

  • 1) Fixed – Fixed step
  • 2) First step +/- (Add pips*Number of open orders) – The next order step is calculated using the specified formula.
  • 3) First step * (Ratio step*Number of open orders) – The next order step is calculated using the specified formula.
  • 4) ATR * Ratio step – The next order step is calculated using the specified formula. See the ATR settings section ========== Indicators
___ First STEP, pips
Initial grid step
___ Add pips for (2)
Additional pips for grid mode 2. If you enter a negative value, the next step will decrease, and if you enter a positive value, it will increase.
___ Ritio for (3) and (4)
Coefficient for grid modes 3 and 4. For this type of calculation, if you enter a value < 1, the next step will decrease, and if > 1, it will increase.
___ Min Step, pips (0=off)
Minimum allowed grid step for the advisor.
___ Max Step, pips (0=off)
The maximum allowed grid step for the advisor.
===== Grid LOT Mode
Lot calculation mode (drop-down list):
  • 1) Fixed (First Lot) – Fixed lot. All orders and positions will be opened based on the value specified in the parameter "First Lot"
  • 2) Last lot +/- Add Lot – The next lot will be calculated according to the specified formula: the last open lot in this direction +\- Add Lot for (arithmetic progression)
  • 3) Last Lot * Ratio lot – The next lot will be calculated according to the specified formula: the last open lot in this direction *  Ratio lot (geometric progression). Does not depend on the number of positions.
  • 4) Total volume of positions * Ratio lot – The next lot will be calculated using the formula: Sum of lots of positions in this direction* Ratio lot. I recommend exhibiting the Ratio lot <1.
___ Add Lot for (2)
Additional lot for lot 2 calculation mode. Can be +\-
___ Ratio lot for (3) and (4)
Lot coefficient for lot calculation modes 3 and 4.
===== Order TYPE for opening the grid Select the order type to open the next position from the drop-down list:
  • Market - The advisor will open the next grid order at the market price.
  • Limit - A pending order of the Limit type will be placed for the next grid order.
  • Stop - A Stop order will be placed for the next grid order when the price moves the " ___Set distance for "Stop", pips"  from the placement point. This ensures that it will be opened if the price reverses. In this mode, the order will also trail the price at a distance. "___Set trailing distance for "Stop", pips", If the price doesn't reverse, this allows you to improve your entry point!!!
___ Set distance for "Stop", pips Select the distance from current prices to place a Stop order.
___ Set trailing distance for "Stop", pips  Select the trailing distance for a Stop order.
===== Grid Stop Loss Mode
Stop Loss calculation mode for the Grid (drop-down list):
  • Off – Stop loss for the grid is disabled. If there are positions with a stop loss, it is removed.
  • Pips from the furthest position – From the farthest position. For BUY from the lowest, for SELL from the highest
___ Stop Loss, pips
Stop Loss value in pips
===== Grid Take Profit Mode
Take Profit calculation mode for the Grid (drop-down list):
  • Off – Take profit is disabled for the grid. If there are positions with take profit, it is removed.
  • Pips from the closest position – From the closest position. For BUY, from the highest position; for SELL, from the lowest position.
  • Pips from breakeven – from the breakeven level taking into account swaps and commissions.
___ Take Profit, pips
Take profit value in pips.
Close Grid the profit, account currency (0=off) Closing all grid orders in one direction when profit is reached


========== Accumulative Buffer (AB)

===== Accumulative Buffer
On/Off
Choosing a direction to close unprofitable positions
Selecting the direction for closing unprofitable positions (drop-down list):
  • Buy - buy positions will be closed due to the cumulative buffer if their total volume reaches the value Threshold to activate AB.
  • Sell - sell positions will be closed using the cumulative buffer if their total volume reaches the value Threshold to activate AB.
  • Avto - due to the cumulative buffer, positions in the direction the total volume of which has reached the value will be closed Threshold to activate ABand the total volume is greater than the opposite volume.
Threshold to activate AB
The activation threshold of the AB when the parameter  ===== Accumulative Buffer is set to On. If the threshold is not reached, the AB is disabled.
Use AB profit for the of days Use the specified number of days to calculate AB profit
Percent use AB A percentage of accumulated profits that will be used to close losing positions. This can be reduced if you want to keep a percentage for yourself.
Lot calculation mode for closing a losing position  Lot calculation mode for closing a losing position (drop-down list):
  • Percent of the total volume of the direction - Percentage of the total volume of the losing direction. For example, the buy direction grid is losing money, its total volume is 0.5 lots. If in the parameter ___ Value for Lot calculation mode =10,then we will close 0.5*10/100=0.05 lot or the entire position if its lot is less.
  • Fixed lot - Will close the lot specified in the parameter ___ Value for Lot calculation modeor the entire position if its lot is less.
    ___ Value for Lot calculation mode Value for Lot calculation mode for closing a losing position 

     

    ========== Visualization

    Drawing the Next level Opening
    Show the opening levels of the next order on the chart
    Drawing Breakeven levels
    Show breakeven levels on the chart. Buy direction - blue, Sell direction - orange, overall breakeven for both directions (if possible) - pink.

     

    ========== Indicators

    --- ATR ---

    Indicator name
    ATR Time frame The time frame from which the ATR value is taken
    ATR Peroid
    ATR Peroid


    Download the demo version and explore AB Universal Grid in the tester

    Version for MT5 https://www.mql5.com/en/market/product/145321
    Version for MT4 https://www.mql5.com/en/market/product/147482