Questions from Beginners MQL5 MT5 MetaTrader 5 - page 425

 
Tapochun:
You need to add your own enumeration to the code.

Can I have a code sample?

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

What do I need to add to make it like this?


 
Tapochun:
Error code?


130 stop loss does not change
 
Sergei Konoplev:

Can I have a code sample?

What do I need to add to make it like this?

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

input MY_ENUM Variant = ONE;
 
Leanid Aladzyeu:

stoplevel is not a good option for calculating the stop, especially as int

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

it's easier to be specific

try:

double CALC_SL=25;//величина стоп-лосса в пунктах
double severs_min_stop = CALC_SL*MarketInfo(symbol,MODE_POINT);
 
Leanid Aladzyeu:
While bidding, unpin the previous stop, stop received, etc.
 
Leanid Aladzyeu:

Where is the mistake?

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

I equalise the StoPlusses in Inite (it's easier, though not more reliable)

How do I get the value of indicator Zigzag? I did not find it in the help.

 
Leanid Aladzyeu:

I equalise the StoPlusses in Inite (it's easier, though not more reliable)

How do I get the value of indicator Zigzag? I did not find it in the help.

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

I've had a lot of trouble - they wrote an extra zero in the function.

Now I will try it - thanks.

 
Tapochun:
Instead of 0, substitute OrdersHistoryTotal()-1
Thank you very much!
Reason: