Modify existing order

 

I want to modify existing orders when the price action has moved beyond 50 pips from the order open price.

I have the following using the ticket variable of the last opened order but the strategy tester does not have any modified orders only buy and sell.

ANy ideas? Would it be better to find the open order using the symbol? I will only have one order open at a time for each currency pair.


void ModifyExisting()
{
//set SL == red line
OrderSelect(ticket,SELECT_BY_TICKET);
if (OrderType() == OP_BUY && (MathAbs(Ask-OrderOpenPrice()>500))) { //50pips profit at least before we modify
OrderModify(OrderTicket(),OrderOpenPrice(),JawsValue,OrderTakeProfit(),0,Green);
return(0);}
if (OrderType() == OP_SELL && (MathAbs(OrderOpenPrice()-Bid>500))) { //50pips profit at least before we modify
OrderModify(OrderTicket(),OrderOpenPrice(),JawsValue,OrderTakeProfit(),0,Red);
return(0);}
}
 
Function knows about your ticket number nothing.

void ModifyExisting(int ticket)

So about JawsValue.

Reason: