Fragen von Neueinsteigern zu MQL4 und MQL5, Hilfe und Diskussion über Algorithmen und Codes - Seite 60

 
Sergey Gritsay:
Es gab einen Fehler im Block zum Schließen der Bestellung, der behoben wurde.
Vielen Dank, ich werde es jetzt überprüfen!
 

Können Sie mir sagen, warum die Bestellungen nicht geöffnet werden? Er gibt einen Fehler 130

input double RSIperiod=14;
input double Urov_70=70;
input double Urov_30=30;
input double Lot=0.01;
input int    TakeProfit=100;
input int    StopLoss=100;
input int    MagicNumber=523;
input int    slippage=30;

double tp=0,sl=0,OrderBuy=0,OrderSell=0;
int tiket;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   tp=NormalizeDouble(TakeProfit*_Point,_Digits);
   sl=NormalizeDouble(StopLoss*_Point,_Digits);
  return(INIT_SUCCEEDED);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {

   for(int i=0; i<OrdersTotal(); i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         if(OrderSymbol()==_Symbol && OrderMagicNumber()==MagicNumber)
           {
            if(OrderType()==OP_BUY){}
            if(OrderType()==OP_SELL){}
           }
     }
   double rsi=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,0);
   double rsi1=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,1);
//+------------------------------------------------------------------+
   if(OrderBuy<1 && rsi>Urov_70 && rsi1<Urov_70)
     {
     tiket= OrderSend(_Symbol,OP_BUY,Lot,Ask,slippage,sl,tp,NULL,MagicNumber,0,clrBlue);
     }
   if(OrderSell<1 && rsi<Urov_30 && rsi1>Urov_30)
     {
      tiket=OrderSend(_Symbol,OP_SELL,Lot,Bid,slippage,sl,tp,NULL,MagicNumber,0,clrRed);
     }
  }
//+------------------------------------------------------------------+

 

Ich bin kein Profi - ich könnte mich irren!

diese Linien

tp=NormalizeDouble(TakeProfit*_Point,_Digits);

sl=NormalizeDouble(StopLoss*_Point,_Digits);

Sie werden es besser verstehen, wenn Sie so vorgehen

tp=NormalizeDouble(Ask+ TakeProfit*_Point,_Digits);

sl=NormalizeDouble(Bid- StopLoss*_Point,_Digits);

Außerdem brauchen Sie die globalen Variablen tp und sl nicht auf Null zu setzen.

 
Ibragim Dzhanaev:

Können Sie mir sagen, warum die Bestellungen nicht geöffnet werden? Fehler 130

...

Fehler 130 ist ein enger Stopp. Überprüfen Sie sie auf den Mindestabstand für die Einstellung des Stopps - StopLevel

Und ja, wie oben bereits erwähnt - Sie berechnen sie falsch.

 

Das habe ich getan - es hat sich nichts geändert (

Ja, ich habe es gerade angekündigt.

input double RSIperiod=14;
input double Urov_70=70;
input double Urov_30=30;
input double Lot=0.01;
input int    TakeProfit=100;
input int    StopLoss=100;
input int    MagicNumber=523;
input int    slippage=30;

double tp=0,sl=0,OrderBuy=0,OrderSell=0;
int tiket;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   tp=NormalizeDouble(Ask+TakeProfit*_Point,_Digits);
   sl=NormalizeDouble(Bid-StopLoss*_Point,_Digits);
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {

   for(int i=0; i<OrdersTotal(); i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         if(OrderSymbol()==_Symbol && OrderMagicNumber()==MagicNumber)
           {
            if(OrderType()==OP_BUY){}
            if(OrderType()==OP_SELL){}
           }
     }
   double rsi=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,0);
   double rsi1=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,1);
//+------------------------------------------------------------------+

   double StopLossLevel;
   double TakeProfitLevel;
   if(StopLoss>0) StopLossLevel=Bid-StopLoss*Point; else StopLossLevel=0.0;
   if(TakeProfit>0) TakeProfitLevel=Ask+TakeProfit*Point; else TakeProfitLevel=0.0;
///---
  
   if(OrderBuy<1 && rsi>Urov_70 && rsi1<Urov_70)
     {
      tiket=OrderSend(_Symbol,OP_BUY,Lot,Ask,slippage,sl,tp,NULL,MagicNumber,0,clrBlue);
     }
   if(OrderSell<1 && rsi<Urov_30 && rsi1>Urov_30)
     {
      tiket=OrderSend(_Symbol,OP_SELL,Lot,Bid,slippage,sl,tp,NULL,MagicNumber,0,clrRed);
     }
  }
//+------------------------------------------------------------------+
 
Ibragim Dzhanaev:

Das habe ich getan - es hat sich nichts geändert (

input double RSIperiod=14;
input double Urov_70=70;
input double Urov_30=30;
input double Lot=0.01;
input int    TakeProfit=100;
input int    StopLoss=100;
input int    MagicNumber=523;
input int    slippage=30;

double tp=0,sl=0,OrderBuy=0,OrderSell=0;
int tiket;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   tp=NormalizeDouble(Ask+TakeProfit*_Point,_Digits);
   sl=NormalizeDouble(Bid-StopLoss*_Point,_Digits);
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {

   for(int i=0; i<OrdersTotal(); i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         if(OrderSymbol()==_Symbol && OrderMagicNumber()==MagicNumber)
           {
            if(OrderType()==OP_BUY){}
            if(OrderType()==OP_SELL){}
           }
     }
   double rsi=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,0);
   double rsi1=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,1);
//+------------------------------------------------------------------+

   double StopLossLevel;
   double TakeProfitLevel;
   if(StopLoss>0) StopLossLevel=Bid-StopLoss*Point; else StopLossLevel=0.0;
   if(TakeProfit>0) TakeProfitLevel=Ask+TakeProfit*Point; else TakeProfitLevel=0.0;
///---
  
   if(OrderBuy<1 && rsi>Urov_70 && rsi1<Urov_70)
     {
      tiket=OrderSend(_Symbol,OP_BUY,Lot,Ask,slippage,sl,tp,NULL,MagicNumber,0,clrBlue);
     }
   if(OrderSell<1 && rsi<Urov_30 && rsi1>Urov_30)
     {
      tiket=OrderSend(_Symbol,OP_SELL,Lot,Bid,slippage,sl,tp,NULL,MagicNumber,0,clrRed);
     }
  }
//+------------------------------------------------------------------+


Verschieben Sie die Berechnung der Haltestellen in den ontischen

   tp=NormalizeDouble(Ask+TakeProfit*_Point,_Digits);
   sl=NormalizeDouble(Bid-StopLoss*_Point,_Digits);


..

 

tp=NormalizeDouble(Ask+TakeProfit*_Point,_Digits);
sl=NormalizeDouble(Bid-StopLoss*_Point,_Digits);

Dies ist die Variante für OP_BUY

für OP_SELL

tp=NormalizeDouble(Bid-TakeProfit*_Point,_Digits);

sl=NormalizeDouble(Ask+StopLoss*_Point,_Digits);
 

Fehler 148. Bei jedem Häkchen öffnet es sich.

input double RSIperiod=14;
input double Urov_70=70;
input double Urov_30=30;
input double Lot=0.01;
input int    TakeProfit=100;
input int    StopLoss=100;
input int    MagicNumber=523;
input int    slippage=30;

double tp,sl,OrderBuy=0,OrderSell=0;
int tiket;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {

   for(int i=0; i<OrdersTotal(); i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         if(OrderSymbol()==_Symbol && OrderMagicNumber()==MagicNumber)
           {
            if(OrderType()==OP_BUY){}
            if(OrderType()==OP_SELL){}
           }
     }
   double rsi=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,0);
   double rsi1=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,1);
//+------------------------------------------------------------------+

   double StopLossLevel;
   double TakeProfitLevel;
   if(StopLoss>0) StopLossLevel=Bid-StopLoss*Point; else StopLossLevel=0.0;
   if(TakeProfit>0) TakeProfitLevel=Ask+TakeProfit*Point; else TakeProfitLevel=0.0;

   tp=NormalizeDouble(Ask+TakeProfit*_Point,_Digits);
   sl=NormalizeDouble(Bid-StopLoss*_Point,_Digits);

   tp=NormalizeDouble(Bid-TakeProfit*_Point,_Digits);
   sl=NormalizeDouble(Ask+StopLoss*_Point,_Digits);

///---

   if(OrderBuy<1 && rsi>Urov_70 && rsi1<Urov_70)
     {
      tiket=OrderSend(_Symbol,OP_BUY,Lot,Ask,slippage,sl,tp,NULL,MagicNumber,0,clrBlue);
     }
   if(OrderSell<1 && rsi<Urov_30 && rsi1>Urov_30)
     {
      tiket=OrderSend(_Symbol,OP_SELL,Lot,Bid,slippage,sl,tp,NULL,MagicNumber,0,clrRed);
     }
  }
//+------------------------------------------------------------------+
 

zwei verschiedene Werte von sl tp

Sie können unterschiedlich bezeichnet werden: slSell , slBuy, tpSell, tpBuy

 
RichLux:

zwei verschiedene Werte von sl tp

Sie können unterschiedlich bezeichnet werden: slSell , slBuy, tpSell, tpBuy

Hat nicht geholfen (

double tp,sl,OrderBuy=0,OrderSell=0;
double slSell,slBuy,tpSell,tpBuy;
int tiket;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {

   for(int i=0; i<OrdersTotal(); i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         if(OrderSymbol()==_Symbol && OrderMagicNumber()==MagicNumber)
           {
            if(OrderType()==OP_BUY){}
            if(OrderType()==OP_SELL){}
           }
     }
   double rsi=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,0);
   double rsi1=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,1);
//+------------------------------------------------------------------+

   double StopLossLevel;
   double TakeProfitLevel;
   if(StopLoss>0) StopLossLevel=Bid-StopLoss*Point; else StopLossLevel=0.0;
   if(TakeProfit>0) TakeProfitLevel=Ask+TakeProfit*Point; else TakeProfitLevel=0.0;

   tpBuy=NormalizeDouble(Ask+TakeProfit*_Point,_Digits);
   slBuy=NormalizeDouble(Bid-StopLoss*_Point,_Digits);

   tpSell=NormalizeDouble(Bid-TakeProfit*_Point,_Digits);
   slSell=NormalizeDouble(Ask+StopLoss*_Point,_Digits);
///---
   if(OrderBuy<1 && rsi>Urov_70 && rsi1<Urov_70)
     {
      tiket=OrderSend(_Symbol,OP_BUY,Lot,Ask,slippage,sl,tp,NULL,MagicNumber,0,clrBlue);      
     }      
   if(OrderSell<1 && rsi<Urov_30 && rsi1>Urov_30)
     {
      tiket=OrderSend(_Symbol,OP_SELL,Lot,Bid,slippage,sl,tp,NULL,MagicNumber,0,clrRed);      
     }
  }
//+------------------------------------------------------------------+