Einzelnen Beitrag anzeigen
  #10 (permalink)  
Alt 28.08.18
Blancomi Blancomi ist offline
Neues Mitglied
 
Registriert seit: Aug 2018
Beiträge: 12
Blancomi befindet sich auf einem aufstrebenden Ast
Standard

Zitat:
Zitat von traderdoc Beitrag anzeigen
Sorry, aber da hat sich aus meiner Sicht an der Klammersetzung nicht viel geändert oder sehe nur ich das auf dem Schirm so. Z.B. die letzten 5 } stehen allen direkt untereinander. Das sollte überhaupt nicht so sein. Die {}-Pärchen müssen eindeutig ersichtlich zuordnungsfähig sein. Wenn man sich erst überlegen muss, welche { zu welcher} gehört, verliert man doch die Lust nach einem Fehler zu suchen.

traderdoc
Nächster Versuch

Code:
#property strict

input double Lots = 0.01;
input int SLPoints = 500;
input int TPPoints = 500;
input int TSLPoints = 500;
input double MaximalesRisiko = 0.01;

input ENUM_TIMEFRAMES Timeframe = PERIOD_H1;
input int PeriodsMAFast = 50;
input int PeriodsMASlow = 200;

input ENUM_MA_METHOD MethodMAFast = MODE_SMA;
input ENUM_MA_METHOD MethodMASlow = MODE_SMA;




input string Commentary = "Long/Short";
input int Magic = 111;

//globale Variable
datetime timestamp;

int OnInit()
  {
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {

   
  }

void OnTick()
  
 
{//Beginn Aktion
 
  
  trailingStop();
  
  if(timestamp == iTime(Symbol(),Timeframe,0)) return;
  timestamp = iTime(Symbol(),Timeframe,0);
  //Berechnung Moving Averages 
  
  double maFast = iMA(Symbol(),Timeframe,PeriodsMAFast,0,MethodMAFast,PRICE_CLOSE,1);
  double maSlow = iMA(Symbol(),Timeframe,PeriodsMASlow,0,MethodMASlow,PRICE_CLOSE,1);
  
  double maFastLast = iMA(Symbol(),Timeframe,PeriodsMAFast,0,MethodMAFast,PRICE_CLOSE,2);
  double maSlowLast = iMA(Symbol(),Timeframe,PeriodsMASlow,0,MethodMASlow,PRICE_CLOSE,2);
  //-----------------------------------------------------------------------------------------// 
  
 
  
  //Bedingungen Long  
  
  int total = OrdersTotal();
  if (total <20)
  
   if(maFast > maSlow && maFastLast < maSlowLast)
    
     {Print("Long");
     int ticket = executeLong();
     Print(IntegerToString(ticket));}
  //------------------------------------------------------------------------------------------//     

  //Bedingungen Short
   else if(maFast < maSlow && maFastLast > maSlowLast)
     
     {Print("Short");
     int ticket = executeShort();
     Print(IntegerToString(ticket));}
  //------------------------------------------------------------------------------------------//     
}//Ende Aktion


  //Ticket auf Long
   int executeLong ()
  
   {double entry = Ask;
   entry = NormalizeDouble(entry,Digits);
   
   double sl = entry - SLPoints * Point; 
   sl = NormalizeDouble(sl,Digits);
   
   double tp = entry + TPPoints * Point;
   tp = NormalizeDouble(tp,Digits);
   
   int ticket = OrderSend(Symbol(),OP_BUY,LotsOptimized,entry,1000,sl,tp,Commentary,Magic);
   
   return ticket;}
  //------------------------------------------------------------------------------------------//
   
  //Ticket auf Short
  int executeShort ()

   
   {double entry = Bid;
   entry = NormalizeDouble(entry,Digits);
   
   double sl = entry + SLPoints * Point; 
   sl = NormalizeDouble(sl,Digits);
   
   double tp = entry - TPPoints * Point;
   tp = NormalizeDouble(tp,Digits);
   
   int ticket = OrderSend(Symbol(),OP_SELL,LotsOptimized,entry,1000,sl,tp,Commentary,Magic);
   
   return ticket;}
   //-------------------------------------------------------------------------------------------//
   
   //Berechnung der Handelsgröße
   double LotsOptimized()
   
   {double lot=Lots;
    lot=NormalizeDouble(AccountFreeMargin()*MaximalesRisiko/1000.0,1);
    if(lot<0.1) lot=0.1;
    return(lot);}
//------------------------------------------------------------------------------------------//



  //TrailingsStop
  void trailingStop()
{//Beginn Aktion

  for(int i = 0; i < OrdersTotal(); i++)
   if(OrderSelect(i,SELECT_BY_POS) && OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
   
      if(OrderType() == OP_BUY)
      {
         double sl = Bid - TSLPoints * Point;
         sl = NormalizeDouble(sl,Digits);
         if(sl > OrderStopLoss())
         {bool res = OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),OrderExpiration());}
            
      }

     if(OrderType() == OP_SELL)
     {
         double sl = Ask + TSLPoints * Point;
         sl = NormalizeDouble(sl,Digits);
         if(sl < OrderStopLoss() || OrderStopLoss() == 0)
         
         {bool res = OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),OrderExpiration());}
     }

}//Ende Aktion
//---------------------------------------------------------------------------------------------//

Geändert von Blancomi (28.08.18 um 21:37 Uhr)