Folks, redownload the order sending script if you have not yet sent your orders yet. Start a fresh demo if you have sent them for the first time and so have no order history to lose.
Thomas noticed that some of the orders were sent in the wrong direction i.e. buying when the previous candle fell. He explained that:
- Data is only called for from the server when needed - in this case the open and close prices of the previous candle.
Said data can take a while to arrive in our history but Empty4 ignores this fact and works with the next best thing - in this case often the open/close prices of two candles ago.
I checked my trades from this morning and yes, at least a third of them were wrong. We live and learn.
Thomas also provided the code to correct this so I edited the script and have just used it on another demo. All correct.
For DIYers, replace the existing void getDirection(string symbol, int tf, int pairIndex) function with this:
Code: Select all
void getDirection(string symbol, int tf, int pairIndex)
{
//Ascertain the direction of movement of the previous candle
//double copen = iOpen(symbol, tf, 1);
//double cclose = iClose(symbol, tf, 1);
//////////////////////////////////////////////////
//Thomas provided this section of code. Here is why, from his
//pm to me:
/*
As I know, history will get loaded as soon as you access data, but that takes a while and Empty4
doesn't wait for the data to arrive. Instead it throws a 4066 or 4073 error which the programmer is
entitled to handle. In MT5 this might work better.
Here is what I have added to my EA. You can easily adapt it to your variables:
*/
ResetLastError();
double copen=iOpen(symbol,PERIOD_MN1,1);
while(GetLastError()!=0)
{
Sleep(10);
ResetLastError();
copen=iOpen(symbol,PERIOD_MN1,1);
}
ResetLastError();
double cclose=iClose(symbol,PERIOD_MN1,1);
while(GetLastError()!=0)
{
Sleep(10);
ResetLastError();
cclose=iClose(symbol,PERIOD_MN1,1);
}
//////////////////////////////////////////////////
direction = none;
if (cclose > copen)
{
direction = long;
return;
}//if (cclose > copen)
if (cclose < copen)
{
direction = short;
return;
}//if (cclose > copen)
}//End void getDirection(string symbol, int tf, int pairIndex)
Let's see if 'correct' code turbocharges this or buggers it up.
Thanks again Thomas.

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.