Version 1j is in post 1, incorporating Philippe's lot-size idiot check.
I was not going to post the update so soon, but spotthedespot has done an outstanding bit of investigateve bloop-spotting that explains why some of you have not been seeing trades taken. If you know how to set your lot sizes and NB has been taking trades, then you do not need the update.
I have copied Dave's pm for the coders, at the end of this post. Translated into non-geek, the problem was caused by the OnlyTradeCurrencyTwice function.
Those of you who can, make these changes:
Find
bool CanTradeThisPair;
and change it to
bool CanTradeThisPair
= true;
Then go to bool IsTradingAllowed() and find this code block, second block down:
Code: Select all
if (OnlyTradeCurrencyTwice && OpenTrades == 0)
{
IsThisPairTradable();
}//if (OnlyTradeCurrencyTwice)
if (!CanTradeThisPair) return(false);
and place this line ahead of the block:
CanTradeThisPair = true;
so that the block is:
Code: Select all
CanTradeThisPair = true;
if (OnlyTradeCurrencyTwice && OpenTrades == 0)
{
IsThisPairTradable();
}//if (OnlyTradeCurrencyTwice)
if (!CanTradeThisPair) return(false);
Setting the variable to 'true' twice is probably overkill, but may as well make sure.
For the coders, here is the explanation (Dave, if you prefer not to have this quoted, sing out and I will remove it):
spotdespot wrote:Hi Steve,
I haven't had the EA trading on my account at all and although I am very capable of doing stupid things (I have many badges) I didn't think I had done anything in this case!
I checked the code (I am not familiar with MQL but code is code) and it seems I may have found the issue why some people are getting trades and some not. If you set OnlyTradeCurrencyTwice to TRUE then, as you know, in the IsTradingAllowed function it calls the IsThisPairTradable function if the conditional is met. In the IsThisPairTradable function it initializes the boolean CanTradeThisPair and checks whether to trade that pair, returning a boolean (from the IsThisPairTradable function). CanTradeThisPair is then checked:
Code: Select all
if (!CanTradeThisPair) return(false);
The issue arises (I think

) if you have OnlyTradeCurrencyTwice set to false as then IsThisPairTradable() is never called and CanTradeThisPair is never initialized. Now I have no idea how MQL deals with uninitialized variables but I have known the outcome to be pretty random using other languages - which might explain why some people are getting trades and others not (it could also just be those that have OnlyTradeCurrencyTwice = False that have the issue).
I set CanTradeThisPair to true when declared and now I am getting trades.
Hopefully this makes sense - I haven't posted this for others that have the issue just in case I am completely FOS!!
Cheers,
Dave.
Read the effing manual, ok?
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed
Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.