Alteration to EA | Placing a pending order with a button push.

MQL4 Indicators Experts Forex

Job finished

Execution time 1 minute
Feedback from employee
Thank you!
Feedback from customer
Very quick, professional, an definitely worth the money. :)

Specification

I have an EA which is supposed to place a pending order with the push of a button, & an execution price at the open of the current bar.

The button functions works perfectly, the parameters within the pending order work flawlessly, the dynamic pricing displayed in button which changed on every tick is perfect. 

However, when I push the button to initiate a pending order, sometimes nothing happens. It prints a "success" message into the Journal, but no Pending order appears in the ledger. Other times, it places a pending order with no problem.

Whenever I use this on a new chart, the prices are not updated either. The execution prices is some random price. I even changed the chart from the EURUSD to the EURJPY - completely different pricing structure, and it as telling me that the entry price on the pending order for the EURJPY was a price formatted to a 5 decimal place price.  I have tried refresh rates, but to no avail. See illustration for case in point.

   Incorrect Pricing in Ledger

Here is my coding, and I have also attached the files if you wanted to recreate this as well.

I need someone who can alter the code to ensure that I do not get sporadic prices, and that it actually places a pending order every time, and not just it feels like it. 

//+------------------------------------------------------------------+
//|                                                      manStat.mqh |
//|                        Copyright 2022, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property strict

#include <global_declarations.mqh> 


void manualStaticButtons(){

currentBid     =  Bid;
currentAsk     =  Ask;
currentSpread  =  sqrt(MathPow((currentBid - currentAsk)/Point,2)); 

ObjectCreate(0,"manBuy",OBJ_BUTTON,0,0,0); 
        
   ObjectSetInteger(0,"manBuy",OBJPROP_XDISTANCE,880);
   
      ObjectSetInteger(0,"manBuy",OBJPROP_YDISTANCE,580);
      
         ObjectSetInteger(0,"manBuy", OBJPROP_YSIZE, 40);
         
            ObjectSetInteger(0,"manBuy", OBJPROP_XSIZE, 200);
      
               ObjectSetInteger(0,"manBuy", OBJPROP_CORNER,CORNER_LEFT_UPPER);
      
                  ObjectSetInteger(0,"manBuy", OBJPROP_COLOR,clrWhite);
                                                            
                     ObjectSetInteger(0,"manBuy", OBJPROP_FONTSIZE,10);
               
                        ObjectSetInteger(0,"manBuy", OBJPROP_BGCOLOR,clrGreen);
                        
                           ObjectSetString(0,"manBuy", OBJPROP_TEXT,"Market Order "+DoubleToString(currentBid,Digits)); 
                           
                              ObjectSetInteger(0,"manBuy",OBJPROP_STATE,false); 
                        
                           
                     
                     
ObjectCreate(0,"manSell",OBJ_BUTTON,0,0,0); 
        
   ObjectSetInteger(0,"manSell",OBJPROP_XDISTANCE,1150);
   
      ObjectSetInteger(0,"manSell",OBJPROP_YDISTANCE,580);
      
         ObjectSetInteger(0,"manSell", OBJPROP_YSIZE, 40);
         
            ObjectSetInteger(0,"manSell", OBJPROP_XSIZE, 200);
      
               ObjectSetInteger(0,"manSell", OBJPROP_CORNER,CORNER_LEFT_UPPER);
      
                  ObjectSetInteger(0,"manSell", OBJPROP_COLOR,clrWhite);
                                                            
                     ObjectSetInteger(0,"manSell", OBJPROP_FONTSIZE,10);
               
                        ObjectSetInteger(0,"manSell", OBJPROP_BGCOLOR,clrRed);
                        
                           ObjectSetString(0,"manSell", OBJPROP_TEXT,"Market Order "+DoubleToString(currentAsk,Digits));
                           
                              ObjectSetInteger(0,"manSell",OBJPROP_STATE,false); 
                               
                                              
ObjectCreate(0,"spread",OBJ_LABEL,0,0,0); 
        
   ObjectSetInteger(0,"spread",OBJPROP_XDISTANCE,1105);
   
      ObjectSetInteger(0,"spread",OBJPROP_YDISTANCE,585);
      
         ObjectSetInteger(0,"spread", OBJPROP_YSIZE, 40);
         
            ObjectSetInteger(0,"spread", OBJPROP_XSIZE, 60);
      
               ObjectSetInteger(0,"spread", OBJPROP_CORNER,CORNER_LEFT_UPPER);
      
                  ObjectSetInteger(0,"spread", OBJPROP_COLOR,clrBlack);
                                                            
                     ObjectSetInteger(0,"spread", OBJPROP_FONTSIZE,20);
               
                        ObjectSetString(0,"spread", OBJPROP_TEXT,DoubleToString(currentSpread,0)); 

}
//+------------------------------------------------------------------+
//|                                                         demo.mq4 |
//|                        Copyright 2022, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

#include <manStat.mqh>
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int      pendingExpiration          = Period() * 60;
double   candleOpenPrice            = iOpen(NULL,0,0);
double   pendingOrderExecPrice      = NormalizeDouble(candleOpenPrice,Digits); 
datetime candleOpenTime             = Time[0];
string   pendingError               = IntegerToString(GetLastError(),0);


int OnInit()
  {

   return(INIT_SUCCEEDED);
  }

void OnTick()
  {

   manualStaticButtons();


   
  }
  
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam){

   lastErrorCode = IntegerToString(GetLastError());
            
      if(id == CHARTEVENT_OBJECT_CLICK){
      
         if(sparam == "manBuy"){
         
            RefreshRates();
         
            if(!OrderSend(Symbol(),OP_BUYSTOP,1,pendingOrderExecPrice,0,0,0,NULL,1,candleOpenTime + pendingExpiration,clrNONE)){
                  
               Print("Error "+pendingError); 

            }
               
            else {
                     
               Print("Success");

            }
            
         }
         
         if(sparam == "manSell"){
         
            RefreshRates();
            
               if(!OrderSend(Symbol(),OP_SELLSTOP,LotSize,pendingOrderExecPrice,0,0,0,NULL,1,candleOpenTime + pendingExpiration,clrNONE)){
                                                                  
                  Print("Error "+pendingError);  
               
               } else {
                   
                   Print("Success");      
   
               }

         }
         
         
      }
  
}


Files:

MQH
manStat.mqh
3.3 Kb
MQ4
demo.mq4
2.3 Kb
EX4
demo.ex4
24.5 Kb

Responded

1
Developer 1
Rating
(204)
Projects
209
28%
Arbitration
0
Overdue
3
1%
Free
2
Developer 2
Rating
(298)
Projects
427
26%
Arbitration
18
61% / 33%
Overdue
26
6%
Free
Similar orders
I have a indicator, mql file. The signals are seen below on a EURNZD H1 chart. Very important to get accurate entries. The signal to trade is the first tic after the the indicator signal paints. I've tried to demonstrate that below. Other than that the EA will have a lot size escalation, an on-screen pip counter, a button to stop taking new trades, SL/TP, and magic number. I would like the indicator to be within the
I would like to create an EA based on the Shved Supply and Demand indicator. you can find the Shved Supply and Demand v1.7 indicator in the following link https://www.mql5.com/en/code/29395 NB: Checks the trading robot must pass before publication in the Market ( https://www.mql5.com/en/articles/2555 ) MQ5 file to be provided
Hi Guys, I am looking to someone that can generate an indicator for MT4 as explained below. Basically I would need that the indicator point out the price that will close my position in stop out/margin call. The indicator should pick automatically the level of trade out for the broker (which can be different from a broker to another broker) It should write (ideally on the bottom on the left) the following information
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
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 am looking for an experienced MQL5 developer to help me finalize and optimize an Expert Advisor (EA) for the FTMO challenge. I have already built a significant portion of the code, but it requires further refinement and optimization to ensure it functions according to the trading strategy I intend to use. I am happy to share all the resources, including the current code, reference materials, and detailed
dreams good and have a great Cash out from your smart phone , tuyoywuiy glamorous flood see full idk idk slow so dolls stupid sis workouts who's spark koalas oral waits also doggo idk

Project information

Budget
90+ USD
For the developer
81 USD
Deadline
to 3 day(s)