SellPositionOpen(): OrderCheck(): Invalid request stops

 

I keep getting the below errors during execution of my EA code. Been digging around but can't seem to find figure this one out.  Thoughts?

2015.07.06 11:28:41.941    2015.03.27 22:14:59   SellPositionOpen(): OrderCheck(): Invalid request stops
2015.07.06 11:28:41.941    2015.03.27 22:14:59   SellPositionOpen(): Incorrect data for structure of trade request!
2015.07.06 11:28:41.941    2015.03.27 22:14:40   SellPositionOpen(): OrderCheck(): Invalid request stops
2015.07.06 11:28:41.941    2015.03.27 22:14:40   SellPositionOpen(): Incorrect data for structure of trade request!


//+------------------------------------------------------------------+
//|                                                           EA.mq5 |
//|                                              Master Forex © 2015 |
//|             https://www.mql5.com/en/users/Master_Forex/portfolio |
//+------------------------------------------------------------------+
#property copyright "Master Forex © 2015"
#property link      "https://www.mql5.com/en/users/Master_Forex/portfolio"
#property version   "1.00"
#include <TradeAlgorithms.mqh>
//+-------------------------------------------------+
//| Trade Parameters                                |
//+-------------------------------------------------+
input string             i_Trade_Settings    = "*** Trade Settings ***";        // 
input double             MM                  = 0.1;           // Lot Size    
input int                StopLoss_           = 30;            // Stop Loss in pips
input int                TakeProfit_         = 30;            // Take Profit in pips
input int                Deviation_          = 3;             // Slippage in pips
input bool               PosClose            = false;         // Close by Opposite Signal
input uint               SignalBar           = 1;             // Bar number for signal
//+-------------------------------------------------+
//| Indicator Parameters: SlopeDirectionLine        |
//+-------------------------------------------------+
input string             Indicators_Settings  = "*** RSI Settings ***"; // 
input int                RSIPeriod            = 14;            // RSI Period
input ENUM_APPLIED_PRICE InpAppliedPrice      = PRICE_CLOSE;   // Applied price 
input string             Indicators_Settings2 = "*** MA Settings ***";  // 
input int                MAPeriod1            = 5;             // MA 1 Period
input int                MAShift1             = 0;             // MA 1 Shift
input ENUM_MA_METHOD     MA_Mode1             = MODE_EMA;      // MA 1 Mode
input ENUM_APPLIED_PRICE InpAppliedPrice1     = PRICE_CLOSE;   // MA 1 appl.price
input int                MAPeriod2            = 10;            // MA 2 Period
input int                MAShift2             = 0;             // MA 2 Shift
input ENUM_MA_METHOD     MA_Mode2             = MODE_EMA;      // MA 2 Mode
input ENUM_APPLIED_PRICE InpAppliedPrice2     = PRICE_CLOSE;   // MA 2 appl.price
input int                MAPeriod3            = 50;            // MA 3 Period
input int                MAShift3             = 0;             // MA 3 Shift
input ENUM_MA_METHOD     MA_Mode3             = MODE_SMA;      // MA 3 Mode
input ENUM_APPLIED_PRICE InpAppliedPrice3     = PRICE_CLOSE;   // MA 3 appl.price
input int                MAPeriod4            = 100;           // MA 4 Period
input int                MAShift4             = 0;             // MA 4 Shift
input ENUM_MA_METHOD     MA_Mode4             = MODE_SMA;      // MA 4 Mode
input ENUM_APPLIED_PRICE InpAppliedPrice4     = PRICE_CLOSE;   // MA 4 appl.price
MarginMode MMMode = LOT; 
//+-------------------------------------------------+
int TimeShiftSec, InpInd_Handle,InpInd_Handle1,InpInd_Handle2,
InpInd_Handle3,InpInd_Handle4, min_rates_total;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {

   InpInd_Handle=iRSI(Symbol(),0,RSIPeriod,InpAppliedPrice);
   if(InpInd_Handle==INVALID_HANDLE)
     {
      Print(" Was not possible receive handle of the indicator RSI");
      return(INIT_FAILED);
     }  
//---      
   InpInd_Handle1=iMA(Symbol(),0,MAPeriod1,MAShift1,MA_Mode1,InpAppliedPrice1);
   if(InpInd_Handle1==INVALID_HANDLE)
     {
      Print(" Was not possible receive handle of the indicator MA");
      return(INIT_FAILED);
     }
//---      
   InpInd_Handle2=iMA(Symbol(),0,MAPeriod2,MAShift2,MA_Mode2,InpAppliedPrice2);
   if(InpInd_Handle2==INVALID_HANDLE)
     {
      Print(" Was not possible receive handle of the indicator MA");
      return(INIT_FAILED);
     } 
//---      
   InpInd_Handle3=iMA(Symbol(),0,MAPeriod3,MAShift3,MA_Mode3,InpAppliedPrice3);
   if(InpInd_Handle3==INVALID_HANDLE)
     {
      Print(" Was not possible receive handle of the indicator MA");
      return(INIT_FAILED);
     } 
//---      
   InpInd_Handle4=iMA(Symbol(),0,MAPeriod4,MAShift4,MA_Mode4,InpAppliedPrice4);
   if(InpInd_Handle4==INVALID_HANDLE)
     {
      Print(" Was not possible receive handle of the indicator MA");
      return(INIT_FAILED);
     }                       
//--- 
   TimeShiftSec=PeriodSeconds(0);
   TimeShiftSec=PeriodSeconds(0);
//--- 
   int LengthR=int(MathMax(MathSqrt(RSIPeriod),1));
   int LengthR2=int(MathMax(MathSqrt(RSIPeriod),1));

   min_rates_total+=int(2+SignalBar);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   GlobalVariableDel_(Symbol());
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- 
   if(BarsCalculated(InpInd_Handle)<min_rates_total) return;
//--- 
   LoadHistory(TimeCurrent()-PeriodSeconds(0)-1,Symbol(),0);
   LoadHistory(TimeCurrent()-PeriodSeconds(0)-1,Symbol(),0);

   static bool Recount=true;
   static bool BUY_Open=false,BUY_Close=false;
   static bool SELL_Open=false,SELL_Close=false;
   static datetime UpSignalTime,DnSignalTime;
   static CIsNewBar NB;
   double Val[3], Val1[3], Val2[3], Val3[3], Val4[3];

   if(NB.IsNewBar(Symbol(),0) || Recount || NB.IsNewBar(Symbol(),0)) 
     {
      //--- 
      BUY_Open=false;      SELL_Open=false;
      BUY_Close=false;     SELL_Close=false;
      Recount=false;
      
      //--- 
      if(CopyBuffer(InpInd_Handle,0,SignalBar,1,Val)<=0) {Recount=true; return;}
      //--- 
      if(CopyBuffer(InpInd_Handle1,0,SignalBar,1,Val1)<=0) {Recount=true; return;}
      //--- 
      if(CopyBuffer(InpInd_Handle2,0,SignalBar,1,Val2)<=0) {Recount=true; return;}
      //--- 
      if(CopyBuffer(InpInd_Handle3,0,SignalBar,1,Val3)<=0) {Recount=true; return;}
      //--- 
      if(CopyBuffer(InpInd_Handle4,0,SignalBar,1,Val4)<=0) {Recount=true; return;}
      //---
      
      if(Val[0]>50 && Val1[0]>Val2[0] && Val3[0]>Val4[0] && Val1[0]>Val3[0] && Val2[0]>Val3[0])
        {
         if(Val[0]!=0 && Val1[0]!=0 && Val2[0]!=0 && Val3[0]!=0 && Val4[0]!=0) BUY_Open=true;
         if(PosClose) SELL_Close=true;
         UpSignalTime=datetime(SeriesInfoInteger(Symbol(),0,SERIES_LASTBAR_DATE))+TimeShiftSec;
        }
      //--- 
      if(Val[0]<50 && Val1[0]<Val2[0] && Val3[0]<Val4[0] && Val1[0]<Val3[0] && Val2[0]<Val3[0])
        {
         if(Val[0]!=0 && Val1[0]!=0 && Val2[0]!=0 && Val3[0]!=0 && Val4[0]!=0) SELL_Open=true;
         if(PosClose) BUY_Close=true;
         DnSignalTime=datetime(SeriesInfoInteger(Symbol(),0,SERIES_LASTBAR_DATE))+TimeShiftSec;
        }
     }
//+------------------------------------------------------------------+     
//--- Close Long
   BuyPositionClose(BUY_Close,Symbol(),Deviation_);
//--- Close Short   
   SellPositionClose(SELL_Close,Symbol(),Deviation_);
//--- Open Long
   BuyPositionOpen(BUY_Open,Symbol(),UpSignalTime,MM,MMMode,Deviation_,StopLoss_,TakeProfit_);
//--- Open Short
   SellPositionOpen(SELL_Open,Symbol(),DnSignalTime,MM,MMMode,Deviation_,StopLoss_,TakeProfit_);
//---  
}  
//+------------------------------------------------------------------+
 
so where exactly are TP and SL calculated?
 
Marco vd Heijden:
so where exactly are TP and SL calculated?

TradeAlgorithms.mqh

https://www.mql5.com/en/code/1578

TradeAlgorithms
TradeAlgorithms
  • votes: 33
  • 2013.03.12
  • Nikolay Kositsin
  • www.mql5.com
Trade functions library designed for use in the code of scripts and Expert Advisors depending on a broker
 
bool BuyPositionOpen
(
    bool &BUY_Signal,          // deal permission flag
    const string symbol,       // deal's trading pair
    const datetime &TimeLevel, // time after which the following deal after the current deal will be performed
    double Money_Management,   // MM
    int Margin_Mode,           // way of lot value calculation
    uint deviation,            // slippage
    int StopLoss,              // Stop Loss in points
    int Takeprofit             // Take Profit in points
);
is in points.
 
oh how i wish i knew coding...:)
 
Francis Dogbe:
oh how i wish i knew coding...:)
No one holding you back from that but you.  I am working on learning it myself, but so far, my Java knowledge is only marginally helpful.