Einzelnen Beitrag anzeigen
  #10 (permalink)  
Alt 20.01.12
Biatsch Biatsch ist offline
Mitglied
 
Registriert seit: Oct 2011
Beiträge: 77
Biatsch befindet sich auf einem aufstrebenden Ast
Standard

HTML-Code:
extern double dLots=0.1;
extern int iStopLoss=6500;
extern int iTakeProfit=500;
extern int iSlippage=30;
extern int iMaxTrades=1;
extern int iMagicNumber=11111;
extern int UpdateToBE=30;


int iTradeSignal=0;
int iOpenBuySignal=10;
int iCloseBuySignal=-10;
int iOpenSellSignal=20;
int iCloseSellSignal=-20;
int iNoSignal=-1;

int iTotalTrades;
int iOrderOpenStatus;
int iErrorNumber;

string strErrorMessage;

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {

   double MAshort1 = iMA(NULL,15,20,0,MODE_EMA, PRICE_CLOSE,1);
   double MAshort0 = iMA(NULL,15,20,0,MODE_EMA, PRICE_CLOSE,0);
   double MAmiddle = iMA(NULL,60,20,0,MODE_EMA, PRICE_CLOSE,0);
   double MAlong   = iMA(NULL,240,20,0,MODE_EMA, PRICE_CLOSE,0);
   double Close1   = iClose(NULL,0,1);
   double Close2   = iClose(NULL,0,2);
   double Close3   = iClose(NULL,0,3);
   double SAR0     = iSAR(NULL,15,0.02,0.2,0);     // Unbenutzt
   double SAR1     = iSAR(NULL,15,0.02,0.2,1);
   double SAR2     = iSAR(NULL,15,0.02,0.2,2);
   double SAR3     = iSAR(NULL,15,0.02,0.2,3);
   
//-------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------BUY_LOGIK-------------------------------------------------------------------------------
if((Ask<MAlong) && (Ask<MAmiddle) && (Ask>MAshort0) && (Close1<MAshort1)){
   if((Close3>SAR3) && (Close2>SAR2) && (Close1>SAR1))
      iTradeSignal = iOpenBuySignal;
   }
   
//-------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------SELL_LOGIK------------------------------------------------------------------------------
if((Bid>MAlong) && (Bid>MAmiddle) && (Bid<MAshort0) && (Close1>MAshort1)){
   if((Close3<SAR3) && (Close2<SAR2) && (Close1<SAR1))
      iTradeSignal = iOpenSellSignal;
}

//--------------------------------------------------------------------------------------------------------------------------------
//----------------------------------MONEY_MANAGEMENT------------------------------------------------------------------------------
for(int i = OrdersTotal(); i >= 1; i--)
{
    if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
       if(OrderType() == OP_BUY && OrderOpenPrice() > OrderStopLoss() && Bid - OrderOpenPrice() >= UpdateToBE * Point)
  	    {
  	       OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0);
  	    }
  		 
       if(OrderType() == OP_SELL && OrderOpenPrice() < OrderStopLoss() && OrderOpenPrice() - Ask >= UpdateToBE * Point)
  	    {
  	       OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0);
  	    }
    }
}
//--------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------BUY_ORDER--------------------------------------------------------------------------
iTotalTrades=OrdersTotal();

if ((iTradeSignal == iOpenBuySignal) && (iTotalTrades < iMaxTrades))

{ 
double dBuyStopLoss=Ask-(iStopLoss*Point);
double dBuyTakeProfit=Ask+(iTakeProfit*Point);


iOrderOpenStatus=OrderSend (Symbol(), OP_BUY,dLots, Ask, iSlippage, dBuyStopLoss, dBuyTakeProfit, "EA",iMagicNumber,0,Green);
   if (iOrderOpenStatus<0)
      {
      iErrorNumber=GetLastError();
      Print ("Order fehlgeschlagen!: ", iErrorNumber);
      return;
      }
}
//--------------------------------------------------------------------------------------------------------------------------------
//----------------------------------------------SELL_ORDER------------------------------------------------------------------------

iTotalTrades=OrdersTotal();

if ((iTradeSignal == iOpenSellSignal) && (iTotalTrades < iMaxTrades))

   {
   double dSellStopLoss=Bid+(iStopLoss*Point);
   double dSellTakeProfit=Bid-(iTakeProfit*Point);
 
   
iOrderOpenStatus=OrderSend (Symbol(), OP_SELL,dLots, Bid, iSlippage, dSellStopLoss, dSellTakeProfit, "EA",iMagicNumber,0,Red);
   if (iOrderOpenStatus<0)
      {
      iErrorNumber=GetLastError();
      Print ("Order fehlgeschlagen!: ", iErrorNumber);
      return;
      }
}


   return(0);
  }
//+------------------------------------------------------------------+