stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

HELP WITH ERROR 4107
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=2914
Page 4 of 18
Author:  fx800 [ Wed Aug 14, 2013 12:25 pm ]
Post subject:  Re: HELP WITH ERROR 4107

ewinner wrote:Yeah, try increasing it to 10 pips, see if that works.... at least then you can rule that out if it still doesn't behave!!

Mark
ok. thanks.
Author:  fx800 [ Thu Aug 15, 2013 4:41 pm ]
Post subject:  Re: HELP WITH ERROR 4107

fx8000 wrote:
ewinner wrote:Yeah, try increasing it to 10 pips, see if that works.... at least then you can rule that out if it still doesn't behave!!

Mark
ok. thanks.

Still getting error 130, invalid stops, despite using buffer of 10 pips.

Very odd.

Does anyone know of a recent ea using pending orders ? I could have a look at its pending order code.
Author:  ewinner [ Thu Aug 15, 2013 9:25 pm ]
Post subject:  Re: HELP WITH ERROR 4107

Have you tried just sending the trade without a SL or TP?
Author:  fxdaytrader [ Fri Aug 16, 2013 2:14 am ]
Post subject:  Re: HELP WITH ERROR 4107

I just tried to see if it works - implemented the code in another script of mine to see if it fires out a pending. and it does.

I assume your problem could be the orderexpiration-time. It seems you have to append * 60 to the code. Another problem could the minimum expiry-minutes be, I read it should be at least 11 mins at http://forum.mql4.com/4992

Code: Select all

 
         int expiry = TimeCurrent() + (PendingBarsTF * BarsToKeepPendings * 60);//Dietcoke modification, comes to sendsingletrade + multiplikate with 60
          if (expiry < (TimeCurrent() + 660)) expiry = TimeCurrent() + 660; //at least 11 mins, http://forum.mql4.com/4992
If you still have problems I may send you my working codesnippet via pm ...
Author:  fx800 [ Fri Aug 16, 2013 4:33 am ]
Post subject:  Re: HELP WITH ERROR 4107

Thanks for helping.

Will try without SL and TP.
Author:  fx800 [ Fri Aug 16, 2013 4:53 am ]
Post subject:  Re: HELP WITH ERROR 4107

fxdaytrader wrote:I just tried to see if it works - implemented the code in another script of mine to see if it fires out a pending. and it does.

I assume your problem could be the orderexpiration-time. It seems you have to append * 60 to the code. Another problem could the minimum expiry-minutes be, I read it should be at least 11 mins at http://forum.mql4.com/4992

Code: Select all

 
         int expiry = TimeCurrent() + (PendingBarsTF * BarsToKeepPendings * 60);//Dietcoke modification, comes to sendsingletrade + multiplikate with 60
          if (expiry < (TimeCurrent() + 660)) expiry = TimeCurrent() + 660; //at least 11 mins, http://forum.mql4.com/4992
If you still have problems I may send you my working codesnippet via pm ...
Thanks for your help.

I will try adding *60 to the pending expiry code and see.

The odd thing is that the same pending expiry code works when added to Steve's GDAY MK2 EA. How do you explain that apart from the fact that the InsertStopLoss and InsertTakeProfit codes are slightly different in GDAY and it does not have the function "void CheckTpSlAreCorrect(int type)"

Anyway, will try the *60 first. Having said that, I have tried commenting out the pending expiry line, and the same error persisted.

Besides, Dietcoke's pending expiry code works perfectly well in another of my ea without the *60.

In fact, after Dietcoke very kindly provided his modification, I found out that Steve's shell ea already has the pending expiry code which has been commented out as most of his ea's uses buyopen and sellopen.

The code in question is attached below

Code: Select all

 //if (SendPendingTrades) expiry = TimeCurrent() + (PendingExpiryMinutes * 60);
All I need to do is add an external variable for PendingExpiryMinutes.
Author:  fxdaytrader [ Fri Aug 16, 2013 4:54 am ]
Post subject:  Re: HELP WITH ERROR 4107

See attached script (belongs to Empty4/experts/scripts), relevant are the parts between
//pending stuff, for testing purposes - just send sellstop order
and //end pending stuff, for testing purposes - just send sellstop order

I removed (nearly) all of the stuff not needed here. The script just sends a sellstop-order (works fine at my Empty4). Look at the code for details ;)
Author:  fx800 [ Fri Aug 16, 2013 10:08 am ]
Post subject:  Re: HELP WITH ERROR 4107

fxdaytrader wrote:See attached script (belongs to Empty4/experts/scripts), relevant are the parts between
//pending stuff, for testing purposes - just send sellstop order
and //end pending stuff, for testing purposes - just send sellstop order

I removed (nearly) all of the stuff not needed here. The script just sends a sellstop-order (works fine at my Empty4). Look at the code for details ;)

Thank you very much.

You are most kind.
Author:  fx800 [ Fri Aug 16, 2013 11:43 am ]
Post subject:  Re: HELP WITH ERROR 4107

fxdaytrader wrote:See attached script (belongs to Empty4/experts/scripts), relevant are the parts between
//pending stuff, for testing purposes - just send sellstop order
and //end pending stuff, for testing purposes - just send sellstop order

I removed (nearly) all of the stuff not needed here. The script just sends a sellstop-order (works fine at my Empty4). Look at the code for details ;)

Added the following modification to bool SendSingleTrade and waiting for the next order.

Code: Select all

bool SendSingleTrade(string symbol, int type, string comment, double lotsize, double price, double stop, double take)
{
   //pah (Paul) contributed the code to get around the trade context busy error. Many thanks, Paul.
   
   double slippage = MaxSlippagePips * MathPow(10, Digits) / PFactor(Symbol());

   
   
   color col = Red;
   if (type == OP_BUY || type == OP_BUYSTOP) col = Green;
   
    int expiry = TimeCurrent() + (PendingBarsTF * BarsToKeepPendings * 60);//Dietcoke modification, comes to sendsingletrade + multiplikate with 60
    if (expiry < (TimeCurrent() + 660)) expiry = TimeCurrent() + 660; //at least 11 mins, http://forum.mql4.com/4992 
Author:  fx800 [ Fri Aug 16, 2013 12:47 pm ]
Post subject:  Re: HELP WITH ERROR 4107

fx8000 wrote:
fxdaytrader wrote:See attached script (belongs to Empty4/experts/scripts), relevant are the parts between
//pending stuff, for testing purposes - just send sellstop order
and //end pending stuff, for testing purposes - just send sellstop order

I removed (nearly) all of the stuff not needed here. The script just sends a sellstop-order (works fine at my Empty4). Look at the code for details ;)

Added the following modification to bool SendSingleTrade and waiting for the next order.

Code: Select all

bool SendSingleTrade(string symbol, int type, string comment, double lotsize, double price, double stop, double take)
{
   //pah (Paul) contributed the code to get around the trade context busy error. Many thanks, Paul.
   
   double slippage = MaxSlippagePips * MathPow(10, Digits) / PFactor(Symbol());

   
   
   color col = Red;
   if (type == OP_BUY || type == OP_BUYSTOP) col = Green;
   
    int expiry = TimeCurrent() + (PendingBarsTF * BarsToKeepPendings * 60);//Dietcoke modification, comes to sendsingletrade + multiplikate with 60
    if (expiry < (TimeCurrent() + 660)) expiry = TimeCurrent() + 660; //at least 11 mins, http://forum.mql4.com/4992 
The same error 130. Setting SL and TP to zero does not help either.

However, removing the pending expiry code altogether works but cannot set how many bars the pending order is for. I would prefer to set the PO for one bar only.

NOW WE KNOW THE PROBLEM IS WITH THE PENDING ORDER EXPIRY CODE.

Code: Select all

bool SendSingleTrade(string symbol, int type, string comment, double lotsize, double price, double stop, double take)
{
   //pah (Paul) contributed the code to get around the trade context busy error. Many thanks, Paul.
   
   double slippage = MaxSlippagePips * MathPow(10, Digits) / PFactor(Symbol());

   
   
   color col = Red;
   if (type == OP_BUY || type == OP_BUYSTOP) col = Green;
   
    //int expiry = TimeCurrent() + (PendingBarsTF * BarsToKeepPendings * 60);//Dietcoke modification, comes to sendsingletrade + multiplikate with 60
    //if (expiry < (TimeCurrent() + 660)) expiry = TimeCurrent() + 660; //at least 11 mins, http://forum.mql4.com/4992
   
   int expiry = 0;
   //if (SendPendingTrades) expiry = TimeCurrent() + (PendingExpiryMinutes * 60);
   //if (SendPendingTrades) expiry = TimeCurrent() + (PendingBarsTF * BarsToKeepPendings * 60);//Dietcoke/FxDayTrader modification 
All times are UTC Page 4 of 18