Hedging Grid EA

MQL4 Experts

Tâche terminée

Temps d'exécution 7 jours
Commentaires de l'employé
Good client, good business
Commentaires du client
Good Job

Spécifications

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.

Dossiers :

Répondu

1
Développeur 1
Évaluation
(258)
Projets
323
30%
Arbitrage
34
26% / 65%
En retard
10
3%
Travail
2
Développeur 2
Évaluation
(107)
Projets
175
25%
Arbitrage
23
13% / 78%
En retard
16
9%
Gratuit
3
Développeur 3
Évaluation
(15)
Projets
19
16%
Arbitrage
5
40% / 40%
En retard
0
Gratuit
4
Développeur 4
Évaluation
(510)
Projets
977
74%
Arbitrage
27
19% / 67%
En retard
100
10%
Gratuit
Publié : 1 article, 6 codes
5
Développeur 5
Évaluation
(98)
Projets
137
52%
Arbitrage
5
40% / 60%
En retard
0
Gratuit
6
Développeur 6
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
7
Développeur 7
Évaluation
(68)
Projets
126
40%
Arbitrage
18
44% / 56%
En retard
33
26%
Travail
8
Développeur 8
Évaluation
(47)
Projets
67
37%
Arbitrage
5
40% / 40%
En retard
1
1%
Gratuit
9
Développeur 9
Évaluation
(365)
Projets
507
40%
Arbitrage
159
17% / 74%
En retard
99
20%
Chargé
10
Développeur 10
Évaluation
(317)
Projets
564
35%
Arbitrage
81
31% / 44%
En retard
204
36%
Gratuit
11
Développeur 11
Évaluation
(25)
Projets
31
13%
Arbitrage
13
0% / 77%
En retard
9
29%
Gratuit
12
Développeur 12
Évaluation
(16)
Projets
35
23%
Arbitrage
4
0% / 50%
En retard
2
6%
Travail
13
Développeur 13
Évaluation
(12)
Projets
13
23%
Arbitrage
7
0% / 71%
En retard
3
23%
Travail
14
Développeur 14
Évaluation
(574)
Projets
945
47%
Arbitrage
309
58% / 27%
En retard
125
13%
Gratuit
15
Développeur 15
Évaluation
(77)
Projets
244
74%
Arbitrage
7
100% / 0%
En retard
1
0%
Gratuit
Publié : 1 article
16
Développeur 16
Évaluation
(58)
Projets
90
43%
Arbitrage
4
0% / 100%
En retard
3
3%
Travail
17
Développeur 17
Évaluation
(13)
Projets
13
38%
Arbitrage
1
0% / 100%
En retard
1
8%
Gratuit
18
Développeur 18
Évaluation
(1)
Projets
1
0%
Arbitrage
0
En retard
0
Gratuit
19
Développeur 19
Évaluation
(43)
Projets
66
12%
Arbitrage
12
58% / 42%
En retard
1
2%
Gratuit
20
Développeur 20
Évaluation
(8)
Projets
7
0%
Arbitrage
3
0% / 100%
En retard
2
29%
Gratuit
21
Développeur 21
Évaluation
(271)
Projets
553
50%
Arbitrage
57
40% / 37%
En retard
227
41%
Travail
22
Développeur 22
Évaluation
(1)
Projets
2
0%
Arbitrage
2
0% / 50%
En retard
0
Gratuit
23
Développeur 23
Évaluation
(9)
Projets
13
0%
Arbitrage
23
0% / 78%
En retard
4
31%
Gratuit
24
Développeur 24
Évaluation
(48)
Projets
56
34%
Arbitrage
15
27% / 60%
En retard
1
2%
Travail
25
Développeur 25
Évaluation
(2)
Projets
2
0%
Arbitrage
0
En retard
0
Gratuit
Commandes similaires
I need someone to develop a very simple and basic Expert Advisor for MetaTrader 5. The EA should open and close trades based on a custom trading time schedule. I am a student and I do not have a budget, so I am kindly asking if someone can help me for free or as a beginner-friendly project. The EA does not need to be complicated. I only need basic settings for start time, end time, buy/sell option, lot size, stop
Profitable EA 50 - 5000 USD
I have been tired of losing money in forex for several years, I decided to buy an EA directly from the programmer , I am ready to put the right price for a real winning strategy, no matter which strategy is used. The main thing is that the strategy is profitable Send me a demo, I'll put it on the VPS. The most profitable strategy will be chosen after a week
I really like this platform. I am interested in trading and need funds for it. I enjoy both crypto and forex trading.I"really appreciate this platform. I am keen on trading and am looking for trading funds. I enjoy trading in both cryptocurrency and forex."
Titan Quantum Algo Engine V2 is an advanced MT5 Expert Advisor designed to identify high-probability market opportunities using trend analysis, breakout detection, and intelligent risk management. The EA automatically executes trades, manages stop-loss and take-profit levels, and helps traders maintain disciplined trading with optimized entry and exit strategies
The striker robot 30 - 2000 USD
I would like a trend and pullback strategy for the robot timeframe:15 minutes(m15) or 1 hour(h1) indicators:50 EMA (Exponential Moving Average)/200 EMA/RSI (14) BUY SET UP 1.Confirm The Trend .50 EMA must be above 200 EMA .Price must be above both EMAs 2.Wait for a pullback .Do not buy when the price shoots up. .Wait for the price to come back near the 50 EMA 3.Confirm entry .ENTER BUY WHEN: .A bullish candlestick
//+------------------------------------------------------------------+ //| Simple XAUUSD EA | //+------------------------------------------------------------------+ input double LotSize = 0.01; input int StopLoss = 500; // in points input int TakeProfit = 1000; // in points input int MAPeriod = 20; int maHandle; int OnInit() { maHandle = iMA(_Symbol, PERIOD_H1, MAPeriod, 0, MODE_SMA
Hello, I need a Python-based MT5 forex trading bot developed. The bot should connect to MetaTrader 5, execute trades based on a predefined strategy, and support standard risk management features such as stop loss, take profit, and position sizing. Requirements: MT5 integration using Python Automated trade execution based on provided strategy rules Configurable risk management settings Support for major forex pairs
### ** Main EA File** - `InstitutionalTrendPullbackScalper.mq5` **Core Features Implemented:** **Multi-Timeframe Analysis** - M15 trend filter (EMA20 > EMA50 for uptrends) - M5 entry signals with 5-condition confirmation - Independent indicator sets for both symbols **Advanced Entry Logic** - RSI reversal detection (crosses thresholds) - Price pullback zone validation - Bullish/bearish candle close confirmation -
I need developer who Can perfectly build me a layout of Ninjatrader 8 (NT8) to look and feel the same on SierraCharts? I currently use NT8 but I want to start using SierraCharts because its more robust than NT8, but I don't want to have to worry about programming SierraCharts. How much would this cost? Thank you
Automate my trading 100 - 300 USD
i want a trading bot that take trade auto and make 5% profit daily and stop with in 24 hours not more then that at least the bot give me more then 2% not less then that like a ai agent if it make any loss that agent have to take care of it i need only 5 % profit

Informations sur le projet

Budget
100 - 150 USD
Délais
à 7 jour(s)