Einzelnen Beitrag anzeigen
  #1 (permalink)  
Alt 06.08.11
sunnyboy20 sunnyboy20 ist offline
Neues Mitglied
 
Registriert seit: Mar 2011
Beiträge: 27
sunnyboy20 befindet sich auf einem aufstrebenden Ast
Question Brauche hilfe bei TrailingStop und BreakEven

Hallo,

ich habe hier meinen ersten EA programmiert und komme aber nun nicht weiter
ich wollte in meinen EA einen TrailingStop einfügen und einen BreakEven aber weiß nicht wo habe schon mehrere Varianten probiert aber keine will funktionieren.

Ich bin auch noch absoluter Noob auf dem Gebiet und habe das "programmieren" ;-) mit hilfe einer LernDVD "gelernt" eher mit Schrittanweisung nach programmiert und das so das es für mich übersichtlich ist und nachvollziehbar, halt so das man jederzeit die Strategie und Indikatoren jederzeit ändern kann.

Nun gut hier ist mein EA und ich brauch wie gesagt hilfe ;-)

Code:
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Sebastian Meissner"


extern string  Expert_Name    = "Trading Basti";
extern double iLots=0.1;
extern double iMaximumRisk= 0.02;
extern int iStopLoss=650;
extern int iTakeProfit=50;
extern int iMaxTrades=1;
extern int iMagicNumber=336699;

double stochg,stochr;

int iTotalTrades;
int iOrderOpenStatus;
int iErrorNumber;

string strErrorMessage;

double LotsOptimized()
  {
  double lot=iLots;
//---- select lot size
   lot=NormalizeDouble(AccountFreeMargin()*iMaximumRisk/1000.0,1);
//---- return lot size
   if(lot<0.1) lot=0.1;
   if(lot>50.0) lot=50.0;
   return(lot);
  }

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   

   
//----
   return(0);
  }
  
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }

//+------------------------------------------------------------------+
//| The functions from this point to the start function are where    |
//| changes are made to test other systems or strategies.            |
//|+-----------------------------------------------------------------+

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

  stochg = iCustom (NULL,0,"Stochastic",8,3,3,MODE_SMA,0,MODE_MAIN,0);                 //////// dont touch
  stochr = iCustom (NULL,0,"Stochastic",8,3,3,MODE_SMA,0,MODE_SIGNAL,0);               //////// dont touch
  double willd       = 81;                                                             //////// dont touch
  double willu       = 19;                                                             //////// dont touch
  double will1       = 80;                                                             //////// dont touch
  double will2       = 20;                                                             //////// dont touch

   
// Buy-Order ausführen

iTotalTrades=OrdersTotal();

if (( stochg > will2) && (stochg > stochr) && (stochr < will2) && (stochr > willu) && (iTotalTrades < iMaxTrades)) //// dont touch this

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

iOrderOpenStatus=OrderSend (Symbol(), OP_BUY,LotsOptimized(), Ask, dBuyStopLoss, dBuyTakeProfit, "Trading Basti",iMagicNumber,0,Green);
   if (iOrderOpenStatus<0)
      {
      iErrorNumber=GetLastError();
      Print ("Order fehlgeschlagen!: ", iErrorNumber);
      return;
      }
}
      
// Sell-Order ausführen

iTotalTrades=OrdersTotal();

if (( stochg < will1) && (stochg < stochr) && (stochr > will1) && (stochr < willd) && (iTotalTrades < iMaxTrades)) ///// dont touch

   {
   double dSellStopLoss=Bid+(iStopLoss*Point);
   double dSellTakeProfit=Bid-(iTakeProfit*Point);
 
   
iOrderOpenStatus=OrderSend (Symbol(), OP_SELL,LotsOptimized(), Bid, dSellStopLoss, dSellTakeProfit, "Trading Basti",iMagicNumber,0,Red);
   if (iOrderOpenStatus<0)
      {
      iErrorNumber=GetLastError();
      Print ("Order fehlgeschlagen!: ", iErrorNumber);
      return;
      }
}
   return(0);
  }
//----
Angehängte Dateien
Dateityp: mq4 bastiEA.mq4 (3,2 KB, 2x aufgerufen)