Zum Inhalt springen

ATR Grid Trader Pro

Aus Kössler Lehrerlexikon


ATR Grid Trader Pro: Professional Grid Trading System Based on ATR Indicator for MetaTrader 5



For traders seeking an automated grid trading system that adapts to market volatility, ATR Grid Trader Pro provides a revolutionary solution that combines the Average True Range (ATR) indicator with a multi-entry system and comprehensive position management. The system uses volatility to determine optimal entry points, automatically opens a series of orders (grid) at optimal distances, and applies advanced risk management techniques including trailing stops and break-even functions, allowing traders to profit from price fluctuations with strict risk control.



Understanding the ATR Indicator and Its Application in Trading



ATR Grid Trader Pro uses the Average True Range (ATR) indicator, developed by J. Welles Wilder, which measures the true price range over a period of time. The indicator calculates the average value of the largest of three values: the difference between the high and low of the current bar, the difference between the high and close of the previous bar, and the difference between the low and close of the previous bar.



ATR shows market volatility regardless of the direction of price movement. A high ATR value indicates high volatility, while a low ATR value indicates low volatility. The system uses ATR_Period (typically 14) for calculation, parameters ATR_HighThreshold and ATR_LowThreshold to determine volatility thresholds, and normalizes ATR to price by dividing by the current price in pips.



ATR Normalization System and Volatility Determination



ATR Grid Trader Pro normalizes the ATR value by dividing by the current price (normalizedATR = currentATR / currentPrice), converting absolute volatility value to relative. The ATR_LowThreshold parameter defines the lower volatility threshold (typically 0.0007 or 0.07%), at which the system opens BUY positions. The ATR_HighThreshold parameter defines the upper volatility threshold (typically 0.0015 or 0.15%), at which the system opens SELL positions.



The trading logic is based on the assumption that low volatility (ATR below the lower threshold) precedes upward movement, so the system opens purchases. High volatility (ATR above the upper threshold) may precede downward movement, so the system opens sales. This logic can be adapted by traders to various market conditions and trading styles.



Multiple Entry System with Order Distance Management



ATR Grid Trader Pro uses parameters GridStep (distance between orders in pips), MinGridDistance (minimum distance between orders), and MaxGridOrders (maximum number of orders in one direction). The CheckGridConditions function checks whether the system can open a new order based on the distance to the nearest existing order through FindClosestOrderPrice.



The system checks that the distance from the current price to the nearest order is greater than MinGridDistance. The system also checks that the distance is a multiple of GridStep through MathMod(distance, GridStep) 0.1, ensuring even order distribution. When all conditions are met, the system opens a new order through OpenOrder.



The CountOpenOrders function counts the number of open positions in each direction, distinguishing between BUY positions (POSITION_TYPE_BUY) and SELL positions (POSITION_TYPE_SELL). The system does not open new positions if the count reaches MaxGridOrders.



Position Size Management System with Risk Adaptation



ATR Grid Trader Pro supports two position size calculation modes. Fixed lot mode (UseRiskPercent = false) uses Lot_Size regardless of market conditions, providing consistent trading volume. Risk management mode (UseRiskPercent = true) uses CalculateLotSize, which calculates lot size based on account balance, stop-loss, and desired risk percentage.



The CalculateLotSize function calculates risk in monetary terms as accountBalance RiskPercent / 100.0, then divides by (stopLossPoints pointValue) to obtain lot size. The system then normalizes the lot to broker requirements through NormalizeLotToStep, ensuring that the size conforms to SYMBOL_VOLUME_MIN, SYMBOL_VOLUME_MAX, and SYMBOL_VOLUME_STEP.



Volume and Margin Validation System Before Opening Positions



ATR Grid Trader Pro uses the CheckVolumeValue function to verify that lot size conforms to broker requirements (falls within minimum and maximum range, is a multiple of the step). The CheckMarginAndAdjustLot function checks available margin through OrderCalcMargin and automatically reduces lot size by 50% in a loop up to 8 attempts if margin is insufficient.



The system also compares ACCOUNT_MARGIN_FREE with required margin before opening a position. If margin is insufficient, the system reduces lot size and rechecks. This process ensures that the system never opens a position with insufficient margin.



Daily Trading Activity Limit Management System



ATR Grid Trader Pro uses parameters DailyLimit (enabling daily limit), MaxOrdersPerDay (maximum number of orders per day), and MinutesBetweenTrades (minimum time between orders in minutes). The CheckAndResetDailyOrders function checks whether a new trading day has occurred by comparing the current date with g_lastDayChecked and resets ordersOpenedToday = 0 when the day changes.



The CountTodayOrders function counts the number of orders opened today by analyzing HistoryOrdersTotal between the beginning of the current day and the current time. The CheckTimeBetweenTrades function checks whether sufficient time has passed (MinutesBetweenTrades 60 seconds) since the last order (lastOrderTime).



When the daily limit is exceeded (ordersOpenedToday >= MaxOrdersPerDay), the system skips opening new positions for the rest of the day, preventing excessive trading activity.



Stop-Loss and Take-Profit Management System



ATR Grid Trader Pro calculates stop-loss by subtracting StopLoss pips from entry price for BUY positions and adding StopLoss pips for SELL positions. The ValidateSL function checks that the stop-loss is at the minimum allowable distance from price, determined by SYMBOL_TRADE_STOPS_LEVEL and SYMBOL_TRADE_FREEZE_LEVEL.



The system normalizes stop-loss to the number of decimal places of the symbol through NormalizeDouble(slWanted, digits). Take-profit is calculated similarly, by adding TakeProfit pips for BUY positions and subtracting for SELL positions.



Trailing Stop System with Position State Tracking



ATR Grid Trader Pro uses the TrailingStopInfo structure to track trailing stop information for each position, including ticket (position number), lastSetSL (last set stop-loss), and lastModifyTime (time of last modification). The UpdateTrailingStopInfoArray function synchronizes the array with all open EA positions.



The ManageTrailingStop function checks whether a position has reached target profit (profitPoints >= TrailingStart), and if so, moves the stop-loss to a distance of TrailingDistance pips from the current price. The function checks that the movement is at least TrailingStep pips better (for BUY positions: idealSL > currentSL + TrailingStep * Point).



The system also prevents frequent modifications by checking that at least 5 seconds have passed since the last modification (currentTime - trailInfo[idx].lastModifyTime

Break-Even System for Capital Protection



ATR Grid Trader Pro uses the ManageBreakEven function to move the stop-loss to the break-even point when a position reaches target profit (profitPoints >= BreakEvenStart). The stop-loss is moved to entry point plus BreakEvenOffset pips, providing zero or minimal risk while maintaining profit potential.



The HasReachedBreakEven function checks whether break-even has already been set on a position by comparing currentSL with openPrice. For BUY positions, break-even is considered set if currentSL >= openPrice, for SELL positions if currentSL

Support System for Two Account Types: Hedging and Netting



ATR Grid Trader Pro automatically determines the account type in OnInit through AccountInfoInteger(ACCOUNTMARGIN_MODE) and sets the g_isNetting flag. The system adapts its parameters to account requirements, particularly when validating stop-loss and margin.



The system uses SYMBOL_TRADE_STOPS_LEVEL to determine the minimum stop-loss distance from price and checks this value in ValidateSL. On netting accounts, requirements are often more stringent, so the system may require additional buffers.



Safe Position Modification System with Error Handling



ATR Grid Trader Pro uses the SafePositionModify function for safely changing position parameters. The function checks whether a position exists through PositionSelectByTicket, compares current SL/TP with new values, and only if there are changes, sends a modification request.



The function creates an MqlTradeRequest with type TRADE_ACTION_SLTP, fills position (position number) and new sl and tp values, then sends through OrderSend. On error, the function outputs the error code and returns false.



Time Between Orders Processing System for Trading Frequency Control



ATR Grid Trader Pro uses the MinutesBetweenTrades parameter and the global lastOrderTime variable to control order opening frequency. The CheckTimeBetweenTrades function checks whether sufficient time has passed (in minutes, converted to seconds by multiplying by 60) between current time and lastOrderTime.



Upon successful order opening, the OpenOrder function updates lastOrderTime = TimeCurrent(), using system time. This prevents excessively frequent trading on volatile markets.



Application on Major Trading Instruments



ATR Grid Trader Pro is effectively applied to all major currency pairs EURUSD, GBPUSD, USDJPY, AUDUSD due to predictable volatility cycles and regular price fluctuations. On the precious metal XAU (gold), the system demonstrates good effectiveness due to clear high and low volatility cycles, especially on the hourly timeframe.



On energy commodities WTI and Brent, the system shows results due to volatility caused by geopolitical events and demand changes. On cryptocurrencies BTC and ETH, the system performs with very good effectiveness due to high volatility, frequent fluctuations, and data availability on various timeframes.



Recommendations for ATR Parameter Optimization



For conservative trading, it is recommended to use ATR_Period 14-20, ATR_LowThreshold 0.0005-0.0010, ATR_HighThreshold 0.0015-0.0020, MaxGridOrders 1-2, GridStep 50-100 pips. For aggressive trading, you can use ATR_Period 7-14, tighter thresholds (low 0.0007, high 0.0012), MaxGridOrders 3-5, GridStep 20-50 pips.



On volatile instruments (crypto, oil) it is recommended to increase ATR_HighThreshold and ATR_LowThreshold. On calm instruments (major currency pairs) you can use more sensitive thresholds. The TimeFrame parameter should match your trading style: H1 for medium-term trading, M30 for more frequent trading, D1 for long-term trading.



Conclusion



ATR Grid Trader Pro represents a comprehensive solution for grid trading that adapts to market volatility through the ATR indicator. The system combines volatility determination, multiple entry management, intelligent position size management, and complete risk control with trailing stops and break-even functions. The system includes daily limits, control over time between orders, and support for various account types, providing universal applicability. Built-in margin and volume validation functions guarantee that the system never opens an invalid position. Regardless of the chosen instrument or timeframe, ATR Grid Trader Pro provides automated, adaptive trading that allows profit extraction from natural market volatility cycles with strict risk management.



If you have any inquiries relating to where and how to use forex expert advisor, you can speak to us at the website.