Einzelnen Beitrag anzeigen
  #142 (permalink)  
Alt 02.03.16
MA-EA MA-EA ist offline
Elite Mitglied
 
Registriert seit: Sep 2015
Beiträge: 565
MA-EA befindet sich auf einem aufstrebenden Ast
Standard

Einen Fehler konnte ich irgendwie beheben. Bleibt bloß noch einer:


Code:
extern int TimeFrame = 60;
extern string TimeFrames= "Current:0;M1:1; M5:5; M15:15; M30:30; H1:60; H4:240; D1:1440";
extern int Fast_GD = 15;
extern int Slow_GD = 30;
extern int GD_Type = 0;
extern string GD_Types = "SMA:0; EMA:1; SMMA;2; LWMA:3";
extern int GD_Shift = 0;
extern double Lots = 0.01;
extern int InpCCIPeriod = 20;// CCI Period
extern int indicator_level1 = "-100.0";
extern int indicator_level2 = "+100.0";
extern color color1 = LightSeaGreen;

int Slippage = 1000;

int Ticket, i;
double Spread, PointSet;
bool IsInvested, CloseTicket;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+

int init(); {
int OnInit iCCI;
return(0);
}

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

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+

int start() {  
   if (Digits <= 3) PointSet = 0.01; else PointSet = 0.0001;
   if (Digits <= 1) PointSet = 1;
   Spread=Ask-Bid;
   Lots = MathMax(MathMin(Lots, MarketInfo(Symbol(),MODE_MAXLOT)),MarketInfo(Symbol(),MODE_MINLOT));

//Define Vars
   if (TimeFrame==0) TimeFrame=NULL;
   double LC = iClose(Symbol(), TimeFrame, 1);
   double GD1c = iMA(Symbol(), TimeFrame, Fast_GD, GD_Shift, GD_Type, PRICE_CLOSE, 1);
   double GD2c = iMA(Symbol(), TimeFrame, Slow_GD, GD_Shift, GD_Type, PRICE_CLOSE, 1);
   double CCI = iCCI(Symbol(), InpCCIPeriod, color1, PRICE_CLOSE, 1);

//Check position
   IsInvested = false;
   for (i=OrdersTotal()-1; i>=0; i--) {
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if((OrderType()==OP_SELL || OrderType()==OP_BUY) && OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol()) IsInvested=true;
      }
   } 

//Open Trade
   if (!IsInvested) {
      if (LC>GD1c && GD1c>GD2c && CCI>"+100") OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0, Name + " Buy(#" + MagicNumber + ")", MagicNumber, 0, Blue);
      if (LC<GD1c && GD1c<GD2c && CCI<"-100") OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, 0, Name + " Sell(#" + MagicNumber + ")", MagicNumber, 0, Red);
   }

//Close Trade
   if (IsInvested) {
    for (i=OrdersTotal()-1; i>=0; i--) {
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderType()==OP_BUY && OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol()) {
            if(LC<GD1c && GD1c<GD2c == CCI<"+100") OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, DarkBlue);
         }
         if (OrderType()==OP_SELL && OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol()) {
            if(LC>GD1c && GD1c>GD2c >("-100")) OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, FireBrick);
         } 
      }
    }    
   }
         
 return(0);
}

Geändert von MA-EA (02.03.16 um 20:58 Uhr)