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

Es gibt im MT4 Strategietester immer die Meldung "Order Close Error 3". Hab 0 Ahnung, was hier falsch ist. Edit:Beim Kompilieren gibts keine Fehler oder Probleme.
Code:
//Kurs
double C = iClose(Symbol(), TimeFrame, 1);

//GDs
double F_MA = iMA(Symbol(), TimeFrame, Fast_MA, GD_Shift, GD_Type, PRICE_CLOSE, 1);//5
double M_MA = iMA(Symbol(), TimeFrame, Middle_MA, GD_Shift, GD_Type, PRICE_CLOSE, 1);//10
double S_MA = iMA(Symbol(), TimeFrame, Slow_MA, GD_Shift, GD_Type, PRICE_CLOSE, 1);//20
//-------------------------------------------------------------------------------------------------------------

//Up-Down-Berechnungen
//Open Buy:O_B_F>M & O_B_M>S
double C_F_MA = C-F_MA;
double O_B_F_MA = F_MA+C_F_MA;

double C_M_MA = C-M_MA;
double O_B_M_MA = M_MA+C_M_MA;

//Open Sell:O_B_F<M & O_B_M<S
double F_MA_C = F_MA-C;
double O_S_F_MA = F_MA-F_MA_C;

double M_MA_C = M_MA-C;
double O_S_M_MA = M_MA-M_MA_C;

//Close Buy:C_B<M_MA
//Zeile 84
double C_B = F_MA-F_MA_C;//?
//Close Sell
//Zeile 91
double C_S = F_MA-C_F_MA;
//--------------------------------------------------------------------------------------------------------------

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

if (!IsInvested){
if (TC>F && TC<T && S<=MS && C!=S_MA && C_F_MA>0.0 && O_B_F_MA>M_MA && O_B_M_MA>S_MA) OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0, Name + " Buy(#" + MagicNumber + ")", MagicNumber, 0, Blue);
if (TC>F && TC<T && S<=MS && C!=S_MA && F_MA_C>0.0 && O_S_F_MA<M_MA && O_S_M_MA<S_MA) 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((C!=S_MA && F_MA_C>0.0 && C_B<M_MA) || (CAA=true && TC>CA)) OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, DarkBlue);}

if (OrderType()==OP_SELL && OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol()){
if((C!=S_MA && C_F_MA>0.0 && C_S>M_MA) || (CAA=true && TC>CA)) OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, FireBrick);}}}}
return(0);}