hab mal die Long Routine soweit hingebracht, daß das Opening bei Kerzenwechsel funktioniert, nur das Schließen geht nicht, d. h. die Position wird sofort geschlossen. Im Terminal wird angezeigt: invalid ticket for OrderClose function.
Code:
extern double Lot=0.01;
extern int StopLoss=6;
extern int TakeProfit=10;
int Multiplier;
int i=0;
int zaehler;
int MagicNumber=1234;
double TPValue,SLValue;
//+------------------------------------------------------------------+
void OnInit() {
Multiplier = 1;
if(Digits == 3 || Digits == 5) Multiplier = 10;
if(Digits == 6) Multiplier = 100;
if(Digits == 7) Multiplier = 1000;
TakeProfit *= Multiplier;
StopLoss *= Multiplier;
TPValue = NormalizeDouble(TakeProfit * Point, Digits);
SLValue = NormalizeDouble(StopLoss * Point, Digits);
}
void start()
{
int ticket;
string comment="Expiration v2 (Long)";
//+------------------------------------------------------------------+
int offeneorders=0;
int anzahlorders=OrdersTotal();
if (Close[2] < Open[2] && Close[1] > Open[1])
{
for(zaehler=0; zaehler<anzahlorders; zaehler++)
{
OrderSelect(zaehler, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol())
{
offeneorders++;
}
}
if(offeneorders==0)
{
ticket=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,Ask-SLValue,Ask+TPValue,comment,0,0,Blue);
}
if (Time[0] > OrderOpenTime() + 4*Period()*60)
{
OrderClose(ticket,Lot,Bid,3,0);
}
}
return(0);
}
|