Fix issue EA mql4

MQL5 Experten

Auftrag beendet

Ausführungszeit 1 Tag
Bewertung des Kunden
very good and fast
Bewertung des Entwicklers
Thank you very much, super customer!

Spezifikation

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

Bewerbungen

1
Entwickler 1
Bewertung
(586)
Projekte
1048
49%
Schlichtung
39
28% / 41%
Frist nicht eingehalten
49
5%
Frei
2
Entwickler 2
Bewertung
(188)
Projekte
212
58%
Schlichtung
9
11% / 89%
Frist nicht eingehalten
8
4%
Frei
3
Entwickler 3
Bewertung
(225)
Projekte
284
42%
Schlichtung
15
13% / 47%
Frist nicht eingehalten
67
24%
Frei
4
Entwickler 4
Bewertung
(564)
Projekte
933
47%
Schlichtung
302
59% / 25%
Frist nicht eingehalten
125
13%
Beschäftigt
Ähnliche Aufträge
I want grate robot for making profits that know when to start a good trade and close a trade and must be active all time to avoid lost of money
I have developed a very strong TradingView strategy in Pine Script but unfortunately, a third-party connector is requiired and in my opinion, I want a more direct connection. I am not brilliant at coding, but I have coded the majority of the MT5 code and I would like you to make sure that the MT5 code matches my TradingView script and executes the same way as the TradingView script that I will provide if you are
Mbeje fx 50+ USD
I like to own my robot that why I want to build my own.i like to be a best to every robot ever in the life to be have more money
I need an MT5 EA that can do the following: I have to give the EA a price in advance, when the price is reached the EA has to automatically place a buy stop or sell stop order 0.5 pips below or above the price. Is this possible
Dr Pattern 30+ USD
good day i need the service of the seaso coder to help me fix my ea The Job required 1 knowledge of Mt4 and Mt5 indicator coding 2. Telegram code 3. ability to code indicator to work on multiple Time frame combine to trade 4 Ability to Join two or three indicator on same ir different time frame if you have these skill please let chart i will discuss the details of the Job inside to you The required day including
Good day, I want someone to help me create a universal news filter with on/off switch, with start and end settings, and drawdown control with magic number of EAs, etc. Thanks
Hello, I am looking for a professional programmer to optimize my existing EA integrating it with ChatGPT to analyze currencies using various methods to make the right trading decisions. i want it to be an EA that can be trusted to carry trade with the help of chat gpt and also have a very low drawdown
Hello, I am looking for a professional programmer to create a trading expert on the MT4 platform, integrating it with ChatGPT to analyze currencies using various methods to make the right trading decisions. Further details will be provided to the applicants later
I have developed a very strong TradingView strategy in Pine Script but unfortunately, a third-party connector is requiired and in my opinion, I want a more direct connection. I am not brilliant at coding, but I have coded the majority of the MT5 code and I would like you to make sure that the MT5 code matches my TradingView script and executes the same way as the TradingView script that I will provide if you are
EA based on RSI and MA 100 - 400 USD
Program is based on RSI and MA indicators dynamic as triggers, for Open/Close criteria. Runs automatically but inputs can be updated manually. It uses a GUI to manage it. Multi TF analysis. Log register of every operation for analysis (db) Open Source deliver. Kindly apply IF you have previous experience with trading and mql/python/c bot/algo developing. And if you have a good track record . ps: Better if you have a

Projektdetails

Budget
30 - 200 USD
Für die Entwickler
27 - 180 USD
Ausführungsfristen
bis 10 Tag(e)