[/QUOTE]The code working without any problem's ..
but the only problem it shown errors under expert option in mt4 , and this makes lag ..
here the picture :
so if anyone can help and fix this codes for me , I will be thanks ...have a nice day.
thank you so much
Here the Main Error :
MetaEditor Error's :
First Error ( Orderselect) :
code :
{
OrderSelect(i,SELECT_BY_POS);
int type=OrderType();
if(( OrderSymbol()==Symbol()) && (OrderMagicNumber()==Magic))
{
switch(type)
{
case OP_BUY : t=1;
case OP_SELL : t=1;
case OP_BUYLIMIT : t=1;
case OP_BUYSTOP : t=1;
case OP_SELLLIMIT : t=1;
case OP_SELLSTOP : t=1;
}
}
}
2nd Error :
{
//---if opened order is "Buy", close another pending order "Sellstop" and use trailing stop for opened "Buy" order
OrderSelect(ticket1,SELECT_BY_TICKET);
if(OrderType()==OP_BUY)
{
// delete pending order
OrderDelete(ticket2);
// use Trailling Stop
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
}
}
}
//---if opened order is "Sell", close another pending order "Buystop" and use trailing stop for opened "Sell" order
OrderSelect(ticket2,SELECT_BY_TICKET);
if(OrderType()==OP_SELL)
{
// delete pending order
OrderDelete(ticket1);
// use Trailling Stop
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if(OrderStopLoss()>(Ask+Point*TrailingStop))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Poi nt*TrailingStop,OrderTakeProfit(),0,Red);
}
}
}
}
3RD Error:
{
// delete pending order
OrderDelete(ticket2);
// use Trailling Stop
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
}
}
}
Order modify Error :
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
}
Order select error:
{
//---if opened order is "Buy", close another pending order "Sellstop" and use trailing stop for opened "Buy" order
OrderSelect(ticket1,SELECT_BY_TICKET);
if(OrderType()==OP_BUY)
{
// delete pending order
OrderDelete(ticket2);
// use Trailling Stop
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
}
}
}
//---if opened order is "Sell", close another pending order "Buystop" and use trailing stop for opened "Sell" order
OrderSelect(ticket2,SELECT_BY_TICKET);
if(OrderType()==OP_SELL)
{
// delete pending order
OrderDelete(ticket1);
// use Trailling Stop
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if(OrderStopLoss()>(Ask+Point*TrailingStop))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Poi nt*TrailingStop,OrderTakeProfit(),0,Red);
}
}
}
}
Order delete error:
{
// delete pending order
OrderDelete(ticket1);
// use Trailling Stop
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if(OrderStopLoss()>(Ask+Point*TrailingStop))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Poi nt*TrailingStop,OrderTakeProfit(),0,Red);
}
}
}
}
and the last error ( order modify ) :
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Poi nt*TrailingStop,OrderTakeProfit(),0,Red);
}