I have DIAD enabled and noticed this morning that whenever it took a sell, it instantly took out two buy trades. Initial buy trades behaved as expected. The problem was in the function that replaces missing lines; it was drawing them in buy line style when it should have been drawing them in sell line style.
The well dragged up little bot obediently discovered the buy lines, correctly spotted that the market had already crossed them and sent the buys. I have remarked before that my bots are impeccably polite and cooperative; just dumber than a box of rocks.
Fixed in post 1 at
http://www.stevehopwoodforex.com/phpBB3 ... =87&t=5077.
DIY fix could not be easier. Copy this over the top of the existing void ReplaceMissingLines() function:
Code: Select all
void ReplaceMissingLines()
{
//if (Symbol() == "USDCHF") Alert(EarliestTradeTicketNo);
if (!BetterOrderSelect(EarliestTradeTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
return;//Trade was closed for some reason
//if (Symbol() == "USDCHF") Alert("Y");
//Calculate the line prices
Trade1Price = OrderOpenPrice();
if (OrderType() == OP_BUY)
{
Trade2Price = Trade1Price + (Trade2At / factor);
Be1Price = (Trade1Price + Trade2Price) / 2 + (DiadBreakevenProfit / factor);
Trade3Price = Trade1Price + (Trade3At / factor);
Be2Price = (Trade2Price + Trade3Price) / 2 + (DiadBreakevenProfit / factor);
TpPrice = Trade1Price + (TakeProfit / factor);
}//if (OrderType() == OP_BUY)
if (OrderType() == OP_SELL)
{
Trade2Price = Trade1Price - (Trade2At / factor);
Be1Price = (Trade1Price + Trade2Price) / 2 - (DiadBreakevenProfit / factor);
Trade3Price = Trade1Price - (Trade3At / factor);
Be2Price = (Trade2Price + Trade3Price) / 2 - (DiadBreakevenProfit / factor);
TpPrice = Trade1Price - (TakeProfit / factor);
}//if (OrderType() == OP_SELL)
//Replace any missing lines
if (OpenTrades == 1)
{
if (ObjectFind(TradeLine2Name) == -1)
{
if (OrderType() == OP_BUY || OrderType() == OP_BUYLIMIT || OrderType() == OP_BUYSTOP)
DrawHorizontalLine(TradeLine2Name, Trade2Price, Trade2LineColour, Trade2BuyLineStyle, 0);
else
DrawHorizontalLine(TradeLine2Name, Trade2Price, Trade2LineColour, Trade2SellLineStyle, 0);
}//if (ObjectFind(TradeLine2Name) == -1)
if (ObjectFind(BeLine1Name) == -1)
{
DrawHorizontalLine(BeLine1Name, Be1Price, BreakEven1LineColour, BeLineStyle, 0);
}//if (ObjectFind(BeLine1Name) == -1)
if (ObjectFind(TradeLine3Name) == -1)
{
if (OrderType() == OP_BUY || OrderType() == OP_BUYLIMIT || OrderType() == OP_BUYSTOP)
DrawHorizontalLine(TradeLine3Name, Trade3Price, Trade3LineColour, Trade3BuyLineStyle, 0);
else
DrawHorizontalLine(TradeLine3Name, Trade3Price, Trade3LineColour, Trade3SellLineStyle, 0);
}//if (ObjectFind(TradeLine3Name) == -1)
if (ObjectFind(BeLine2Name) == -1)
{
DrawHorizontalLine(BeLine2Name, Be2Price, BreakEven2LineColour, BeLineStyle, 0);
}//if (ObjectFind(BeLine2Name) == -1)
if (ObjectFind(TakeProfitLineName) == -1)
{
DrawHorizontalLine(TakeProfitLineName, TpPrice, TakeProfitLineColour, STYLE_SOLID, 0);
}//if (ObjectFind(TakeProfitLineName) == -1)
}//if (OpenTrades == 1)
}//End void ReplaceMissingLines()
You can remove the greyed out Alerts - they were part of the debugging and not needed.

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.