Fix issue EA mql4

MQL5 Эксперты

Работа завершена

Время выполнения 1 день
Отзыв от заказчика
very good and fast
Отзыв от исполнителя
Thank you very much, super customer!

Техническое задание

Hello,

 

i have 1 issue with my stop loss, when the order is passed, there is 1 case where the stop loss does not activate.

The case is :

For short position :

- when the order is passed and the entry is below the close of the bar, the stop loss is not activated

For long position :

- when the order is passed and the entry is above the close of the bar, the stop loss is not activated

here the exit code :

input int InpNormalizeDouble = 4;
input int atrlength = 48;
double vAtr;
 vAtr = iATR(NULL,0,atrlength,0);
input double factorSL = 1.00; 

//--- it is important to enter the market correctly, but it is more important to exit it correctly...   
      for(cnt=0;cnt<total;cnt++)
        {
         if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
            continue;
         if(OrderType()<=OP_SELL &&   // check for opened position 
            OrderSymbol()==Symbol())// && // check for symbol
           {
            //--- long position is opened
            if(OrderType()==OP_BUY)
              {
              //Print(""+OrderMagicNumber());
                 switch(OrderMagicNumber())
                 {
                  case 1:
                   //int mtime = iBarShift(_Symbol, 0, OrderOpenTime());
                   //iClose(_Symbol,0,0)
                   //iTime(_Symbol,0,0)
                   //if((bRegHigh1 < High[0] && xbars1L < xNumberbars) || bRegHigh1 == 0)
                   //{
                   //  bRegHigh1 = High[0];
                   //  xbars1L++;
                   //}
                    bRegHigh1 = HHsinceEntry(OrderOpenTime());
                    //exitpriceL1 = NormalizeDouble(bRegHigh1 - (bRegHigh1 *(vAtr / OrderOpenPrice())*1.55),InpNormalizeDouble);
                    exitpriceL1 = bRegHigh1 - (bRegHigh1 *(vAtr / OrderOpenPrice())*factorSL);
                    //Print("bRegHigh1: "+bRegHigh1);
                    //Print("exitpriceL1: "+exitpriceL1);
                    //Print("vAtr: "+vAtr);
                    //Print("OrderOpenPrice(): "+OrderOpenPrice());
                    //Print("===============================================");
                      if(MathAbs(Close[0]-OrderOpenPrice())>MathAbs(exitpriceL1-OrderOpenPrice()))
                       {
                        if(OrderStopLoss()<exitpriceL1 || OrderStopLoss()==0)
                          {
                          //pips = profit / PipValuePerLot;
                          //NormalizeDouble(pips,1)
                           //--- modify order and exit
                           //Print("OrderModifyL: "+exitpriceL1);
                           //if(!OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green))
                           if(!OrderModify(OrderTicket(),OrderOpenPrice(),exitpriceL1,OrderTakeProfit(),0,Green))
                              Print("OrderModify error",GetLastError());
                           return;
                          }
                       }
                  break;
               
                 }
               
              }
            else // go to short position
              {
              
                 switch(OrderMagicNumber())
                 {
                  case 1:
                  
                  //if((sRegLow1 > Low[0] && xbars1S < xNumberbars) || sRegLow1 == 0)
                  //{
                  //   sRegLow1 = Low[0];
                  //   xbars1S++;
                  //}
                  //Print("sRegLow1: "+sRegLow1);
                     //exitpriceS1 = NormalizeDouble(sRegLow1 + (sRegLow1 *(vAtr / OrderOpenPrice())*1.55),InpNormalizeDouble);
                     sRegLow1 = LLsinceEntry(OrderOpenTime());
                     
                     exitpriceS1 = sRegLow1 + (sRegLow1 *(vAtr / OrderOpenPrice())*factorSL);
                     Print("sRegLow1: "+sRegLow1);
                     Print("exitpriceS1: "+exitpriceS1);
                     Print("vAtr: "+vAtr);
                     Print("OrderOpenPrice(): "+OrderOpenPrice());
                     Print("===============================================");
                      if(MathAbs(OrderOpenPrice()-Close[0])>MathAbs(OrderOpenPrice()-exitpriceS1))
                       {
                       
                        if(OrderStopLoss()>exitpriceS1 || OrderStopLoss()==0)
                          {
                          //Print("OrderModifyS: "+exitpriceS1);
                          //Print("OrderOpenPrice()-Close[0]: "+(OrderOpenPrice()-Close[0]));
                          //Print("OrderOpenPrice()-exitpriceS1: "+(OrderOpenPrice()-exitpriceS1));
                           //--- modify order and exit
                           //if(!OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red))
                           if(!OrderModify(OrderTicket(),OrderOpenPrice(),exitpriceS1,OrderTakeProfit(),0,Red))
                              Print("OrderModify error",GetLastError());
                           return;
                          }
                       }
                  break;
                 }
              }
           }
           else
           {
            bRegHigh1 = 0;
            
            sRegLow1 = 0;
         
           }
        }
     }
  }
//+------------------------------------------------------------------+


and below the variable to know bRegHigh1  and  sRegLow1 :

double HHsinceEntry(datetime)
{
   //datetime    OOT         = OrderOpenTime();          // Assumes OrderSelect() done already
   int         iOOT        = iBarShift(Symbol(),Period(),OrderOpenTime(), false);   // Bar of the open.
   #define     iBarBuy   0                        // Include current bar.
   int         nSince  = iOOT + 1;       // No. bars since open.
   int         iHi         = iHighest(Symbol(),Period(), MODE_HIGH, nSince, iBarBuy);
   double      HH = iHigh(Symbol(), Period(), iHi);
   // Highest high.iHi give the number of the bar with highest price.High[] return price high of the bar
   return HH;
}

double LLsinceEntry(datetime)
{
   //datetime    OOT         = OrderOpenTime();          // Assumes OrderSelect() done already
   int         iOOT        = iBarShift(Symbol(),Period(),OrderOpenTime(), false);   // Bar of the open.
   #define     iBarSell   0                         // Include current bar.
   int         nSince  = iOOT + 1;       // No. bars since open.
   int         iLi         = iLowest(Symbol(),Period(), MODE_LOW, nSince, iBarSell);
   double      LL = iLow(Symbol(), Period(), iLi);
   // Lowest low. 
   return LL;
}


i attach a screenshot for the short position



Price is nego in case


tom

Откликнулись

1
Разработчик 1
Оценка
(588)
Проекты
1065
50%
Арбитраж
39
28% / 41%
Просрочено
49
5%
Свободен
Опубликовал: 1 статью, 8 примеров
2
Разработчик 2
Оценка
(188)
Проекты
212
58%
Арбитраж
9
11% / 89%
Просрочено
8
4%
Свободен
3
Разработчик 3
Оценка
(225)
Проекты
285
41%
Арбитраж
15
13% / 47%
Просрочено
67
24%
Свободен
4
Разработчик 4
Оценка
(574)
Проекты
945
47%
Арбитраж
309
58% / 27%
Просрочено
125
13%
Свободен
Похожие заказы
Criei um Robô para a venda alta precisão que automatiza a estratégia de correção média de Larry Williams. Possui filtros de tendência seletiva, controle de lote por risco percentual e execução rápida. Compatível com contas Hedge e Netting. Configuração simples e otimizada para mercados de alta volatilidade. *55(16) 993786056
SMC ORDER BLOCK 30 - 60 USD
I want already build FULLY AUTOMATED order block MT5 XAUUSD HTF H4 ENTRY LTF M15 - Show result on live account. m15 ob entry in the direction of h4 ob bias the developper to provide source code in the end
I need an MT5 Expert Advisor built as a high-precision volumizer for Forex. Its core purpose is to generate controlled trading volume for rebates, while still maintaining low-risk account growth. I am not looking for aggressive profit chasing. I am looking for a stable, intelligent EA that can produce volume in a disciplined way without damaging the account. The ideal system should trade major currency pairs, avoid
1. IF price forms: - Higher highs + higher lows → TREND = BUY - Lower highs + lower lows → TREND = SELL ELSE → NO TRADE 2. IF: - Trend = BUY - Price retraces to support zone - Bullish engulfing candle forms - TDI green crosses above red (optional) THEN: - Execute BUY 3. IF: - Trend = SELL - Price retraces to resistance - Bearish engulfing forms - TDI confirms THEN: - Execute SELL 4. Risk per trade = 1% of account Lot
I need a high frequency trading robot for gold in one or 5 minute timeframe the robot should have spread filter where it should only open trades below a set spread should have news filter to allow trading during fundal news or not the robot should have input in number of minutes to close all open trades and remove pending orders before fundamental news as part of news filter. It should also have the number of minutes
Hello! I want to programm EA that uses volume profile indicator, but I am not sure if this is possible. Only experienced programmers please, I will not select a programmer who did only few jobs. Before starting I need to make sure you understand everything and that this is for sure technically possible
Hello, I am looking for a professional trading system including: 1- Trading Bot (Expert Advisor): - Good profit performance - High security and strong risk management - Works efficiently during high market volatility (news and strong movements) - Works on all pairs (Forex + Gold) 2- Signal Indicator: - Provides clear Buy and Sell signals - Includes Take Profit and Stop Loss - No repaint (signals must not change or
Hi, I’m looking for a top-tier, profit-optimized EA that has the potential to scale trading returns significantly. My goal is to maximize growth over time. Can you help develop a bespoke EA that could potentially scale to high six or seven figures
Max amount grid 30+ USD
max amount grid step for magic number do keep deleting .only when it is in negative floating .but when it is profit allow to go over the max and replays to grid step
Apply with a screen of your work . Symbol Specific Logic . Live Chart Optimization Check the Core logic . [back tests as well] Change points to pips . Create buffer for the zone

Информация о проекте

Бюджет
30 - 200 USD
Сроки выполнения
до 10 дн.