Hedging Grid EA

MQL4 Experts

Job finished

Execution time 7 days
Feedback from employee
Good client, good business
Feedback from customer
Good Job

Specification

Project Overview: Hedging Grid EA
The goal is to create an MQL4 Expert Advisor that employs a hedging grid strategy. This means it will open both buy and sell trades, often simultaneously, and will add to positions at predefined intervals as the price moves.
Core Strategy:
Grid Trading: The EA places new pending orders (BUYSTOP, SELLSTOP) at a set distance from existing trades.
Hedging: It manages buy and sell trades independently, allowing them to run at the same time.
Lot Sizing: It can use a multiplier (martingale-style) or a fixed increment to increase the lot size for new grid orders.
Profit/Loss Management: It closes trades based on several conditions:
Profit target for a single direction (e.g., close all buys).
Combined profit target for both directions (hedged basket).
A hard stop-loss based on total drawdown.
Dynamic Orders: It uses trailing stops on open positions and can also "trail" its pending orders, adjusting their entry price as the market moves.
Visual Interface: The EA displays key information directly on the chart, including profits, average entry prices, and trading signals.
Part 1: EA Settings (Global extern Variables)
These are the user-configurable inputs. The programmer needs to declare these at the top of the file so they appear in the EA's settings window in MetaTrader.
Order Management:
Magic: int - A unique magic number to distinguish this EA's trades from others.
slippage: int - The maximum allowed slippage in points for order execution.
Allow_BUY, Allow_SELL: bool - Master switches to enable or disable buy and sell trading.
Open_order_on_trend: bool - A setting to control grid order placement logic (either with or against the trend).
Lot Sizing:
Order_lotsize: double - The initial lot size for the first trade in a series.
Multiply_lotsize_by: double - A multiplier for the next lot size (e.g., 1.5 for a martingale strategy).
Increase_lotsize_by: double - A fixed amount to add to the next lot size (used if the multiplier is 1.0).
Round_lotsize_to_decimals: int - The number of decimal places to round the lot size to (e.g., 2 for standard lots).
Grid & Order Spacing:
First_step: int - The distance in points from the current price to place the first pending order.
Distance_between_orders: int - The minimum distance in points between orders in the grid.
Minimum_price_distance: int - The minimum distance from the current price for subsequent pending orders.
Move_step: int - The number of points the price must move before a pending order is trailed (modified).
Stop Loss & Take Profit:
Stoploss, Takeprofit: int - The initial Stop Loss and Take Profit in points for each individual order.
Trailing_type: int - The type of trailing stop to use (0 = disabled). The programmer will need to implement the logic for different types if required.
Trailing_step: int - The step, in points, for the trailing stop.
Minimum_trailing_profit: int - The minimum profit in points an order must have before the trailing stop is activated.
Basket Closing Conditions:
Profit_for_closing_1_direction: double - The profit amount in account currency to close all trades in one direction (e.g., close all buys when their total profit reaches $50).
Profit_for_closing_2_directions: double - The profit amount to close all trades (buys and sells) when the combined profit of the hedged basket reaches this target.
Loss_for_closing: double - A negative dollar amount that triggers the closing of all trades in one direction (e.g., close all buys if their total profit reaches -$100).
Maximum_allowed_loss: double - A negative dollar amount that prevents the EA from opening new trades in a direction.
Close_loss_by_drawdown: double - A profit threshold. If the profit of either side drops below this, the EA switches to its "hedged close" logic.
Auto_calculated_profit: double - A setting to automatically calculate the profit target based on lot size and tick value.
Indicators & Timing:
Opening_1_order_on_indicators: bool - If true, the very first order will only be placed if RSI conditions are met.
Timeframe_indicator: int - The timeframe to use for the RSI calculation.
RSI_Period, Oversold_zone, Overbought_zone: int - Standard RSI settings.
Delete_Orders: bool - Enable/disable the scheduled deletion of all orders.
DeleteHour: int - The server hour (0-23) to delete all orders.
Visuals:
Font_size: int - The font size for text displayed on the chart.
Color_information: color - The color for the informational text.
Part 2: Main Program Structure (OnInit, OnDeinit, OnTick)
int OnInit(): This function runs once when the EA is first attached to a chart. Its purpose is to set up the visual display. The programmer should write code here to create all the necessary text objects (OBJ_LABEL) on the chart for displaying Balance, Equity, Profits, etc.
void OnDeinit(const int reason): This function runs once when the EA is removed from the chart. It should contain a cleanup routine to delete all chart objects created in OnInit().
void OnTick(): This is the heart of the EA, running on every new price tick. The programmer should implement this function exactly as it appears in the refactored code, with the main logic flow calling the 9 helper functions in sequence.
Part 3: Helper Function Implementation
The programmer should create each of the 9 functions called by OnTick.
HandleScheduledOrderDeletion(): Simple function. Check the Delete_Orders setting and the current server hour. If they match DeleteHour, call a function to close/delete all orders.
ProcessOpenOrders(...): This is a critical data-gathering function. It must loop through all orders, filter them by the current symbol and magic number, and then calculate all the key metrics (counts, lots, profits, price points) needed by the other functions.
UpdateAveragePriceObjects(...): This function should first delete the old "SLb" and "SLs" arrows from the chart. Then, if buy or sell orders exist, it should create new arrows (OBJ_ARROW with SYMBOL_RIGHTPRICE) at the calculated averageBuyPrice and averageSellPrice.
ApplyTrailingStops(...): Loop through all open trades. For each trade, calculate the potential new trailing stop loss price. If this new price is better than the current one (higher for buys, lower for sells) and meets the minimum profit condition, modify the order using OrderModify().
ManageProfitAndLossClosing(...): Implement the series of if statements to check the various profit and loss conditions against the targets. If a condition is met, it should call the CloseOrders() function with the correct parameter (1 for buys, -1 for sells, 0 for all).
UpdateTradingSignals(...): This function updates the chart labels ("Char.b", "Char.s") that show if trading is allowed. It uses ObjectSetText() with special Wingdings font characters to display green checkmarks or red crosses.
ManagePendingOrders(...): Implement the logic to place new grid orders. This involves calculating the lot size, determining the entry price based on distance rules and RSI, and checking if there is enough free margin before calling OrderSend().
ModifyPendingOrders(...): Implement the "trailing pending order" logic. Calculate the ideal new price for the existing pending order and compare it to its current price. If the complex shouldModify condition is met, call OrderModify() to update the order's entry price.
UpdateChartInformation(...): Update all the informational text labels on the chart (Balance, Equity, ProfitB, etc.) with the latest values calculated in ProcessOpenOrders.
Part 4: Required Utility Functions
The programmer will also need to create the functions that perform the actual trading actions and calculations.
CloseOrders(int direction): This function will loop through all orders. Based on the direction parameter (1, -1, or 0), it will use OrderClose() on the matching trades.
DeleteOrders(): Similar to CloseOrders, but it will use OrderDelete() for pending orders and OrderClose() for open market orders.
TradingHours(): A function that checks the current server time against user-defined start and end hours to determine if the EA is within its allowed trading session.
CalculateTrailingStop(...): The logic to calculate the trailing stop price. This could be as simple as Bid - Trailing_Stop_Points for a buy order.
UpdateChartLabel(...): A small helper function to make creating and updating the text objects in OnInit and UpdateChartInformation cleaner and less repetitive.

Files:

Responded

1
Developer 1
Rating
(232)
Projects
289
27%
Arbitration
14
50% / 36%
Overdue
9
3%
Loaded
2
Developer 2
Rating
(94)
Projects
137
17%
Arbitration
4
50% / 25%
Overdue
12
9%
Loaded
3
Developer 3
Rating
(13)
Projects
17
18%
Arbitration
3
67% / 0%
Overdue
0
Working
4
Developer 4
Rating
(463)
Projects
907
76%
Arbitration
25
16% / 68%
Overdue
99
11%
Free
Published: 1 article, 6 codes
5
Developer 5
Rating
(98)
Projects
137
52%
Arbitration
4
50% / 50%
Overdue
0
Free
6
Developer 6
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
7
Developer 7
Rating
(66)
Projects
119
39%
Arbitration
15
47% / 53%
Overdue
29
24%
Loaded
8
Developer 8
Rating
(45)
Projects
59
37%
Arbitration
1
0% / 0%
Overdue
1
2%
Working
9
Developer 9
Rating
(365)
Projects
507
40%
Arbitration
147
18% / 72%
Overdue
99
20%
Loaded
10
Developer 10
Rating
(293)
Projects
523
36%
Arbitration
62
34% / 35%
Overdue
188
36%
Working
11
Developer 11
Rating
(7)
Projects
8
13%
Arbitration
2
0% / 0%
Overdue
1
13%
Loaded
12
Developer 12
Rating
(15)
Projects
34
24%
Arbitration
3
0% / 33%
Overdue
2
6%
Working
13
Developer 13
Rating
(12)
Projects
13
23%
Arbitration
6
0% / 67%
Overdue
3
23%
Working
14
Developer 14
Rating
(574)
Projects
945
47%
Arbitration
303
59% / 25%
Overdue
125
13%
Free
15
Developer 15
Rating
(77)
Projects
232
73%
Arbitration
6
100% / 0%
Overdue
1
0%
Free
16
Developer 16
Rating
(53)
Projects
85
41%
Arbitration
3
0% / 100%
Overdue
3
4%
Working
17
Developer 17
Rating
(6)
Projects
6
17%
Arbitration
0
Overdue
0
Working
18
Developer 18
Rating
(1)
Projects
1
0%
Arbitration
0
Overdue
0
Free
19
Developer 19
Rating
(43)
Projects
65
11%
Arbitration
12
58% / 42%
Overdue
1
2%
Free
20
Developer 20
Rating
(6)
Projects
7
0%
Arbitration
0
Overdue
2
29%
Free
21
Developer 21
Rating
(270)
Projects
550
49%
Arbitration
56
39% / 36%
Overdue
227
41%
Working
22
Developer 22
Rating
(1)
Projects
2
0%
Arbitration
1
0% / 0%
Overdue
0
Free
23
Developer 23
Rating
(8)
Projects
12
0%
Arbitration
22
0% / 77%
Overdue
4
33%
Free
24
Developer 24
Rating
(6)
Projects
7
14%
Arbitration
0
Overdue
0
Loaded
25
Developer 25
Rating
(2)
Projects
2
0%
Arbitration
0
Overdue
0
Free
Similar orders
I am looking for an experienced MQL5 developer to backtest and optimize an existing Expert Advisor (EA) for XAUUSD (Gold), M5 timeframe . The objective is to achieve consistent, low-risk performance suitable for live trading. Scope of Work Run detailed backtests using high-quality historical tick data Optimize key parameters, including risk settings, SL/TP, trailing stop, and lot sizing Ensure stability across
Hi there, I am here as a representative of my team looking for a very reliable to have clear look at my HFT trading strategy including references of exactly what the final product should look like, we also have a detailed specifications in place which we'll be sharing only with an experience certified top level developer, I mean he/she must be well skilled and knowledgeable in various programming language with the
I’m seeking an experienced MQL5 developer to backtest and optimize an existing Expert Advisor (EA) for XAUUSD (Gold), M5 timeframe . Goals: Consistent daily profit of £50–£100 on a £10,000 account Maximum 10% drawdown Smooth, stable performance without triggering equity protection Scope: Backtest with high-quality historical data Optimize key parameters (risk, SL/TP, trailing stop, lot sizing, etc.) Deliver optimized
1. RSI Filter: Implement an RSI filter that prevents the EA from opening buy orders if the RSI overbought value exceeds the specified parameter, and prevents sell orders if the RSI oversold value is below the specified parameter. Input settings should include: Use RSI Filter: true/false RSI Period: 14 (configurable) RSI Overbought level (input) RSI Oversold level (input) 2. MQL5 Market Validation: Ensure the code
when the marked yu we need to buy if it up we will get profit when the marked up to down we need to sell for get profit if it up we will loss
Job Description I am looking for a highly skilled MQL5 DEVELOPER and A TRADER to work on an MT5 Expert Advisor (EA) project. The main tasks will include: 1. Code Compilation & Optimization – Reviewing, compiling, and streamlining the existing EA code to ensure efficiency and stability. 2. Backtesting Setup & Execution – Running professional backtests to ensure the EA produces consistent, gradual profit growth curves
Hi there, I am here as a representative of my team looking for a very reliable to have clear look at my HFT trading strategy including references of exactly what the final product should look like, we also have a detailed specifications in place which we'll be sharing only with an experience certified top level developer, I mean he/she must be well skilled and knowledgeable in various programming language with the
MT5 Bar-Replay Simulator EA — Live Terminal / Offline-Style Chart Spec 1) Execution Mode Attach EA to any live chart → Open a setup dialog ( Apply Settings ). On OK , EA: Loads history for selected symbol(s)/date range, Creates a synthetic custom symbol (e.g., REPLAY.XAUUSD ), Builds a synthetic chart (offline-style) for the chosen start date, Opens that replay chart and mounts all UI panels there. All trading is
Objective To design and implement a profitable Expert Advisor (EA) that trades based on time-of-day signals , historical success ratio , and a volume-based trigger . The system adapts over a bi-weekly performance evaluation window to optimize entry conditions. Core Logic Time-of-Day Filter EA only trades within user-defined trading sessions (e.g., London Open, NY Open, Asia Session). Configurable start/end time
hello i want the indicator please hello i want the indicator please hello i want the indicator please hello i want the indicator please hello i want the indicator please

Project information

Budget
100 - 150 USD
For the developer
90 - 135 USD
Deadline
to 7 day(s)