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
preciso de um robô com duas médias móveis, uma exponencial high e uma exponencial low. preciso também ter a opção de utilizar e todos os tempos gráficos e alterar os parâmetros das médias. entrada de compra será feita quando um candle de alta romper e fechar a cima da média high e fechará a posição quando um candle de baixa romper e fechar a baixo da média low. a venda será feita quando o candle de baixa romper e
Greetings, As the title suggests, I am trying to convert an indicator that calls itself via an iCustom call like this. iMAArray_Buffer[loop_1] = iCustom ( NULL , Selected_TF, MQLInfoString ( MQL_PROGRAM_NAME ), "calculate" , RPeriod, MType, MPeriod, 1 , shift); Full code will not be provided, only the position that needs fixing. I cannot get this working in MQL5 but the original code runs smoothly in MQL4. Please
I need a chart to replicate/track my equity + Balance Curve into my mt4. Also this chart i need to be able to add Stochastic / Bollingerband / Moving average on the equity/balance curve. Besides the equity curve i would like the indicator to show the Line-chart of my win + 1 and my loss -1 which results in a win-loss curve. ( i will discuss this with the choosen developer in depth. ) More information on what i want
Greetings great developer, I am in search of a highly skilled developer to assist with an exciting project. I need to convert two open-source TradingView indicators to NinjaTrader 8 and implement a usage restriction based on computer IDs. If you have experience with NinjaTrader 8 coding please let me know. I’d be happy to discuss the details further
Hello, This is pretty simple and its an indicator with On/Off button 1-Off will remove all indicator from the chart. 2-On will put them all back again with the same settings
Trading bot 300+ USD
We need bot that trades when medium and low impact news hits It will release pending order both directions few min prior to news impact And will have certain risk management strategy attached Example If Monday and Tuesday news successful clears profits It will reduce risk for next news events until new week starts each week message on tg: Dstatewealthtrading NOTE: 4 YAERS OF EXPERIENCE UPWORD, YOU MUST BE A
I need someone the create a supertrend indicator based on Heikin Ashi candles instead of normal candles. Needs to be exactly the same as the supertrend (original one) + ha from tradingview. In m1,m5,m15 the indicator must have the same values ​​found with the tradingview. Work that meets this requirement will be accepted ( depending on the broker and spread, however, a few pips of difference will be accepted)
Here is a detailed instruction for the coder to implement the vertical lines based on the BrainTrainSignalAlert indicator: --- **Task: Implement Vertical Lines for Alerts from BrainTrainSignalAlert Indicator** **Objective:** Create a system that adds vertical lines on specified timeframes (M5 or M30) whenever an alert is generated by the BrainTrainSignalAlert indicator on the H1, H4, and D1 timeframes. The lines
Hello Guys! I want to modify/fix the indicator that uses sequential type of entries (it calculates from 1 to 9) and if the conditions are met it provides an arrow (signal) with alert. The problem is that, sometimes (for unknown for me reasons) it repaints arrow signal. Like on the picture: Signal 1 - correct signal Signal 2 - correct signal Signal 3 - correct signal Signal 4 - repaints (signal 3 arrow dissapeared
Hi, I have a Live Data feature for my trading accounts that lets me check details like total open positions, number of lots, profits, etc. I need someone to add the number of pending orders to this live data. This is important for me to ensure that all accounts have the same number of pending orders, since I use a copy trading system. Also, there is a website where I check all the data. In this case, you would need

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