MT5 functions needed: (1) WAtp for hedged sequences (2) Partial closing trades, based on closed profit

MQL5 Outros Forex

Termos de Referência

1) WA take profit

input int MagicNumber =8888; // input Magic Main trades
int HedgeBuyMagicNumber = 1234; // MagicNumber for buy hedge trades
int HedgeSellMagicNumber = 4321; // MagicNumber for sell hedge trades

input double TargetProfit = 35; // TP in pips, for trades + hedges

------------

We trade in 2 directions, opening martingale sequence. Buy sequences and Sell sequences can exists at the same time. At a certain point there will be hedge trades added to the sequence.
This means; buy sequence will have: buy1(8888)+buy2(8888)+buy 3(8888) +etc +hedgesell 1(4321)+ hedge sell 2(4321), and sell sequence vice versa.

I need a function for closure for this (-buy OR sell NOT both at the same time-) sequence, that uses weighted average profit + TargetProfit. Taking in account spread.

------------



2) Partial closing opposite trade.

input double TargetProfitHedge = 40  // TP in pips, for hedges

------------

When a trade using HedgeBuyMagicNumber or HedgeSellMagicNumber, closes in profit, Because it hits TargetProfitHedge

=> register the profit

=> look up oldest opposite open trade ( HedgeBuyMagicNumber = look for sell with MagicNumber  | HedgeSellMagicNumber = look for buy MagicNumber)

=> partial close, for the profit part. ( if possible considering lotsize)



------------------------------------------------
extra info.

I have AWtp working in my EA, only the TP is based on currency. Because I could net get the closing based in TP in pips to work properly and fast.

The -Partial closing opposite-, I can not figure out the "history reading" part

These functions will be integrated in my own EA, by myself.


**Payment Terms & Conditions**

In the past, I have followed a 1/6, 2/6, 3/6 payment structure: a down payment, a payment upon proof of concept, and a final payment upon full delivery and approval. However, since this project involves functional code, this approach is not applicable.

Due to a number of negative experiences with developers, I now require payment to be made only after the project has been completed and I have verified that it works as requested.

Please understand that this means the developer assumes the risk for the project. This condition is non-negotiable. My goal is to maintain transparency, so you are fully aware of the terms if you decide to take on the assignment. 

---

Kind regards!




Here are the 3 functions im using for grid/sequence coding atm. BASED ON CURRENCY TP.

//+-----------
void HandleTakeProfit(ulong &tickets[], double &volumes[], int count, int gridType) {
int hedgeCount = (gridType == POSITION_TYPE_BUY)
? CountHedges(HedgeSellMagicNumber)
: CountHedges(HedgeBuyMagicNumber);

if (hedgeCount == 0) {
// ✅ Gebruik BE + TP in pips voor een normale grid zonder hedges
CheckTPByBreakEven(tickets, volumes, count, gridType, TargetProfitPips);
} else {
// Gebruik TP op basis van valuta als er wel hedges zijn
CheckTPByCurrency(tickets, count, gridType, TargetProfitCurrency);
}
}


//+-----------
void CheckTPByCurrency(ulong &tickets[], int count, int gridType, double targetProfit) {
double currentProfit = CalculateGridNetProfit(tickets, count);

if (currentProfit >= targetProfit) {
DebugPrint("✅ Target currency profit reached. Closing grid...");
CloseGrid(tickets, count);
} else {
// DebugPrint("Current profit: " + DoubleToString(currentProfit, 2) + " | Target profit: " + DoubleToString(targetProfit, 2));
}
}


void CloseGrid(ulong &tickets[], int count) {
DebugPrint("Starting CloseGrid with " + IntegerToString(count) + " positions.");

isProcessingTrade = true; // Schakel OnTick() tijdelijk uit

int closedCount = 0; // Telt succesvol gesloten posities
int failedCount = 0; // Telt mislukte sluitingen

for (int i = 0; i < count; i++) {
ulong ticket = tickets[i];

// **Selecteer en controleer positie in één stap**
if (!PositionSelectByTicket(ticket)) {
DebugPrint("Skipping ticket (not found): " + IntegerToString(ticket));
continue;
}

double lotSize = PositionGetDouble(POSITION_VOLUME);
double openPrice = PositionGetDouble(POSITION_PRICE_OPEN);
int positionType = (int)PositionGetInteger(POSITION_TYPE);

// **Probeer positie te sluiten**
if (trade.PositionClose(ticket)) {
closedCount++;
DebugPrint("Closed: Ticket=" + IntegerToString(ticket) +
", Type=" + (positionType == POSITION_TYPE_BUY ? "BUY" : "SELL") +
", Lot=" + DoubleToString(lotSize, 2) +
", OpenPrice=" + DoubleToString(openPrice, 5));
} else {
failedCount++;
DebugPrint("Failed to close: Ticket=" + IntegerToString(ticket));
}
}

isProcessingTrade = false; // Heractiveer OnTick()

DebugPrint("CloseGrid completed: Success=" + IntegerToString(closedCount) +
", Failed=" + IntegerToString(failedCount));
}
















































































































































Respondido

1
Desenvolvedor 1
Classificação
(19)
Projetos
20
25%
Arbitragem
1
100% / 0%
Expirado
0
Livre
2
Desenvolvedor 2
Classificação
(271)
Projetos
445
38%
Arbitragem
92
42% / 18%
Expirado
73
16%
Ocupado
3
Desenvolvedor 3
Classificação
(1)
Projetos
1
0%
Arbitragem
1
0% / 100%
Expirado
0
Livre
Pedidos semelhantes
Ea converter 30 - 200 USD
//+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { // Initialization logic Print("Trading bot initialized."); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function |
hello - i have a fully functioning code I have built out for ninjatrader 8 - i actually have 4 of them I am looking for someone to be able to help me to convert the code from ninjatrader 8 C# code to a metatrader 5 and also metatrader 4 code. so i have provided 2 files one is an IFVG strategy and simply trades price action based on inversed fair value the other one is a MACD strategy but it uses the custom MACD
I'm looking to get a custom MT5 Breakout EA created that will place trades automatically based on the condition rules. This explains rules in identifying: High and Low of a range Direction of the trend Conditions to place a buy trade Conditions to place a sell trade Breakout MetaTrader Expert Advisor Strategy Settings
Gooday programmers! I would like to order a Robot with the following requirements: 1. When the moving average MA of period 5, then period 6, then period 7 breaks the price from above, and then all averages intersect at the same price - BUY 1. 2. When the price breaks below of moving average MA period 5, and period 6, and period 7, and all averages intersect - SELL (roll).. 3. Stop-loss break even feature and tp
I need an EA with great results (5 years back test atleast) its better to work on many instruments Work on prop firms without violate rolls consistency is most important factor
Job Description: I need an experienced MQL developer freelancer who can create an Expert Advisor (EA) with Websocket integration for the Meta Trader platform. The end result of this project is one source code of MQ4 and MQ5 EA, which is able to communicate directly with the websocket that we have built using node.js technology. The goal is for these EAs to communicate, exchanging information via the internet. Project
Hello, I am looking for an experienced developer to help me enhance an existing indicator and Expert Advisor (EA) that I own. I would like to add several new features to improve their functionality and performance. Please review the attached file for a detailed description of the modifications I need. Let me know if you are available to assist with this project
I need the QQE Indicator in mql5 for building an EA. That means the indicator needs buffers obviously. We can maybe create an EA together once this job is done. The code needs to be written in english and clean coded (incl. documentation). The best would be if someone made it already. Please send screenshots in that scenario. Please Note: If you don't know anything about the QQE Indicator then don't apply
Program Strategy for Ninja Trader 8, Strategy will use the RangeFinder indicator. Strategy will include Daily profit target - Profit Target can be enabled / disabled - Screen shot provided, Maximum Daily Loss function - enabled / disabled, 3 Start and Stop times with enable and disable options based on template provided. A screen shot of the start and stop times has been provided. Strategy is as follows: Strategy
Hello, We need programmer very soon for built EA MT4 This EA using MA, ATR, and Consecutives Candle for trigger open position The others EA features any about risk lot, TP, SL, News, Notification to MT4 Desktop, MT4 Mobile, and Telegram This EA has parameters panel statistic results that we input settings in EA like history that we want depend on time and current time resuts, and also can backtest normally This job

Informações sobre o projeto

Orçamento
30+ USD
IVA (21%): 6.3 USD
Total: 36 USD
Desenvolvedor
27 USD
Prazo
para 5 dias

Cliente

Pedidos postados1
Número de arbitragens0