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

MQL4 指标 专家 外汇

工作已完成

执行时间1 一分钟
员工反馈
Thank you!
客户反馈
Very quick, professional, an definitely worth the money. :)

指定

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");      
   
               }

         }
         
         
      }
  
}


附加的文件:

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

反馈

1
开发者 1
等级
(258)
项目
268
29%
仲裁
1
100% / 0%
逾期
3
1%
已载入
发布者: 2 代码
2
开发者 2
等级
(298)
项目
427
26%
仲裁
18
61% / 33%
逾期
26
6%
空闲
发布者: 8 代码
相似订单
Hi, I Wanne have a trading robot that give me signals for short buy and sell. And only for all currency in forex trading and also can use it on mt5
I will pay 2500 to 10000 USD (negotiable) for one MT5 Expert Advisor, built properly. One robot done right, not a batch of cheap jobs. I have a strategy I believe in and a rough draft robot I built myself. The logic is there. The execution is not. That last part is outside my expertise, which is why I am hiring instead of continuing on my own. I am open to feedback on the strategy itself. If you see something in it
I Have an existing Mql5 Expert advisor (source code), I want a professional programmer to help me Modify the EA... so that it can stop taking new trades once it Gets to a Pacific Lots Size or Floating loss
I Have an existing Mql5 Expert advisor (source code), I want a professional programmer to help me Modify the EA... so that it can stop taking new trades once it Gets to a Pacific Lots Size or Floating loss
Hi, can you define entry conditions based on 100 or 200 trades? If you need more history, i can give you more trades. It is EURUSD with great results! If you can do it, contact me
Wise Legend 30 - 500 USD
I want this robot to alert me on a good entry point on the trading flat form ether to buy or to sell. And also alert me when to close the market. And alert me on market continuations
I have an existing MT5 Expert Advisor with the original MQ5 source code. I need an experienced MQL5 developer to review, debug and professionally improve the existing EA, not build an unrelated EA from scratch. The EA is mainly for XAUUSD and already contains entry signals, EMA filters, automatic lot sizing, basket profit management, spread/margin protection, news filtering and recovery logic. The main problem is the
I buy EA for USDEUR or XAUUSD for FTMO with proven backtest. Send me images with backtest reports where daily max dd is 1% on 200k account. I can buy several eas if you have them with proofs. Need images of backtesting for 5 years
I am looking for a programmer that can develop an MT4 indicator that shows COT DATA For Forex, indices and and metals. The indicator must be an oscillator or any other form that would work well in that format. It doesn't need to show all pairs at once, it can show only for current chart. Let's talk
Cerco uno sviluppatore MQL5 esperto per lavorare su un Expert Advisor (EA) XAUUSD per MetaTrader 5 già esistente , versione attuale XAU_V59.mq5 . L'obiettivo è modificare, correggere e sviluppare il codice esistente senza stravolgere la logica già presente , mantenendo le regole ei parametri già definiti, salvo le modifiche espressamente richieste. REQUISITI FONDAMENTALI Il codice deve essere scritto in MQL5 nativo e

项目信息

预算
90+ USD
截止日期
 3 天