Need help with these buy and sell two orders script

Back to topics list To post a new topic, please log in or register
avatar
3
ecerejo 2015.02.02 13:34
 

These are two scripts to buy and sell two orders with the same stop loss of 15 pips when I compile the script I'm getting two warnings on lines 44 and 49 on both.

 return value of 'OrderSend' should be checked !Sell 2 Orders.mq4 44 19

function must return a value !Sell 2 Orders.mq4 49 14

I'm not a coder and I can't figure this out as to why I'm getting these warnings and I would appreciate if someone could fix this for me.

Also when the market is very volatile the sending of the second order and the placing of the stop loss might violate the FIFO rules, for example if the sell order is to place a stop of 15 pips for both orders and if the market is moving fast it might place the stop for the first at 1.5000 and the stop for the second order at 1.49998 and some broker will not place the second order.  So what I want is the stop for the second order to be the same as the first order all the time.  Here's the code for the sell and buy orders.

 

 Sell Order:

#property show_inputs

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

//parameternya ini, input-nya ini
extern double LOT = 0.30;
extern int    TP  =   16;
extern int    TP2 =   46;
extern int    SL  =   15;
//---------------------------
string        MySym    =     "";
int       MyDigits     =      5;
double    MyPoints     = 0.0001;


//+------------------------------------------------------------------+
//| Custom initialization function |
//+------------------------------------------------------------------+
int init()
  {
       MySym = Symbol();   
   MyPoints  = MarketInfo( MySym, MODE_POINT  );
   MyDigits  = MarketInfo( MySym, MODE_DIGITS );
   //---
        if( MyPoints == 0.001   ) { MyPoints = 0.01;   MyDigits = 3; }
   else if( MyPoints == 0.00001 ) { MyPoints = 0.0001; MyDigits = 5; }
   
   return(0);
  }
//+------------------------------------------------------------------+
// +
//+------------------------------------------------------------------+
int start()
{
    RefreshRates();
    while( IsTradeContextBusy() ) { Sleep(100); }
//----
     double Stop  = NormalizeDouble(Bid + (SL  * MyPoints),MyDigits);
     double Prof1 = NormalizeDouble(Bid - (TP  * MyPoints),MyDigits);
     double Prof2 = NormalizeDouble(Bid - (TP2 * MyPoints),MyDigits);
      
     int ticket = OrderSend(MySym,OP_SELL,LOT,Bid,NormalizeDouble(3 * MyPoints,MyDigits),Stop,Prof1,"contest",1,0,CLR_NONE);
                  OrderSend(MySym,OP_SELL,LOT,Bid,NormalizeDouble(3 * MyPoints,MyDigits),Stop,Prof2,"contest",2,0,CLR_NONE);
         if(ticket<1)
            {
             int error=GetLastError();
             Print("Error = ",ErrorDescription(error));
             return;
            }
//----
   OrderPrint();
return(0);
}

Buy Order:

#property show_inputs

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

//parameternya ini, input-nya ini
extern double LOT =   0.30;
extern int    TP  =   16;
extern int    TP2 =   46;
extern int    SL  =   15;
//---------------------------
string        MySym    =     "";
int       MyDigits     =      5;
double    MyPoints     = 0.0001;


//+------------------------------------------------------------------+
//| Custom initialization function |
//+------------------------------------------------------------------+
int init()
  {
       MySym = Symbol();   
   MyPoints  = MarketInfo( MySym, MODE_POINT  );
   MyDigits  = MarketInfo( MySym, MODE_DIGITS );
   //---
        if( MyPoints == 0.001   ) { MyPoints = 0.01;   MyDigits = 3; }
   else if( MyPoints == 0.00001 ) { MyPoints = 0.0001; MyDigits = 5; }
   
   return(0);
  }
//+------------------------------------------------------------------+
// +
//+------------------------------------------------------------------+
int start()
{
    RefreshRates();
    while( IsTradeContextBusy() ) { Sleep(100); }
//----
     double Stop  = NormalizeDouble(Ask - (SL  * MyPoints),MyDigits);
     double Prof1 = NormalizeDouble(Ask + (TP  * MyPoints),MyDigits);
     double Prof2 = NormalizeDouble(Ask + (TP2 * MyPoints),MyDigits);
      
     int ticket = OrderSend(MySym,OP_BUY,LOT,Ask,NormalizeDouble(3 * MyPoints,MyDigits),Stop,Prof1,"contest",1,0,CLR_NONE);
                  OrderSend(MySym,OP_BUY,LOT,Ask,NormalizeDouble(3 * MyPoints,MyDigits),Stop,Prof2,"contest",2,0,CLR_NONE);
         if(ticket<1)
            {
             int error=GetLastError();
             Print("Error = ",ErrorDescription(error));
             return;
            }
//----
   OrderPrint();
return(0);
}

 

I would appreciate could fix these two scripts for me.  Thank you
avatar
13010
WHRoeder 2015.02.02 16:45 #
 
ecerejo: I'm not a coder and I can't figure this out as to why I'm getting these warnings and I would appreciate if someone could fix this for me.
  1. learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
  2. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
  3.              Print("Error = ",ErrorDescription(error));
                 return;          << you get an error on this line
                }
    //----
       OrderPrint();
    return(0);                    << you don't get an error on this line
    What's the difference?
Back to topics list  

To add comments, please log in or register