Editing my EA. 6 new conditions

İş tamamlandı

Tamamlanma süresi: 16 gün
Müşteri tarafından geri bildirim
Super!!!! Did great job , will definitely use again , very knowledgeable and patient ,..☺️👍👍👍👍👍👍

İş Gereklilikleri

Good day,
I would like to edit my EA. Add new conditions and edit existing ones.

In the appendix you will find Word where all the new 6 conditions for trading are described. And EA alone.

It is very important that it is clear at the outset after reading the code how EA works and that you are able to fully understand the functionality of EA and then add and edit new conditions.

_

If alert window with phrase “nesprávná hodnota arg-point” shows up, you have to maximise the window and copy paste the value from this row to the EA set_up.

 

New conditions – it should be possible to turn on and turn off each point:

 

1.     Max orders on “Target profit”

Maximal number of consecutive profitable positions (positions closed on Target profit).

In set_up we enter number x, meaning “Max orders on Target profit”. When x positions are closed on Target profit, EA doesn´t open new positions that day (till 0:00) or according to time set up in trading session.

2.     Trading session 2 - Another time block (from 9-11 / 17-19)

One is already in EA and I would like to have another one, so EA could trade in more time zones.

3.     Information panel column on the left

-       ID Magic Number

-        Total profit - Information on the total profit from the chart. I can trade one underlying asset in multiple charts, each chart has its own magic number. It is therefore not the sum of all profits on the underlying asset, but on one chart, ie on one magic number. In currency of trading account. This is not reseted.

-        Total profit in % = 100*(Total profit / Balance). This is not reseted.

-        Consecutive TP – TP is Target profit. Number of positions closed on Target Profit (consecutive), ie number of consecutive Target Profit for one magic number. This number is reseted once we reach Stop Loss.

-        Max consecutive TP – the max number of consecutive target profits. This is not reseted, number can be only higher.

Example:

Max consecutive TP“ the higest number of consecutive Target profits.
Example: I get 2 consecutive TP, then I get Stop loss (in this moment „
Max consecutive TP“ is 2). Then I get 7 consecutive TP, then I get Stop loss (in this moment „Max consecutive TP“ is 7). Then I get 4 consecutive TP, then I get Stop loss (in this moment „Max consecutive TP“ is still 7).

-        Max TP on MN – how many times we reached Target profit (this number is not reseted). When we reach TP, “Max TP on MN” increases by 1.

-        Total drawdown - Information on the total dwawdown from the chart. In currency of trading account. This is not reseted.

-        Total drawdown in % - 100*(Total drawdown / Balance). This is not reseted.

-        Consecutive SL – SL is Stop loss. Number of positions closed on Stop loss (consecutive), ie number of consecutive Stop loss for one magic number. This number is reseted once we reach Target profit.

-        Max consecutive SL – the max number of consecutive Stop loss. This is not reseted, number can be only higher.

Example:

Max consecutive SL“ the higest number of consecutive Stop losses.
Example: I get 2 consecutive SL, then I get Target profit (in this moment „
Max consecutive SL“ is 2). Then I get 7 consecutive SL, then I get Target profit (in this moment „Max consecutive SL“ is 7). Then I get 4 consecutive SL, then I get Target profit (in this moment „Max consecutive SL“ is still 7).

-        Max SL on MN - how many times we reached Stop loss (this number is not reseted). When we reach SL, “Max SL on MN” increases by 1.

-        Market conditions (Spread, Swap)

-       Trading plan

o   Max Consecutive Loss Allowed (information from set_up)

o   TP and SL (information from set_up)

o   Max future drawdown

§  Here you can see calculation of Max future drawdown:

Equation: SL/TP=”coefficient”  

SL2=SL*”coefficient”

SL3=SL2*”coefficient”

SL4=SL3*”coefficient”

Sum of these SLs (according to “Max Consecutive Loss Allowed”)=Max future drawdown in pips. We need to recalculate this to currency of trading account and show in graph.

o   Max future drawdown in % =100*(Max future drawdown/Balance)

 

The displayed text must be displayed in its entirety in the graph in all resolutions - or I can choose the text size in the set up.

 

 

4.     Breakeven – shown in graph

Breakeven” is shown as line in the graph, line colour is adjustable.

Following step, when the price is already 10% from TP of recovery position, Stop Loss is set up to 0,1% minus (so in case of execution of this little minus EA would open recovery position again and not position according to basic set up due to swaps and commissions).

When market price is 5% from Target Profit, “Breakeven” moves to new value (BE=sum of previous loss + commissions + swap).

You can find equations also in excel “rovnice_Equations”

Example:
So we can for use 100/2 = 50

Total loss 1500

So if profit=1550

BE=1500

Another example

If total loss = 100(a bit higher with swap and commission)

BE step=100/2 = 50

If profit = 100+50 = 150

BE= 150

Tp=200

Another one

Total loss 300

Total profit 400

400-300 = 100

So

100/2 = 50

If profit = 350

BE = 300

 

5.     Shifting the sum of consecutive candles for the next corrected position. (Shift of sum of consecutive candles for next recovery position)

In set_up, we use following condition:

"Numbers of Candles to check" (already in code).

New condition “MAX next of candles to check” (turned on / off) increases number of consecutive candles by 1, when position is opened immediately after closure of loss positions.

Example: “Number of candles to check” is set up to 1. When I get Stop Loss, new position is opened automatically after 2 candles. Now when I get Stop Loss, new position is opened after 3 candles and so on.

Of course, we need one new condition “MAX next candles to check” (we enter number in here) – this number defines max number of consecutive candles (when number of consecutive candles+1 is reached, no new position is opened).  

(More info in code – “Number of Candles to check”)

 

Example: In set_up:

Number of Candles to check: 1

MAX next of candles to check: 3

Max Consecutive Loss Allowed: 3

-        First position is opened after one candle – this position is closed on Stop Loss. When we get first Stop Loss, we need 2 consecutive candles so new position is opened. In case this second position is also closed on Stop Loss, we need now 3 consecutive candles so new position is opened. This position is the last one (when it is closed again on Stop Loss), because we set up sum of max. consecutive Stop Losses.

 

If “Max Consecutive Loss Allowed” is 5 and “Max next of candle to check” is 3:

-        EA opens new position after 3 consecutive candles.

 

 

 

 

When I get Target Profit, EA starts open positions again from the beginning according to set_up.

 

BUT: My position is closed on Stop Loss and it seems that conditions for opening new position in the same direction will be met (it means new position needs to have the same direction as the last one closed position, not opposite direction!), new position is opened immediately (according to set_up “Number of Candles to check” and others) and doesn´t wait for another candle according to “MAX next of candles to check”. It should be possible to turn on / off this condition.

 

Start new start:

-        This is a new condition – in case we reach condition “Max Consecutive Loss Allowed”, EA starts trading from the beginning according to set_up.

-        Max Consecutive Loss Allowed” – it is maximum of positions closed on Stop Loss. When we meet this condition, we have to edit Magic number manually, so EA can start trading again according to set_up.

-        Start new start” should replace this manual edit – if “Start new start” is active and we reach “Max Consecutive Loss Allowed”, Magic number is edited automatically and EA starts trading again from the beginning according to set_up.

 

 

 

It is important so we don´t loose anything in the code, everything should work as it worked till now. New conditions are in addition to the existing ones. Example: they should cooperate with time blocks for trading, it should be possible to use indicators etc.  


Sample code:


//--- New Candle Filter
   bool IsNewBar=Time[0]>Candle_Time;


    // ============================== Entries ==============================

    if (AllowTrading && IsNewBar && Count(0)+Count(1)==0 && (UseTF==false || IsGoodTime(TradeStartTime,TradeEndTime)))
      {
       int CustomIndicatorDirection = -1;
       
       if (CustomeIndicatorName != "")
       {
         double value = iCustom(Symbol(), Period(), CustomeIndicatorName, CustomIndicatorBuffer, 1);
         
         if (value < CustomIndicatorMiddleLevel)
            CustomIndicatorDirection = OP_SELL;
         else
            CustomIndicatorDirection = OP_BUY;
       }
       
       if(Bull_Count()>=CandleCount)
         {
          if (CustomeIndicatorName == "" || CustomIndicatorDirection == OP_BUY)
            if (NewOrderAllowed())
               sendMarketOrder(TRADEDIR_LONG);
            
          Candle_Time=Time[0];
         }
       else if(Bear_Count()>=CandleCount)
        {
         if (CustomeIndicatorName == "" || CustomIndicatorDirection == OP_SELL)
            if (NewOrderAllowed())
               sendMarketOrder(TRADEDIR_SHORT);
            
         Candle_Time=Time[0];
        }
      }

}

//+------------------------------------------------------------------+
//| Open Orders Counting Function                                    |
//+------------------------------------------------------------------+
int Count(int Type)
  {
   int count=0;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      bool Select=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(Select && OrderSymbol()==_Symbol && OrderMagicNumber()==MagicNumber && OrderType()==Type)
         count++;
     }
   return (count);
  }
//+------------------------------------------------------------------+
//| Previous Bullish Candles Counting Function                       |
//+------------------------------------------------------------------+
int Bull_Count()
  {
   int count=0;
   for(int i=1; i<Bars; i++)
     {
      if(Close[i]>Open[i]) count++;
      if(Close[i]<Open[i]) break;
     }
   return (count);
  }
//+------------------------------------------------------------------+
//| Previous Bearish Candles Counting Function                       |
//+------------------------------------------------------------------+
int Bear_Count()
  {
   int count=0;
   for(int i=1; i<Bars; i++)
     {
      if(Close[i]<Open[i]) count++;
      if(Close[i]>Open[i]) break;
     }
   return (count);
  }
//+------------------------------------------------------------------+
//| Time Filter Function                                             |
//+------------------------------------------------------------------+
bool IsGoodTime(string StartTime,string EndTime)
  {
   bool goodtime=false;
   datetime tradestarttime=StringToTime(StartTime);
   datetime tradeendtime=StringToTime(EndTime);
   
   if(tradeendtime>tradestarttime) goodtime=(TimeCurrent()>=tradestarttime && TimeCurrent()<tradeendtime);
   else if(tradestarttime>tradeendtime && tradeendtime<=TimeCurrent() && tradestarttime>TimeCurrent()) goodtime=false;
   else goodtime=true;

   return(goodtime);
  }
// ====================================================================
// Helper methods
// ====================================================================

bool existsOpenPosition(int &out_ticket) {
    out_ticket = -1;
    
    for (int i = OrdersTotal() - 1; i >= 0; i--) {
        if (selectOurOrder(i, SELECT_BY_POS, MODE_TRADES) &&
                    isBuyOrSell(OrderType())) {
            out_ticket = OrderTicket();
            return true;
        }
    }
    return false;
}

bool isLossSequence(int &out_cnt, double &out_pl, double &out_avgCommissionPerLot) {
    out_cnt = 0;
    out_pl = out_avgCommissionPerLot = 0.0;
    
    CArrayInt openTimes;
    CArrayDouble profits, swaps, commissions, lots;
    collectLossSequence(OrdersTotal(), MODE_TRADES, openTimes, profits, swaps, commissions, lots);
    collectLossSequence(OrdersHistoryTotal(), MODE_HISTORY, openTimes, profits, swaps, commissions, lots);
    if (profits.Total() > 0) {
        out_cnt = profits.Total();
        double sumLots = 0.0;
        for (int i = 0; i < openTimes.Total(); i++) {
            out_pl += profits[i] + swaps[i] + commissions[i];
            sumLots = lots[i];
        }
        out_avgCommissionPerLot = out_pl / sumLots;
        return true;
    }
    return false;
}

bool insertNewestFirst(CArrayInt &openTimes, const datetime openTime,
                       CArrayDouble &pls, const double pl,
                       int &out_insertPos) {
    out_insertPos = -1;

    // keeping just a single positive P/L in the array and that one at the end (if there is any positive P/L)
    // ... keeping the openTime and P/L entries order by the openTime    
    for (out_insertPos = 0; out_insertPos < openTimes.Total(); out_insertPos++) {
        // checking inserting to the front of the current stored openTime
        if (openTime > openTimes[out_insertPos]) {
            openTimes.Insert((int)openTime, out_insertPos);
            pls.Insert(pl, out_insertPos);
            return true;
        }
        // potentially replacing the current element if the time is identical and the P/L is positive and higher
        if (openTime == openTimes[out_insertPos] && pl > 0.0 && pl > pls[out_insertPos]) {
            openTimes.Insert((int)openTime, out_insertPos);
            pls.Insert(pl, out_insertPos);
            return true;
        }
        // not inserting anything if we are at a stored positive P/L (... and the given openTime is at-or-after the stored openTime)
        if (pls[out_insertPos] > 0.0) {
            out_insertPos = -1;
            return false;
        }
    }
    // reaching this point means that we didn't find any stopper so inserting to the end
    openTimes.Add((int)openTime);
    pls.Add(pl);
    return true;
}

void collectLossSequence(const int orderCount, const int orderPool,
                         CArrayInt &openTimes, CArrayDouble &profits, CArrayDouble &swaps,
                         CArrayDouble &commissions, CArrayDouble &lots) {
    datetime openTime;
    double profit, swap, commission, pl;
    int insertIndex;
    bool added;
    CArrayDouble pls;
    for (int i = orderCount; i >= 0; i--) {
        if (selectOurOrder(i, SELECT_BY_POS, orderPool) &&
                    isBuyOrSell(OrderType())) {
            // we want to keep the last element as profit (or loss if no later profits where encountered)
            openTime = OrderOpenTime();
            profit = OrderProfit();
            swap = OrderSwap();
            commission = OrderCommission();
            pl = profit + swap + commission;
            added = insertNewestFirst(openTimes, openTime, pls, pl, insertIndex);
            if (added) {
                if (insertIndex >= profits.Total()) {  // adding the elements to the end
                    profits.Add(profit);
                    swaps.Add(swap);
                    commissions.Add(commission);
                    lots.Add(OrderLots());
                } else {
                    profits.Insert(profit, insertIndex);
                    swaps.Insert(swap, insertIndex);
                    commissions.Insert(commission, insertIndex);
                    lots.Insert(OrderLots(), insertIndex);
                }
                if (pl > 0.0) {
                    for (int di = openTimes.Total(); di > insertIndex; di--) {
                        openTimes.Delete(di);
                        pls.Delete(di);
                        profits.Delete(di);
                        swaps.Delete(di);
                        commissions.Delete(di);
                        lots.Delete(di);
                    }
                }
            }
        }
    }
}

Dosyalar:

Yanıtlandı

1
Geliştirici 1
Derecelendirme
(10)
Projeler
9
11%
Arabuluculuk
5
0% / 60%
Süresi dolmuş
1
11%
Serbest
Benzer siparişler
Just have a let down by previous coder. (Andrii) please dont apply for this one. Coder with low Metrix please dont apply : High Arbitrage/Low reviews/High Overdue I will just avoid This is a long-term Project You ll have to continue work on the source file done so far, there might be bug to fix and continue the work as needed. What be involve: Grid system Dashboard Indicaotor Addon Setting/Logic enhancement News
Experts mt5 30 - 50 USD
I need a programmer to create an MT5 robot, putting my strategy inside it, send me a message if you are interested! The robot will be based on averages making purchases and sales together
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
Hello, my budget is 30$, I need MT5 EA send alert to telegram: 1. Send alert if any position volume by magic number more than: for example, 0.25 lot, send position symbol name and positions not all positions just the positions are more than 0.25 lot volume and positions trade comment and send Custom comment: I entered it manually in input menu. 2. Send alert if I have open positions by magic number in
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
I’m looking for a skilled MQL5 developer to build an MT5 Expert Advisor that mirrors inverse trades (Buy ↔ Sell) from a prop firm challenge account (demo) to a live hedge account . Core Requirements: Open and close opposite trades in real-time Dynamic lot sizing based on account balances (Objective: recover approx. $500 if the challenge account fails) Support for multiple symbols , including: XAUUSD, NAS100, BTCUSD
Hi, I’m looking for an experienced MQL5 or AI trading systems developer who can build a scalable, beginner-friendly forex trading network . The system should include: Fully automated trading logic (AI-enhanced or rule-based) MT5 (or MT4 if needed) compatibility A beginner dashboard with simplified controls A structure that supports onboarding of multiple traders (eventually multi-asset) Key modules like performance
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
I need someone who can provide metatrader4/5 restful api. And I want restful and websockets. we need to use metatrader api in our app for statistics and trade copying. Apply only if you have the necessary qualifications and experience for this project
I need a highly disciplined, low-risk EA for MT4/MT5 that trades only when 100% strategy conditions are met. It must include multi-timeframe trend logic, support/resistance rejection, BOS/CHoCH detection from real swing levels, and a breakout strategy with trailing SL. EA should scan all major pairs (from one chart), trade only during 07:00–16:00 GMT, and skip trades 2 hours before major news. Max 1 trade per pair

Proje bilgisi

Bütçe
30 - 90 USD
KDV (21%): 6.3 - 18.9 USD
Toplam: 36.3 - 108.9 USD
Geliştirici için
27 - 81 USD
Son teslim tarihi
from 1 to 4 gün