ok. thanks.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
HELP WITH ERROR 4107
-
fx800
- Trader
- Posts: 1334
- Joined: Sun Dec 04, 2011 4:11 am
Re: HELP WITH ERROR 4107
-
fx800
- Trader
- Posts: 1334
- Joined: Sun Dec 04, 2011 4:11 am
Re: HELP WITH ERROR 4107
fx8000 wrote:ok. thanks.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
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
Have you tried just sending the trade without a SL or TP?
- 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
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
If you still have problems I may send you my working codesnippet via pm ...
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
-
fx800
- Trader
- Posts: 1334
- Joined: Sun Dec 04, 2011 4:11 am
Re: HELP WITH ERROR 4107
Thanks for helping.
Will try without SL and TP.
Will try without SL and TP.
-
fx800
- Trader
- Posts: 1334
- Joined: Sun Dec 04, 2011 4:11 am
Re: HELP WITH ERROR 4107
Thanks for your help.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
If you still have problems I may send you my working codesnippet via pm ...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
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);- 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
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
//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
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
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
The same error 130. Setting SL and TP to zero does not help either.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
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