void [B]OpenBuyStop[/B]()
{
int ticket,err,tries;
tries = 0;
if (!GlobalVariableCheck("InTrade")) {
while (tries < 3)
{
GlobalVariableSet("InTrade", CurTime()); // set lock indicator
ticket = OrderSend(Symbol(),[B]OP_BUYSTOP[/B],LotsOptimized(),[B]ho,1,hso,htp[/B],TradeComment,Magic,0,Green);
Write("[B]OpenBuyStop[/B], OrderSend Executed, ticket="+ticket);
GlobalVariableDel("InTrade"); // clear lock indicator
if(ticket<=0) {
Write("Error Occurred : "+ErrorDescription(GetLastError())+" BuyStop @ "+[B]lo[/B]+" SL @ "+[B]lso[/B]+" TP @"+[B]ltp[/B]);
tries++;
} else tries = 3;
}
}
}
void [B]OpenSellStop[/B]()
{
int ticket,err,tries;
tries = 0;
if (!GlobalVariableCheck("InTrade")) {
while (tries < 3)
{
GlobalVariableSet("InTrade", CurTime()); // set lock indicator
ticket = OrderSend(Symbol(),[B]OP_SELLSTOP[/B],LotsOptimized(),[B]lo,1,lso,ltp[/B],TradeComment,Magic,0,Red);
Write("[B]OpenSellStop[/B], OrderSend Executed, ticket="+ticket);
GlobalVariableDel("InTrade"); // clear lock indicator
if(ticket<=0) {
Write("Error Occurred : "+ErrorDescription(GetLastError())+" [B]SellStop[/B] @ "+[B]ho[/B]+" SL @ "+[B]hso[/B]+" TP @"+[B]htp[/B]);
tries++;
} else tries = 3;
}
}
}
void DoModify()
{
for (int i = 0; i < OrdersTotal(); i++) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()==Symbol() && (OrderMagicNumber() == Magic) && (OrderType()==[B]OP_BUYSTOP[/B])) {
if ((OrderOpenPrice()>[B]ho[/B]) || (OrderOpenPrice()<[B]ho[/B])) {
Write("[B]Buy Stop[/B] was @ "+DoubleToStr(OrderOpenPrice(),5)+", changed to "+DoubleToStr([B]ho[/B],5));
OrderModify(OrderTicket(),[B]ho,hso,htp[/B],0,Green);
}
}
if (OrderSymbol()==Symbol() && (OrderMagicNumber() == Magic) && (OrderType()==[B]OP_SELLSTOP[/B])) {
if ((OrderOpenPrice()>[B]lo[/B]) || (OrderOpenPrice()<[B]lo[/B])) {
Write("[B]Sell Stop[/B] was @ "+DoubleToStr(OrderOpenPrice(),5)+", changed to "+DoubleToStr([B]lo[/B],5));
OrderModify(OrderTicket()[B],lo,lso,ltp[/B],0,Red);
}
}
}
}