Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools

Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools (http://www.expert-advisor.com/forum/index.php)
-   Programmierung MQL4 (http://www.expert-advisor.com/forum/forumdisplay.php?f=220)
-   -   OrderModifyError 1 ???? (http://www.expert-advisor.com/forum/showthread.php?t=4848)

Traderole 18.03.16 08:54

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

Traderole 18.03.16 08:57

Also ich bekomme das ganze Journal voll mit OrderModifyError1, obwohl die Positionen richtig bearbeitet werden...

MA-EA 18.03.16 09:15

Muss nicht die Zeit oben als solche definiert werden? Start und Ende reicht da glaub ich nicht.

Soll man die Parameter nicht im MT einstellen können?

Traderole 18.03.16 22:51

Danke für die schnelle Antwort!

Die Zeit definiere ich in der Funktion tradezeit().

Ich habe den EA bei einem anderen Broker getestet und erhalte dort nicht die Fehlermeldung. Schon merkwerdürdig...


Alle Zeitangaben in WEZ +2. Es ist jetzt 18:06 Uhr.

Powered by vBulletin® Version 3.8.5 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.1
Powered by vBCMS® 2.7.0 ©2002 - 2024 vbdesigns.de
Copyright ©2009 - 2023 by Expert-Advisor.com - Das Metatrader Forum