Leaving this aside, why does the damn code insist on allowing the new trade when the stop loss modify fails? Until we work this out, anything else is prone to error.DragosDanescu wrote:Steve, don't know if here is the problem, I have modified condition anyway to assure trade is in profit and at a certain number of pips away (BreakEvenPips), but seems to me that OrderModify it's the problem...
...shouldn't be something likeCode: Select all
if (OpenTrades > 0) { if (OrderStopLoss() < OrderOpenPrice() && Ask - OrderOpenPrice() >= NormalizeDouble(BreakEvenPips*Point, Digits)) //Attempt to move stop to breakeven { result = OrderModify(TicketNo, OrderOpenPrice(), OrderOpenPrice(), OrderStopLoss(), OrderExpiration(), CLR_NONE); if (!result)
Code: Select all
{ stop = NormalizeDouble(OrderOpenPrice() + xPips*Point,Digits); result = OrderModify(TicketNo, OrderOpenPrice(), stop, 0, OrderExpiration(), CLR_NONE);
I cannot work out why the bloody trade is still sent even though the bloody stop loss modify bloody well fails.
SCREAAAAMMMMMMMM
I am going to leave it for now and start again tomorrow.
For now, the initial trade send is fine. It is the stack stuff that is failing. It will be a simple logic bloop - it always is. If all else fails, then rewriting void LookForTradingOpportunities() will solve the problem.