V 1d is in post 1. I have worked a lot on the bot this weekend and the details are in the new user guide. I have:
- added simple and complex offsetting as a trade closure option.
- added features to deal with the potential leaky toilet (noobs, you will read about this in the UG):
- added a way to define a position as unbalanced.
- added simple and complex offsetting to help CP return to a balanced position.
- added two 'nuclear option' closure functions when the position becomes unbalanced.
I have tested the code in Crapergy Tester and it appears to be fine but bugs sometimes emerge when an EA is loaded onto demo when the markets open. We shall see. Maybe hold off using the new features live until we have run them on demo for a day? They are disabled by default.
I have just had an idea. If you want to leave 1c running on your live accounts whilst we test the new features, copy this over the top of the existing bool EnoughDistance(int type, double price):
Code: Select all
bool EnoughDistance(int type, double price)
{
//Returns false if the is < MinDistanceBetweenTradesPips
//between the price and the nearest order open prices.
double pips = 0;
//No market order yet
if (type == OP_BUY)
if (!BuyOpen)
return(true);
if (type == OP_SELL)
if (!SellOpen)
return(true);
for (int cc = OrdersTotal() - 1; cc >= 0; cc--)
{
if (!BetterOrderSelect(cc, SELECT_BY_POS, MODE_TRADES) ) continue;
if (OrderSymbol() != Symbol() ) continue;
if (OrderMagicNumber() != MagicNumber) continue;
if (OrderType() != type) continue;
pips = MathAbs(price - OrderOpenPrice() ) * factor;
if (pips < MinDistanceBetweenTrades)
return(false);
}//for (int cc = OrdersTotal() - 1; cc >= 0; cc--)
//Got here, so OK to trade
return(true);
}//End bool EnoughDistance(int type, double price)
This is accurate code to calculate that there is sufficient distance between the proposed new trade and the nearest existing ones.
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.