Editing my EA. 6 new conditions

MQL4 Indicadores Experts

Trabalho concluído

Tempo de execução 16 dias
Comentário do cliente
Super!!!! Did great job , will definitely use again , very knowledgeable and patient ,..☺️👍👍👍👍👍👍

Termos de Referência

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);
                    }
                }
            }
        }
    }
}

Arquivos anexados:

Respondido

1
Desenvolvedor 1
Classificação
(10)
Projetos
9
11%
Arbitragem
5
0% / 60%
Expirado
1
11%
Livre
Pedidos semelhantes
Job Title: Experienced MT5 Developer Needed to Update MT5 EA PLEASE READ THE ENTIRE JOB DESCRIPTION BEFORE APPLYING Qualifications Required: * Minimum of 5 years of experience in coding Expert Advisors * Experience with at least 150 completed EA projects (must be visible on your profile) * Must have knowledge of both forex trading and coding, as these are different skills * Fluent in English (no translators) * Must
I have a fully coded TradingView indicator that I need updated to function as a strategy. This should include the ability to backtest the strategy using the TradingView strategy tester. The main task is to convert the existing indicator into a strategy format while maintaining its core functionality, but adapting it for automated trading logic and performance analysis. Please ensure that the strategy uses proper
I'm looking for professional developer for long term. Who have skill in Converting trading to MT4/5. Also have good knowledge of Algo. And response and deliver tools on time and at the top need good communication. That's all we need
budget of 500 usd I want to create a rsi bot for eur usd money is the least important thing I want it to look good if you are going to apply do it but send me at least 3 photos or screenshots of this type of work with rsi bot my goal level 50 sell level 20 buy that's all it must have its basic robot functions
I have simple EA i want to modify its parameters. If you are good at modifying EAs contact me for more details. I will issue the source code then you return after finishing without changing the buy or sell conditions
the code wasn't mine, i have got it somewhere on the web, but i like the performance of the EA, so i want to use it on mt5 platform. the given code based on price movements with ladder entry concept
* Advanced level dev only, NDA required * Hi, I have a multi timeframe, multiindicator expert that requires additional features added to it. First started development 5 years ago. Upgrading with new features. To be added Entry - Add Stochastic and CCI options for trade entry to be added to existing signal options. Add config options to existing menu Bulk Exit - Master switch for close all trades based on basket
I am developing a master EA that integrates several sub-EAs. The project is complex, and the documentation is thoroughly structured, spanning 50 pages with detailed step-by-step procedures. 1st sub-EA: This EA opens trades without using indicators. Instead, it opens a new trade based on the color or status of the last candle. For instance, if the last candle was green, a new buy trade is opened. 2nd sub-EA: This EA
Good Day I would like to order a trading robot. Pairs: XAUUSD (GOLD) EUR/USD USD/JPY The robot should be trading daily with TP/SL build in, would like to have trailing and stop loss, should execute up to 5 trades (preffarable setting choice) up to 10 trades Los sizes to be choise setting, must also trade major US vews events Like:US- PPI, CPI, NFP, Sales m/m and so on Must also show/display alert when opening
Hello Guys, I need a trading bot for the MT5 to place order based on my trading strategy which is based on - >> entry based on EMA with rejection from specific levels like support and resistance area - levels and time frame i will apply into the robot manually on daily basis. also need - trailing stoploss , shift to breakeven after gaining some points. need a highly expert developer

Informações sobre o projeto

Orçamento
30 - 90 USD
IVA (21%): 6.3 - 18.9 USD
Total: 36.3 - 108.9 USD
Desenvolvedor
27 - 81 USD
Prazo
de 1 para 4 dias