Questions des débutants MQL5 MT5 MetaTrader 5 - page 425

 
Tapochun:
Vous devez ajouter votre propre énumération au code.

Puis-je avoir un exemple de code ?

extern string Variant                = "One, Two, Three";

Que dois-je ajouter pour que ce soit comme ça ?


 
Tapochun:
Un code d'erreur?


130 stop loss ne change pas
 
Sergei Konoplev:

Puis-je avoir un exemple de code ?

Que dois-je ajouter pour que ce soit comme ça ?

// На глобальном уровне
enum MY_ENUM
{
 ONE,    // One
 TWO,    // Two
 THREE   // Three
};

input MY_ENUM Variant = ONE;
 
Leanid Aladzyeu:

stoplevel n'est pas une bonne option pour calculer l'arrêt, d'autant plus que int

130:    "Слишком близкие стопы или неправильно рассчитанные или ненормализованные цены в стопах (или в цене открытия отложенного ордера)."

il est plus facile d'être précis

essayez :

double CALC_SL=25;//величина стоп-лосса в пунктах
double severs_min_stop = CALC_SL*MarketInfo(symbol,MODE_POINT);
 
Leanid Aladzyeu:
Pendant l'enchère, débrochez l'arrêt précédent, l'arrêt reçu, etc.
 
Leanid Aladzyeu:

Où est l'erreur ?

//+------------------------------------------------------------------+
   double CorrectStopLoss(string sy,int op,double price_set,double stop_loss) {
      if(stop_loss==0) return(0);
      double pt=SymbolInfoDouble(sy,SYMBOL_POINT);
      double price=(op==OP_BUY)?SymbolInfoDouble(sy,SYMBOL_BID):(op==OP_SELL)?SymbolInfoDouble(sy,SYMBOL_ASK):price_set;
      int lv=StopLevel(sy), dg=(int)SymbolInfoInteger(sy,SYMBOL_DIGITS);
      if(op==OP_BUY || op==OP_BUYLIMIT || op==OP_BUYSTOP) return(NormalizeDouble(fmin(price-(lv+1)*pt,stop_loss),dg));
      else return(NormalizeDouble(fmax(price+(lv+1)*pt,stop_loss),dg));
   }
//+------------------------------------------------------------------+
   double CorrectStopLoss(string sy,int op,double price_set,int stop_loss) {
      if(stop_loss==0) return(0);
      double pt=SymbolInfoDouble(sy,SYMBOL_POINT);
      double price=(op==OP_BUY)?SymbolInfoDouble(sy,SYMBOL_BID):(op==OP_SELL)?SymbolInfoDouble(sy,SYMBOL_ASK):price_set;
      int lv=StopLevel(sy), dg=(int)SymbolInfoInteger(sy,SYMBOL_DIGITS);
      if(op==OP_BUY || op==OP_BUYLIMIT || op==OP_BUYSTOP) return(NormalizeDouble(fmin(price-(lv+1)*pt,price-stop_loss*pt),dg));
      else return(NormalizeDouble(fmax(price+(lv+1)*pt,price+stop_loss*pt),dg));
   }
//+------------------------------------------------------------------+
   double CorrectTakeProfit(string sy,int op,double price_set,double take_profit) {
      if(take_profit==0) return(0);
      double pt=SymbolInfoDouble(sy,SYMBOL_POINT);
      double price=(op==OP_BUY)?SymbolInfoDouble(sy,SYMBOL_BID):(op==OP_SELL)?SymbolInfoDouble(sy,SYMBOL_ASK):price_set;
      int lv=StopLevel(sy), dg=(int)SymbolInfoInteger(sy,SYMBOL_DIGITS);
      if(op==OP_BUY || op==OP_BUYLIMIT || op==OP_BUYSTOP) return(NormalizeDouble(fmax(price+(lv+1)*pt,take_profit),dg));
      else return(NormalizeDouble(fmin(price-(lv+1)*pt,take_profit),dg));
   }
//+------------------------------------------------------------------+
   double CorrectTakeProfit(string sy,int op,double price_set,int take_profit) {
      if(take_profit==0) return(0);
      double pt=SymbolInfoDouble(sy,SYMBOL_POINT);
      double price=(op==OP_BUY)?SymbolInfoDouble(sy,SYMBOL_BID):(op==OP_SELL)?SymbolInfoDouble(sy,SYMBOL_ASK):price_set;
      int lv=StopLevel(sy), dg=(int)SymbolInfoInteger(sy,SYMBOL_DIGITS);
      if(op==OP_BUY || op==OP_BUYLIMIT || op==OP_BUYSTOP) return(NormalizeDouble(fmax(price+(lv+1)*pt,price+take_profit*pt),dg));
      else return(NormalizeDouble(fmin(price-(lv+1)*pt,price-take_profit*pt),dg));
   }
//+------------------------------------------------------------------+
   int StopLevel(string sy) {
      int sp=(int)SymbolInfoInteger(sy,SYMBOL_SPREAD);
      int lv=(int)SymbolInfoInteger(sy,SYMBOL_TRADE_STOPS_LEVEL);
      return((lv==0)?sp*2:lv);
      }
//+------------------------------------------------------------------+
 

J'égalise les StoPlusses dans Inite (c'est plus facile, mais pas plus fiable).

Comment puis-je obtenir la valeur de l'indicateur Zigzag? Je ne l'ai pas trouvé dans l'aide.

 
Leanid Aladzyeu:

J'égalise les StoPlusses dans Inite (c'est plus facile, mais pas plus fiable).

Comment puis-je obtenir la valeur de l'indicateur Zigzag ? Je ne l'ai pas trouvé dans l'aide.

Via iCustom.
 
new-renaif(prevTime!=iTime(Symbol(),PERIOD_M5,0,0))

J'ai eu beaucoup de problèmes - ils ont écrit un zéro supplémentaire dans la fonction.

Je vais maintenant l'essayer - merci.

 
Tapochun:
Au lieu de 0, substituez OrdersHistoryTotal()-1
Merci beaucoup !