Fix issue EA mql4

MQL5 Experts

Job finished

Execution time 1 day
Feedback from customer
very good and fast
Feedback from employee
Thank you very much, super customer!

Specification

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

Responded

1
Developer 1
Rating
(586)
Projects
1045
49%
Arbitration
39
28% / 41%
Overdue
49
5%
Free
2
Developer 2
Rating
(188)
Projects
212
58%
Arbitration
9
11% / 89%
Overdue
8
4%
Free
3
Developer 3
Rating
(224)
Projects
283
42%
Arbitration
15
13% / 47%
Overdue
67
24%
Free
4
Developer 4
Rating
(555)
Projects
922
48%
Arbitration
300
59% / 25%
Overdue
123
13%
Working
Similar orders
MT4 EA 30+ USD
I have project for expert developer here.. The task is to make the EA take trades using the indicator upper line and the lower line to take trades. When the upper line appears on the chart I need the EA to take a sell at that point. Then when the lower line shows up I need the seel trade to close. The same concept applies for the lower line. I need the EA to take a buy trade when the lower line appears and close when
News field 30+ USD
I am in need of a custom EA news filter for my trading platform, and I believe your expertise in this field can greatly assist me. Below are the specifications for the filter: 1. It should be implemented as a boolean function, returning either true or false. 2. The filter must automatically detect currency pairs. 3. Three hours before and after any significant news events pertaining to each currency in the pair, the
Hello, I would like to ask who would perform a backtest + optimization on my existing EA ? The EA works mainly on two pairs. Thank you for your reply. Sincerely Martin
I need someone to create an MA crossover EA. This program should be able to trade the crosses. We would be using the MA indicators to make decisions about buying and selling stocks or other assets. The MA crossover would help me invest my money more effectively by automatically executing trades based on these indicators. If you can create this program, please let me know as I am interested in working with you
the idea of the bot is to trade based on trend. we are going to use 5 different sma( smoothed moving average). they are sma7,sma20, sma50, sma100 and sma200. the bot will look for only buy trades when all the smas are facing up. the bot will look for only sell trades when all the smas are facing down. when we are in a up trend, the bot will look to enter trades on bullish candles that create fvg. if there is an fvg
Topx 80+ USD
1)I need EA with on/off button per currency and buttons to control lots size, auto change of currency with time, Dashboard of 4 indicators (Bollinger, Currency strength, FVG and Gann ) and trade management. Entry: When buy is clicked, the EA draws a line. After x pips market move away from the line or when price moves to given price line and or time, the EA opens buy order if clicked/selected indicators align. Set
I'm looking for an experienced developer to make some modifications to my MT4 Currency Strength Table indicator. Key Requirements: - I would like to have the add on feature of delta or the difference of the strength of currencies displayed in the new table and showing as B or S of only the one currency pair when the delta or difference arises. the delta will change values as the difference of strength of compared
I need Spike DETECTOR EA for Boom and Crash.. which will send me notification or alerts when spike is near. The EA should also be able be buy on crash Index and sell on Boom Index depending on the market..Demo may be provided for faster execution of my order
· I need an MT5 EA that trades on Currencies, Indices, Metals, Crypto, Commodities and Deriv Synthetic Indices. · It should trigger trades on the Moving average cross above or below of the RSI levels in the same window. It should have a Trailing stop and break even input variables. Please note that I only want to use the RSI levels and not its period hence the RSI period will be set to 1. Also the
ODSMART EA 30 USD
I want an EA developed from this strategy that will buy and sell based on the appearance of these colours. Blue-buy (Enter when the signal indicator is at zero on the blue background) Red -sell( Enter when the signal indicator is at 100) White and brown, exit trade

Project information

Budget
30 - 200 USD
For the developer
27 - 180 USD
Deadline
to 10 day(s)