OrderModifyError 1 ????
Hallo!
Ich habe einen EA geschrieben, der zwei Positionen eröffnet. Sobald die erste Posi in T/P gelaufen ist, soll der S/L der zweite Posi in auf Breakeven gezogen werden. Hier ist der Code:
int RSIperiode = 2;
int CCIperiode = 10;
int Start = 8;
int Ende = 22;
int magicnumber = 12345;
int ticketlong1,ticketlong2,ticketshort1,ticketshort2;
double lot = 0.1;
double slippage= 2 * Point;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
checkforOrdersend();
checkforbreakeven();
}
//+------------------------------------------------------------------+
//================================================== ================
bool tradezeit()
{
int zeit = TimeHour(TimeLocal());
if(zeit > Start && zeit < Ende )
return (true);
else return (false);
}
//================================================== ================
bool checkforBuy()
{
double RSI = iRSI(NULL,0,RSIperiode,PRICE_CLOSE,1);
double CCI = iCCI(NULL,0,CCIperiode,PRICE_CLOSE,1);
double BB = iBands(NULL,0,20,2,0,PRICE_CLOSE,2,1);
if(RSI < 10 && CCI < -150 && Close[1] < BB)
return(true);
else return(false);
}
//================================================== ===================
double checkstoplosslong()
{
double StopplossLong = Close[1] - 100 * Point; // 10 PIPS S/L
return (StopplossLong);
}
//================================================== ===================
double checktakeprofitlong1()
{
double TakeprofitLong1 = Close[1] + 200 * Point; // T/P1 = 20 PIPS
return (TakeprofitLong1);
}
//================================================== ======
double checktakeprofitlong2()
{
double TakeprofitLong2 = Close[1] + 400 * Point; // T/P1 = 40 PIPS
return (TakeprofitLong2);
}
//================================================== ======
//================================================== ======
int checkforOrdersend()
{
if(Volume[0] == 1 && checkforBuy() == true && tradezeit() == true)
{
ticketlong1 = OrderSend(NULL,OP_BUY,lot,Ask,slippage,checkstoplo sslong(),checktakeprofitlong1(),"",magicnumber,0,B lue);
if(ticketlong1 == -1) Print(GetLastError());
}
if(Volume[0] == 1 && checkforBuy() == true && tradezeit() == true)
{
ticketlong2 = OrderSend(NULL,OP_BUY,lot,Ask,slippage,checkstoplo sslong(),checktakeprofitlong2(),"",magicnumber,0,B lue);
if(ticketlong2 == -1) Print(GetLastError());
}
return(0);
}
//================================================== ===================
int checkforbreakeven()
{
int i;
RefreshRates();
for(i = OrdersTotal()-1; i >= 0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderType() == OP_BUY && NormalizeDouble(Bid,Digits) >= NormalizeDouble(OrderOpenPrice()+200 * Point,Digits) && OrderTakeProfit() != checktakeprofitlong1() && OrderStopLoss() != OrderOpenPrice() )
{
if (!OrderModify(OrderTicket(),OrderOpenPrice(),Order OpenPrice(),OrderTakeProfit(),0,Yellow))
{
Print("Ordermodifylong:_",GetLastError());
}
else Print("Order has been modified");
}
}
return(0);
}
Kann mir da jemand weiterhelfen??? Ich danke schon mal im Voraus
|