Philippe[/quote]
It is the jumping stop with Stealth that causes the problem, with the error 1 messages it generates. It is trying to modify the stoploss with a value that is already the stoploss, and I cannot work out why.

[/quote]
Steve, I hope this version is OK. I have seen a jumping SL OK with HiddenPip = 50
Code: Select all
//Philippe's code version II for Stealth .
void JumpingStopLoss()
{
// Jump sl by pips and at intervals chosen by user .
//if (OrderProfit() < 0) return;//Nothing to do.
//Use the sl line if this is drawn on the chart.
string LineName = SlPrefix + DoubleToStr(OrderTicket(), 0);
double sl = OrderStopLoss();
double real_sl = 0;
if (ObjectFind(LineName) > -1 || HiddenPips > 0)
{
sl = ObjectGet(LineName, OBJPROP_PRICE1);
}//if (ObjectFind(LineName) > -1)
//if (sl == 0) return;//No line, so nothing to do
double NewStop;
bool modify=false;
bool result;
if (OrderType()==OP_BUY)
{
if (sl == 0) real_sl = OrderStopLoss();
else real_sl = NormalizeDouble(sl - (HiddenPips*Point),Digits);
if (real_sl < OrderOpenPrice() ) return;//Not at breakeven yet
if (real_sl == 0) real_sl = OrderOpenPrice(); //No hidden stop loss line
if (Bid >= real_sl + ((JumpingStopPips * 2) * Point) )
{
NewStop = NormalizeDouble(real_sl + (JumpingStopPips * Point), Digits);
if (AddBEP) NewStop = NormalizeDouble(NewStop + (BreakEvenProfit*Point), Digits);
if (NewStop - real_sl > Point) modify = true;//George again. What a guy
}// if (Bid>= sl + (JumpingStopPips*Point) && sl>= OrderOpenPrice())
}//if (OrderType()==OP_BUY)
if (OrderType()==OP_SELL)
{
if (sl == 0) real_sl = OrderStopLoss();
else real_sl = NormalizeDouble(sl + (HiddenPips*Point),Digits);
if (real_sl > OrderOpenPrice() ) return;//Not at breakeven yet
if (real_sl== 0) real_sl = OrderOpenPrice(); //No hidden stop loss line
if (Bid <= real_sl - ((JumpingStopPips * 2) * Point) )
{
NewStop = NormalizeDouble(real_sl - (JumpingStopPips * Point), Digits);
if (AddBEP) NewStop = NormalizeDouble(NewStop - (BreakEvenProfit*Point), Digits);
if (real_sl - NewStop > Point) modify = true;//George again. What a guy
}// close if (Bid>= sl + (JumpingStopPips*Point) && sl>= OrderOpenPrice())
}//if (OrderType()==OP_SELL)
//Move 'hard' stop loss whether hidden or not. Don't want to risk losing a breakeven through disconnect.
if (modify)
{
while (IsTradeContextBusy() ) Sleep(100);
result = OrderModify(OrderTicket(), OrderOpenPrice(), NewStop, OrderTakeProfit(), OrderExpiration(), CLR_NONE);
if (!result) ReportError();
else
{
Print(Symbol()+" Jumping SL");
if (OrderType()==OP_BUY) ObjectMove(LineName, 0, Time[0], NormalizeDouble(NewStop + (HiddenPips*Point),Digits));
if (OrderType()==OP_SELL) ObjectMove(LineName, 0, Time[0], NormalizeDouble(NewStop - (HiddenPips*Point),Digits));
}
if (PartCloseEnabled && OrderLots() > Preserve_Lots)// Only try to do this if the jump stop worked
{
bool PartCloseSuccess = PartCloseTradeFunction();
//if (!PartCloseSuccess) SetAGlobalTicketVariable();
}//if (PartCloseEnabled && OrderLots() > Preserve_Lots)
}//if (modify)
} //End of JumpingStopLoss sub
I attach an modify EA so you can test it
cheers
Philippe
You do not have the required permissions to view the files attached to this post.