10.04.13
|
Mitglied
|
|
Registriert seit: Apr 2011
Ort: Osnabrück
Beiträge: 103
|
|
Ich habe deinen Code entsprechend angepasst und so ein paar Kleinigkeiten eingesetzt.
Z.B. die Prints durch Comment ersetzt, damit mir die Logs nicht vollgeschrieben werden^^
PHP-Code:
#property link ""
#define MAGIC 08042010
double startkurs = 0.0;
extern double diff = 1.2;
double buystop;
double sellstop;
bool CheckedToday = FALSE;
extern double LOT = 0.1;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
startkurs = Bid;
buystop = startkurs + (diff*ThisPip()) ;
sellstop = startkurs - (diff*ThisPip()) ;
//+------------------------------------------------------------------+
//| Horizontale Linie zeichnen |
//+------------------------------------------------------------------+
ObjectCreate("startkurs", OBJ_HLINE,0,Time[0],startkurs);
ObjectSet("startkurs", OBJPROP_COLOR, Yellow);
//+------------------------------------------------------------------+
//| Pending Orders absetzen |
//+------------------------------------------------------------------+
{
OrderSend(Symbol(), OP_SELLSTOP, LOT, (sellstop), 0, 0.0, 0.0, "SellStop Order", MAGIC);
OrderSend(Symbol(), OP_BUYSTOP, LOT, (buystop), 0, 0.0, 0.0, "SellStop Order", MAGIC);
{
Print("OrderSend failed with error #",GetLastError());
return(0);
}
}
//----
return;
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int Tick;
int start()
{
string ThisComment = "Ticknummer: " + Tick + "\nLetztes Hoch = " + High[0];
ThisComment = ThisComment + "\nLetztes Tief = " + Low[0] + "\nStartpreis = " + startkurs;
ThisComment = ThisComment + "\nBUYSTOP ist = " + buystop + "\nSELLSTOP ist = " + sellstop;
Tick++;
Comment(ThisComment);
//+------------------------------------------------------------------+
//| Prüfe ob eine Pending Order ausgefürt wurde |
//+------------------------------------------------------------------+
//----
if (CountLong(Symbol(),MAGIC)+CountShort(Symbol(),MAGIC) > 0) ClosePending(Symbol(),MAGIC);
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| MSP bestimmen |
//+------------------------------------------------------------------+
double ThisPip()
{
//----
double returnPoint = 0.000001;
int ThisDigits = MarketInfo(Symbol(), MODE_DIGITS);
if (ThisDigits == 2 || ThisDigits == 3) returnPoint = 0.01;
if (ThisDigits == 4 || ThisDigits == 5) returnPoint = 0.0001;
return(returnPoint);
//----
}
//+------------------------------------------------------------------+
//| Anzahl der Longpositionen |
//+------------------------------------------------------------------+
void ClosePending(string ThisSymbol="EURUSD",int ThisMagigNumber=123)
{
int ThisOrdersTotal = OrdersTotal();
for (int ThisCounter = 0; ThisCounter < ThisOrdersTotal; ThisCounter++)
{
OrderSelect(ThisCounter,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == ThisMagigNumber && OrderSymbol() == ThisSymbol && (OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP) )
{
OrderDelete(OrderTicket());
}
}
}
int CountLong(string countLongSymbol, int countLongMagic)
{
int CountLongReturn = 0;
int ThisOrdersTotal = OrdersTotal();
if (ThisOrdersTotal > 0 )
{
for(int counterCountLong = 0; counterCountLong < ThisOrdersTotal; counterCountLong++)
{
OrderSelect(counterCountLong, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol() == countLongSymbol && OrderMagicNumber() == countLongMagic)
{
if(OrderType() == OP_BUY)
{
CountLongReturn++;
}
}
}
}
return (CountLongReturn);
}
//+------------------------------------------------------------------+
//| Anzahl der Shortpositionen |
//+------------------------------------------------------------------+
int CountShort(string countShortSymbol, int countShortMagic)
{
int CountShortReturn = 0;
int ThisOrdersTotal = OrdersTotal();
if (ThisOrdersTotal > 0 )
{
for(int counterCountShort = 0; counterCountShort < ThisOrdersTotal; counterCountShort++)
{
OrderSelect(counterCountShort, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol() == countShortSymbol && OrderMagicNumber() == countShortMagic)
{
if(OrderType() == OP_SELL)
{
CountShortReturn++;
}
}
}
}
return (CountShortReturn);
}
|