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

Sorry, versteh nur Bahnhof. Weshalb so einige Sachen wohl keinen Sinn ergeben.

Edit:Jetzt sinds nur noch 5 Fehler.

Code:
//Globale Variablen
///Zeit/Open Orders Von/Bis
extern datetime Time Open_Orders_From = 13:00:00;
extern datetime Time Open_Orders_Till = 17:00:00;
extern int TimeFrame = 30;
extern string TimeFrames= "Current:0;M1:1; M5:5; M15:15; M30:30; H1:60; H4:240; D1:1440";

//GDs
extern int Fast_GD = 3;
extern int Slow_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;
int Slippage = 1000;
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 C=iClose(Symbol(), TimeFrame, 0);
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);
datetime F = TimeCurrent,(Open_Orders_From);
datetime T = TimeCurrent,(Open_Orders_Till);

//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>GD1c && GD1c>GD2c && C>LC) OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0, Name + " Buy(#" + MagicNumber + ")", MagicNumber, 0, Blue);
if (Spread <= Max_Spread && LC<GD1c && GD1c<GD2c && C<LC) 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) OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, DarkBlue);
}
if (OrderType()==OP_SELL && OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol()) {
if(LC>GD1c && GD1c>GD2c) OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, FireBrick);
} 
}
}    
}

Geändert von MA-EA (20.03.16 um 19:28 Uhr)