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

//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);

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

//Exit
if (IsInvested) {
for (i=OrdersTotal()-1; i>=0; i--) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderType()==OP_SELL && OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol()) {
if(LC>GD1c) CloseTrade(OrderType(), OrderTicket(), OrderLots(), Ask, Slippage, FireBrick);
}
if (OrderType()==OP_BUY && OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol()) {
if(LC<GD1c) CloseTrade(OrderType(), OrderTicket(), OrderLots(), Bid, Slippage, DarkBlue);
}
}
}
}