Fix issue EA mql4

MQL5 Uzmanlar

İş tamamlandı

Tamamlanma süresi: 1 gün
Müşteri tarafından geri bildirim
very good and fast
Geliştirici tarafından geri bildirim
Thank you very much, super customer!

İş Gereklilikleri

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

Yanıtlandı

1
Geliştirici 1
Derecelendirme
(588)
Projeler
1065
50%
Arabuluculuk
39
28% / 41%
Süresi dolmuş
49
5%
Serbest
Yayınlandı: 1 makale, 8 kod
2
Geliştirici 2
Derecelendirme
(188)
Projeler
212
58%
Arabuluculuk
9
11% / 89%
Süresi dolmuş
8
4%
Serbest
3
Geliştirici 3
Derecelendirme
(225)
Projeler
285
41%
Arabuluculuk
15
13% / 47%
Süresi dolmuş
67
24%
Serbest
4
Geliştirici 4
Derecelendirme
(574)
Projeler
945
47%
Arabuluculuk
309
58% / 27%
Süresi dolmuş
125
13%
Serbest
Benzer siparişler
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
This is yakubu Jnr trading bots I create the trading robots to help my self and others traders to be successful please you can join my live trading bots or subscribe to my trading robots
Nyasco 90+ USD
Fast trading bot for starters less losses which leads to bigger profits made for thousands of people making billions of dollars .be the best trader for your self all the way
Nyasco 30+ USD
Faster robot with less losses which can be used for a long term earning money every day creating a bot for more than thousands of people to earn billions of money
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
I will pay 3000+ USD (negotiable) for an EA for existing MT5 that generates a minimum of 15-20% or higher a month consistently (provide source code after final deal) Looking for a highly profitable EA Please send demo version directly subject (Buying profitable EA Budget up to $ 3000 USD), past results and optimal settings so I can test, if it performs in a strategy tester i will also need option to forward test it
EA fx 30+ USD
Hello, I need an already developed EA similar to the one trading XAUUSD, with consistent entries and good risk management. Before we proceed, I would like to verify its performance. Please provide a live or demo account login along with the investor (read-only) password so I can monitor the trading results. I am looking for stable performance, controlled drawdown, and consistent profit on gold (XAUUSD). Once I
The strategy records the highest and lowest prices within a specified duration (default 15 minutes) after the New York market opens, forming the opening range. Post-Formation Breakout: When the price breaks above or below the opening range after its formation, it may indicate the direction of the day’s price movement. Trend Confirmation: The strategy uses two EMAs (default 20-period and 50-period) as trend filters to

Proje bilgisi

Bütçe
30 - 200 USD
Son teslim tarihi
to 10 gün