Modify an Expert Advisor so it will trade

MQL4 Indicators Experts Forex

Job finished

Execution time 3 minutes
Feedback from customer
I am fairly new to all this and was amazed with the skill and patience from my developer. I will always use him in the future.
Feedback from employee
Thank you very much!

Specification

I created an EA online through EA Builder.com, but it will not initiate any trades. I keep receiving an error stating:  "OrderSend error #4051 invalid function parameter value" and "invalid lots amount for OrderSend function".I have tried every lot size I can think of, but I still get this same error message.

Here is what I want this EA to be able to do:

1.  I want to be able for it to initiate a trade, long and/or short in the lot size I can specify.

2.  I want to be able to set trading times of day in 30 minute intervals.  For example, I can turn the system on at 4pm and stop initiating trades at 6pm.

3.  That's All!


Here is the current EA that I am using that will not initiate any trades:

//+------------------------------------------------------------------+
//|                                         Strategy: RJS QQE EA.mq4 |
//|                                       Created with EABuilder.com |
//|                                        https://www.eabuilder.com |
//+------------------------------------------------------------------+
#property copyright "Created with EABuilder.com"
#property link      "https://www.eabuilder.com"
#property version   "1.00"
#property description ""

#include <stdlib.mqh>
#include <stderror.mqh>

int LotDigits; //initialized in OnInit
int MagicNumber = 1532634;
extern double TradeSize = 0.1;
int MaxSlippage = 3; //adjusted in OnInit
bool crossed[1]; //initialized to true, used in function Cross
bool Push_Notifications = true;
int MaxOpenTrades = 1;
int MaxLongTrades = 1;
int MaxShortTrades = 1;
int MaxPendingOrders = 1;
int MaxLongPendingOrders = 1;
int MaxShortPendingOrders = 1;
bool Hedging = false;
int OrderRetry = 5; //# of retries if sending order returns error
int OrderWait = 5; //# of seconds to wait if sending order returns error
double myPoint; //initialized in OnInit

bool Cross(int i, bool condition) //returns true if "condition" is true and was false in the previous call
  {
   bool ret = condition && !crossed[i];
   crossed[i] = condition;
   return(ret);
  }

void myAlert(string type, string message)
  {
   if(type == "print")
      Print(message);
   else if(type == "error")
     {
      Print(type+" | RJS QQE EA @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
      if(Push_Notifications) SendNotification(type+" | RJS QQE EA @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
     }
   else if(type == "order")
     {
      Print(type+" | RJS QQE EA @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
      if(Push_Notifications) SendNotification(type+" | RJS QQE EA @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
     }
   else if(type == "modify")
     {
     }
  }

int TradesCount(int type) //returns # of open trades for order type, current symbol and magic number
  {
   int result = 0;
   int total = OrdersTotal();
   for(int i = 0; i < total; i++)
     {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false) continue;
      if(OrderMagicNumber() != MagicNumber || OrderSymbol() != Symbol() || OrderType() != type) continue;
      result++;
     }
   return(result);
  }

int myOrderSend(int type, double price, double volume, string ordername) //send order, return ticket ("price" is irrelevant for market orders)
  {
   if(!IsTradeAllowed()) return(-1);
   int ticket = -1;
   int retries = 0;
   int err = 0;
   int long_trades = TradesCount(OP_BUY);
   int short_trades = TradesCount(OP_SELL);
   int long_pending = TradesCount(OP_BUYLIMIT) + TradesCount(OP_BUYSTOP);
   int short_pending = TradesCount(OP_SELLLIMIT) + TradesCount(OP_SELLSTOP);
   string ordername_ = ordername;
   if(ordername != "")
      ordername_ = "("+ordername+")";
   //test Hedging
   if(!Hedging && ((type % 2 == 0 && short_trades + short_pending > 0) || (type % 2 == 1 && long_trades + long_pending > 0)))
     {
      myAlert("print", "Order"+ordername_+" not sent, hedging not allowed");
      return(-1);
     }
   //test maximum trades
   if((type % 2 == 0 && long_trades >= MaxLongTrades)
   || (type % 2 == 1 && short_trades >= MaxShortTrades)
   || (long_trades + short_trades >= MaxOpenTrades)
   || (type > 1 && type % 2 == 0 && long_pending >= MaxLongPendingOrders)
   || (type > 1 && type % 2 == 1 && short_pending >= MaxShortPendingOrders)
   || (type > 1 && long_pending + short_pending >= MaxPendingOrders)
   )
     {
      myAlert("print", "Order"+ordername_+" not sent, maximum reached");
      return(-1);
     }
   //prepare to send order
   while(IsTradeContextBusy()) Sleep(100);
   RefreshRates();
   if(type == OP_BUY)
      price = Ask;
   else if(type == OP_SELL)
      price = Bid;
   else if(price < 0) //invalid price for pending order
     {
      myAlert("order", "Order"+ordername_+" not sent, invalid price for pending order");
   return(-1);
     }
   int clr = (type % 2 == 1) ? clrRed : clrBlue;
   while(ticket < 0 && retries < OrderRetry+1)
     {
      ticket = OrderSend(Symbol(), type, NormalizeDouble(volume, LotDigits), NormalizeDouble(price, Digits()), MaxSlippage, 0, 0, ordername, MagicNumber, 0, clr);
      if(ticket < 0)
        {
         err = GetLastError();
         myAlert("print", "OrderSend"+ordername_+" error #"+IntegerToString(err)+" "+ErrorDescription(err));
         Sleep(OrderWait*1000);
        }
      retries++;
     }
   if(ticket < 0)
     {
      myAlert("error", "OrderSend"+ordername_+" failed "+IntegerToString(OrderRetry+1)+" times; error #"+IntegerToString(err)+" "+ErrorDescription(err));
      return(-1);
     }
   string typestr[6] = {"Buy", "Sell", "Buy Limit", "Sell Limit", "Buy Stop", "Sell Stop"};
   myAlert("order", "Order sent"+ordername_+": "+typestr[type]+" "+Symbol()+" Magic #"+IntegerToString(MagicNumber));
   return(ticket);
  }

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {  
   //initialize myPoint
   myPoint = Point();
   if(Digits() == 5 || Digits() == 5)
     {
      myPoint *= 10;
      MaxSlippage *= 10;
     }
   //initialize LotDigits
   double LotStep = MarketInfo(Symbol(), MODE_LOTSTEP);
   if(NormalizeDouble(LotStep, 5) == round(LotStep))
      LotDigits = 0;
   else if(NormalizeDouble(10*LotStep, 5) == round(10*LotStep))
      LotDigits = 1;
   else if(NormalizeDouble(100*LotStep, 5) == round(100*LotStep))
      LotDigits = 5;
   else LotDigits = 5;
   int i;
   //initialize crossed
   for (i = 0; i < ArraySize(crossed); i++)
      crossed[i] = true;
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
  }

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   int ticket = -1;
   double price;  
  
  
   //Open Buy Order, instant signal is tested first
   if(Cross(0, iCustom(NULL, PERIOD_CURRENT, "QQE averages histo + alerts + arrows", 1, 5, 14, 0, 4.236, 70, 30, "Alerts Settings", false, false, true, false, false, false, true, false, "alert2.wav", true, "qqe Arrows1", 1.5, false, DeepSkyBlue, Red, 233, 234, 1, 1, true, DeepSkyBlue, Red, 233, 234, 3, 3, 3, 0) > iCustom(NULL, PERIOD_CURRENT, "QQE averages histo + alerts + arrows", 1, 5, 14, 0, 4.236, 70, 30, "Alerts Settings", false, false, true, false, false, false, true, false, "alert2.wav", true, "qqe Arrows1", 1.5, false, DeepSkyBlue, Red, 233, 234, 1, 1, true, DeepSkyBlue, Red, 233, 234, 3, 3, 4, 0)) //QQE averages histo + alerts + arrows crosses above QQE averages histo + alerts + arrows
   )
     {
      RefreshRates();
      price = Ask;  
      if(IsTradeAllowed())
        {
         ticket = myOrderSend(OP_BUY, price, TradeSize, "");
         if(ticket <= 0) return;
        }
      else //not autotrading => only send alert
         myAlert("order", "");
     }
  }

Responded

1
Developer 1
Rating
(191)
Projects
232
30%
Arbitration
1
100% / 0%
Overdue
9
4%
Free
2
Developer 2
Rating
(139)
Projects
181
24%
Arbitration
23
22% / 39%
Overdue
13
7%
Free
3
Developer 3
Rating
(166)
Projects
189
10%
Arbitration
37
38% / 35%
Overdue
5
3%
Loaded
4
Developer 4
Rating
(185)
Projects
190
27%
Arbitration
0
Overdue
3
2%
Free
5
Developer 5
Rating
(188)
Projects
212
58%
Arbitration
9
11% / 89%
Overdue
8
4%
Free
6
Developer 6
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
7
Developer 7
Rating
(126)
Projects
151
48%
Arbitration
6
83% / 17%
Overdue
2
1%
Free
8
Developer 8
Rating
(54)
Projects
53
17%
Arbitration
7
0% / 100%
Overdue
5
9%
Free
9
Developer 9
Rating
(33)
Projects
49
12%
Arbitration
16
0% / 88%
Overdue
10
20%
Free
10
Developer 10
Rating
(66)
Projects
143
34%
Arbitration
11
9% / 55%
Overdue
26
18%
Working
11
Developer 11
Rating
(250)
Projects
401
38%
Arbitration
82
41% / 20%
Overdue
70
17%
Loaded
12
Developer 12
Rating
(23)
Projects
45
20%
Arbitration
24
29% / 42%
Overdue
12
27%
Working
13
Developer 13
Rating
(53)
Projects
72
43%
Arbitration
21
14% / 67%
Overdue
8
11%
Free
14
Developer 14
Rating
(2387)
Projects
2997
65%
Arbitration
76
47% / 14%
Overdue
340
11%
Free
15
Developer 15
Rating
(769)
Projects
1033
44%
Arbitration
50
8% / 50%
Overdue
117
11%
Free
16
Developer 16
Rating
(21)
Projects
29
21%
Arbitration
8
63% / 13%
Overdue
9
31%
Free
17
Developer 17
Rating
(86)
Projects
114
26%
Arbitration
7
29% / 57%
Overdue
5
4%
Free
18
Developer 18
Rating
(48)
Projects
80
28%
Arbitration
8
75% / 13%
Overdue
41
51%
Free
19
Developer 19
Rating
(7)
Projects
8
63%
Arbitration
1
0% / 100%
Overdue
1
13%
Free
20
Developer 20
Rating
(33)
Projects
46
59%
Arbitration
0
Overdue
6
13%
Free
21
Developer 21
Rating
(557)
Projects
924
48%
Arbitration
301
59% / 25%
Overdue
123
13%
Loaded
Similar orders
I hope this message finds you well. I am currently seeking an experienced MQL developer to work on a project that involves modifying an existing trading robot and creating a new version with specific enhancements and customizations. I have the source code of a trading robot that I would like to modify. Requirements: Experience with MQL4 and MetaTrader 4 platform. Strong understanding of trading algorithms and
Indicator for mql4 40 - 80 USD
I am looking for a programmer who can write a MQL4 indicator from scratch. The indicator should generate buy and sell signals. More information will be added in the comments
I want someone who is really skilled at making zigzag indicators,because I want a zigzag that does not ignore any zigzag that occurs. Please, if you are a beginner, do not offer me an offer. I want someone skilled in zigzag indicators. Very important: I do not want the dull methods that beginners use to draw zigzags
I want someone who is really skilled at making zigzag indicators,because I want a zigzag that does not ignore any zigzag that occurs. Please, if you are a beginner, do not offer me an offer. I want someone skilled in zigzag indicators. Very important: I do not want the dull methods that beginners use to draw zigzags
I need someone to help me convert my tradingview pinescript to mt4, my budget for this project is $20 and I need this done fast in two days, Also, I am going to need you to be able to build a new indicator because that's the nest project, But I need to know if you can do this first , Thank you
Hi, I have a trading strategy and would like to convert it into a MT5 or MT4 trading bot. It involves a pinescript indicator and some simple indicators. The pinescript indicator is called SuperBollingerTrend (Expo) written by Zeiierman in TradingView. Can you look at the code and see if you can convert it to MT5/4? I only need the part of the script which gives the Zigzag signal (arrow up and arrow down signals). The
Revesal trend 30 - 50 USD
I have 3 indicators here i would like to become one, they are all mq4 files, two will be the trend and one will give the arrow, i have already present them as how they should in 'input' i have image here showing what i want
I want an indicator that will generate signal based on technical analysis/market analysis, order blocks (demand and supply), and should be able to show arrows for buy and sell after analyzing the direction of the market. It should also be able to show if a signal is strong or weak. In case the signal is rejected, it should show an X sign
The task is as follows: Create and EA, preferably in python, that can connect to MT5 (via API), with the following criteria: -Scans a multitude of triangular currency pairs (EUR/USD, USD/JPY, EUR/JPY as an example), and finds differences between the implied rate via the use of two currencies, ie in the example case EUR/USD*USD/JPY, and the actual rate. -Takes positions in a market neutral nature (short/long postions)
I'm looking to make some edits to an existing pinescript indicator. I created a quick 5 minute video that showcases what I need. Please let me know when you have taken a look at it and how quickly you can complete this. Looking for a quick turnaround, today would be great

Project information

Budget
100+ USD
For the developer
90 USD
Deadline
to 1 day(s)