Einzelnen Beitrag anzeigen
  #156 (permalink)  
Alt 11.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

Hallo.

Ist hier irgendwas falsch? Oder kennt der EA nicht den Unterschied zwischen GDs auf High, Low und Close?
Code:
extern int TimeFrame = 60;
extern string TimeFrames= "Current:0;M1:1; M5:5; M15:15; M30:30; H1:60; H4:240; D1:1440";
//GDs
extern int High_GD = 6;
extern int Fast_Close_GD = 3;
extern int Slow_Close_GD = 6;
extern int Low_GD = 6;
extern int GD_Type = 0;
extern string GD_Types = "SMA:0; EMA:1; SMMA;2; LWMA:3";
int GD_Shift = 0;
//Sonstige globale Variablen
extern double Lots = 0.01;
extern int Slippage = 600;
extern int Max_Spread = 40;
int Ticket, i;
double Spread, PointSet;
bool IsInvested, CloseTicket;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init() {
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);
//GDs
double HGD = iMA(Symbol(), TimeFrame, High_GD, GD_Shift, GD_Type, PRICE_HIGH, 1);
double FCGD = iMA(Symbol(), TimeFrame, Fast_Close_GD, GD_Shift, GD_Type, PRICE_CLOSE, 1);
double SCGD = iMA(Symbol(), TimeFrame, Slow_Close_GD, GD_Shift, GD_Type, PRICE_CLOSE, 1);
double LGD = iMA(Symbol(), TimeFrame, Low_GD, GD_Shift, GD_Type, PRICE_LOW, 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 (Spread <= Max_Spread && LC>HGD && LC>FCGD && FCGD>SCGD) OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0, Name + " Buy(#" + MagicNumber + ")", MagicNumber, 0, Blue);
if (Spread <= Max_Spread && LC<LGD && LC<FCGD && FCGD<SCGD) 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<FCGD && FCGD<SCGD) OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, DarkBlue);
}
if (OrderType()==OP_SELL && OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol()) {
if (LC>FCGD && FCGD>SCGD) OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, FireBrick);
} 
}
}    
}
return(0);
}