Partial Lot Size Close at Floating Loss

Tâche terminée

Temps d'exécution 17 heures
Commentaires du client
Very prompt in replying and making fixes. I recommend this developer to anyone
Commentaires de l'employé
Nice Customer.. thx bro..

Spécifications

Hello , I need to Modify an expert advisor (Trade Manager for other EAs) to add new functionality :

1) Partial Lot Size Close at Floating Loss Amount:

  • Close % Partial Lot-size if Loss reached a defined amount (Note: Closing Priority will lead it the orders orders being closed first)
  • Close All Modify Take Profit of Remaining Lots to Breakeven (Dollar profit of Zero when taking into account Commission)

BONUS: For the Advanced Coders, I am willing to increase my budget if you are able to achieve the configuration that is shown in the Screenshot "Part 2"  . I can elaborate on this more, if you are interested/able to achieve this request.


This will require the following adjustment, modify the Magic Number the Open Orders so that the EA is able to manage them.

Here is an example of some source code that is able to achieve this, however it is not viable for my EA as it modifies the take profit of individuals orders and not the weighted average lot size of the orders for a specific symbol within a sequence.

void OnTick()
{
        for ( int z = OrdersTotal() - 1; z >= 0; z -- )
        {
                if ( !OrderSelect( z, SELECT_BY_POS, MODE_TRADES ) )
                {
                        Print( "OrderSelect( ", z, ", SELECT_BY_POS, MODE_TRADES ) - Error #", GetLastError() );
                        continue;
                }
                if ( MagicNumber != -1 && OrderMagicNumber() != MagicNumber ) continue;
                if ( OnlyCurrentSymbol && OrderSymbol() != _Symbol ) continue;

                int D = getDigits( OrderSymbol() );
                double P = getPoint( OrderSymbol() );

                if ( TakeProfit_B > 0.0 && OrderType() == OP_BUY )
                {
                        double correct_tp = NormalizeDouble( OrderOpenPrice() + TakeProfit_B*P, D );
                        if ( fabs( OrderTakeProfit() - correct_tp ) > P/20.0 && !AlreadyModified() )
                        {
                                Print( "Modifying TP of buy-order #", OrderTicket(), " (", 
                                                        DoubleToString( OrderTakeProfit(), D ), " -> ", DoubleToString( correct_tp, D ), ")..." );
                                if ( !OrderModify( OrderTicket(), OrderOpenPrice(), OrderStopLoss(), correct_tp, 0 ) )
                                        Print( "OrderModify failed with error #", GetLastError(), "!" );
                                else
                                        OrderSave();
                        }
                }
                if ( TakeProfit_S > 0.0 && OrderType() == OP_SELL )
                {
                        double correct_tp = NormalizeDouble( OrderOpenPrice() - TakeProfit_S*P, D );
                        if ( fabs( OrderTakeProfit() - correct_tp ) > P/20.0 && !AlreadyModified() )
                        {
                                Print( "Modifying TP of sell-order #", OrderTicket(), " (", 
                                                        DoubleToString( OrderTakeProfit(), D ), " -> ", DoubleToString( correct_tp, D ), ")..." );
                                if ( !OrderModify( OrderTicket(), OrderOpenPrice(), OrderStopLoss(), correct_tp, 0 ) )
                                        Print( "OrderModify failed with error #", GetLastError(), "!" );
                                else
                                        OrderSave();
                        }
                }
        }
}

As a result you may want to use some snippets from this code:

   void ModifyTP(int m)
{
   int i,r;
   double tpnya,dtp,bbep,sbep,ssize,bsize;
   tpnya=0;dtp=0;bbep=0;sbep=0;ssize=0;bsize=0;
   for (i=0; i<OrdersTotal();i++) 
   { 
      if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
      if (OrderSymbol() != Symbol()|| OrderMagicNumber() != MagicNumber || OrderType()!=m) continue;
         tpnya=OrderTakeProfit();
         if (m==0) {bbep += OrderOpenPrice()*OrderLots(); bsize= bsize+OrderLots();}
         if (m==1) {sbep += OrderOpenPrice()*OrderLots(); ssize= ssize+OrderLots();}
               
   }
   if (bbep>0) { bbep/=bsize; tpnya=NormalizeDouble(bbep + TP*pt,Digits); }
   if (sbep>0) { sbep/=ssize; tpnya=NormalizeDouble(sbep - TP*pt,Digits); }
      
   for (i=OrdersTotal()-1; i>=0; i--) 
   {
      if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
      if(OrderSymbol() != Symbol()|| OrderMagicNumber() != MagicNumber|| OrderType()!=m) continue;
         dtp=OrderTakeProfit();
         //if (m==0) {bbep += OrderOpenPrice()*OrderLots(); bsize= bsize+OrderLots();}
         //if (m==1) {sbep += OrderOpenPrice()*OrderLots(); ssize= bsize+OrderLots();}
         Print("tpnya",tpnya,": ",i);
         Print("dtp",dtp,": ",i);
         if( MathAbs(tpnya-dtp)>=pt &&  OrderType()==m)
         r  =  OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), tpnya, 0, CLR_NONE); 
   }
   //if (bbep>0) bbep/=bsize; dtp=bbep;
   //if (sbep>0) sbep/=ssize; dtp=sbep;  
}
   

The key inputs would be as follows:

input    string      CHART_MANAGEMNET1= "====== Trade Managerment ======";
input    string      symbol1          = "EURUSD";    // Symbol //Symbol that the modification would occur for
int                     MagicNumber                                             = -1;                           // * MagicNumber (-1 - modify all) - this is the magic number that the EA would change the Open Orders to
input double      TakeProfit           = 0.0;         //Breakeven amount in dollars (excluding commission) - this would be the modification amount in dollars taking into account commision (Note: I don't want pips as I will use this on other symbols that are not just forex)
^//Forgot to add this 

input double      PartialClose           = .3;         //Partial close percentage of lots when floating loss is reached on symbol 

EXAMPLE 1:

extern bool Partial_Close= true;

IF_LOSS = -500  ( $ )

{

Close 30% of Symbol in Loss 

Modify Take Profit to breakeven in dollars (taking into account Commission)

}





Dossiers :

PNG
Part_1.PNG
78.0 Kb
PNG
Part_2.PNG
99.5 Kb

Répondu

1
Développeur 1
Évaluation
(616)
Projets
963
46%
Arbitrage
31
39% / 32%
En retard
96
10%
Gratuit
Publié : 6 codes
2
Développeur 2
Évaluation
(120)
Projets
159
49%
Arbitrage
15
53% / 27%
En retard
4
3%
Gratuit
3
Développeur 3
Évaluation
(298)
Projets
427
26%
Arbitrage
18
61% / 33%
En retard
26
6%
Gratuit
Publié : 8 codes
4
Développeur 4
Évaluation
(11)
Projets
18
28%
Arbitrage
3
67% / 33%
En retard
1
6%
Gratuit
5
Développeur 5
Évaluation
(10)
Projets
4
0%
Arbitrage
11
0% / 82%
En retard
0
Gratuit
6
Développeur 6
Évaluation
(366)
Projets
465
23%
Arbitrage
50
60% / 20%
En retard
52
11%
Occupé
7
Développeur 7
Évaluation
(1)
Projets
1
0%
Arbitrage
1
0% / 0%
En retard
0
Gratuit
8
Développeur 8
Évaluation
(284)
Projets
458
39%
Arbitrage
94
44% / 18%
En retard
72
16%
Chargé
Publié : 2 codes
Commandes similaires
"I don’t just code bots – I engineer profit engines. Contact: quant.alpha@proton.me ✨ Why Traders Will Love It: ⚡ AI-Powered Decisions – Self-learning PPO model adapts to changing gold market conditions . ⚡ Military-Grade Risk Control – Auto position sizing, volatility filters, and instant circuit breakers . ⚡ Seamless MT5 Execution – Handles slippage, partial fills, and spread risks like a pro. ⚡ Proven Backtesting
I am looking for an experienced developer who can create a MetaTrader 5 (MT5) Expert Advisor (EA) based on a single TradingView indicator and a set of Buy/Sell conditions that I will personally share with you. Requirements: Convert the TradingView indicator (Pine Script) logic to a working MT5 EA Implement specific Buy and Sell conditions (I will provide exact rules) EA must include basic risk management options (Lot
I need a clean, simple EA for MT5 that consistently produces ~5% monthly return with moderate trade frequency (6–12 trades/week). - Must auto-compound or use risk-based lot sizing - Must include .mq5 source file , not just .ex5 - Must show backtest proof on 2 different pairs , preferably M30/H1 - Must be original or legally yours to transfer, this will be used in a broader structured trading setup I’m building I
Trading is journey not a destination every win and loss is stepping stone to greatness stay patient stay focused and keep learning our back through is just around the corner we won’t give up on dreams
Dbrain EA bot 100+ USD
import MetaTrader5 as mt5 import pandas as pd import numpy as np import time from datetime import datetime # --- CONFIGURATION --- ACCOUNT_ID = 12345678 # Replace with your MT5 account ID PASSWORD = "your_password" # Replace with your MT5 password SERVER = "your_broker_server" # e.g., "Exness-MT5server" SYMBOL = "EURUSD" TIMEFRAME = mt5.TIMEFRAME_H1 # 1-hour timeframe (adjust as needed) INITIAL_CAPITAL = 10000.00 #
To develop EA algo on GBPUSD on MT5 Client will provide the necessary indicator which will plot Daily pivots on the chart. PFA screenshot attached for details of job work
I am looking for a professional expert advisor developer to build my EA (MT4 and MT5). The first thing that I need is screenshot of the work to make sure the developer can Done my project. I need to make sure that the developer fully understood my Strategy and could do it. So the developer should start the job and proof ability to finish the job then we will go ahead to make contract. So I need a good developer with
Description de la stratégie de trading : Bot de trading ULTIMATE AI Smart Money Concept (SMC) Aperçu: J'ai besoin du robot de trading IA ultime, conçu pour mettre en œuvre une stratégie de trading Smart Money Concept (SMC) axée sur l'identification des configurations de trading à forte probabilité en fonction de la structure du marché, des blocs d'ordres et de l'évolution des prix. Ce robot vise à capitaliser sur le
Trading Strategy Description: ULTIMATE AI Smart Money Concept (SMC) Trading Bot Overview: i need The ULTIMATE AI trading bot that is designed to implement a Smart Money Concept (SMC) trading strategy that focuses on identifying high-probability trading setups based on market structure, order blocks, and price action. The bot aims to capitalize on institutional trading behavior by analyzing price movements and
GOLD KILLER 1099+ USD
TELL ME SELL OR BUY DON’t BLOW ACCOUNT. THE ROBOT IS FAST ON TAKING TRADING ON MONDAY AND CPI NFP AND EVEY THING I WILL NOT SELL THE BOT ITS FREE

Informations sur le projet

Budget
30 - 60 USD
Pour le développeur
27 - 54 USD
Délais
de 1 à 3 jour(s)