HELP WITH ERROR 4107

Post Reply
fx800
Trader
Posts: 1334
Joined: Sun Dec 04, 2011 4:11 am

Re: HELP WITH ERROR 4107

Post by fx800 »

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.
fx800
Trader
Posts: 1334
Joined: Sun Dec 04, 2011 4:11 am

Re: HELP WITH ERROR 4107

Post by fx800 »

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.
ewinner
Trader
Posts: 36
Joined: Wed Nov 16, 2011 9:36 am
Location: South West Ireland

Re: HELP WITH ERROR 4107

Post by ewinner »

Have you tried just sending the trade without a SL or TP?
User avatar
fxdaytrader
Trader
Posts: 190
Joined: Sun Jun 10, 2012 7:03 am
Location: Poon-Town (germany, se-asia, se-europe) ...

Re: HELP WITH ERROR 4107

Post by fxdaytrader »

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 ...
fx800
Trader
Posts: 1334
Joined: Sun Dec 04, 2011 4:11 am

Re: HELP WITH ERROR 4107

Post by fx800 »

Thanks for helping.

Will try without SL and TP.
fx800
Trader
Posts: 1334
Joined: Sun Dec 04, 2011 4:11 am

Re: HELP WITH ERROR 4107

Post by fx800 »

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.
User avatar
fxdaytrader
Trader
Posts: 190
Joined: Sun Jun 10, 2012 7:03 am
Location: Poon-Town (germany, se-asia, se-europe) ...

Re: HELP WITH ERROR 4107

Post by fxdaytrader »

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 ;)
You do not have the required permissions to view the files attached to this post.
fx800
Trader
Posts: 1334
Joined: Sun Dec 04, 2011 4:11 am

Re: HELP WITH ERROR 4107

Post by fx800 »

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.
fx800
Trader
Posts: 1334
Joined: Sun Dec 04, 2011 4:11 am

Re: HELP WITH ERROR 4107

Post by fx800 »

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 
fx800
Trader
Posts: 1334
Joined: Sun Dec 04, 2011 4:11 am

Re: HELP WITH ERROR 4107

Post by fx800 »

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 
Post Reply

Return to “Coders Hangout”