Questions from Beginners MQL5 MT5 MetaTrader 5 - page 585

 
barudkinarseniy:
Hello Comrades! Can you please tell me what the error is, the compiler gives a warning about possible data loss(
An explicit type conversion is needed:
int ts = (int)SymbolInfoInteger(Symbol(),SYMBOL_TRADE_STOPS_LEVEL);
 
Vasiliy Sokolov:
An explicit type conversion is needed:
Thank you! I can't remember all these nuances of conversion))
 
barudkinarseniy:
Thank you! I can't remember all these nuances of conversion))
Often it is this:SymbolInfoInteger that is misleading. That's why it's better to look in the help once again.
 
Please tell me what the problem is. The compiler does not give out any errors. In the tester, in most transactions all is well, but sometimes the error handler in the printer does not write the correct stops and open price writes with 6 decimal places: Invalid price (stop) OrderSendX(symbol=AUDCAD,cmd=SELL,volume=0.29,price=0.995120,slippage=50,stoploss=0.996470,takeprofit=0.991070)

//+------------------------------------------------------------------+
//Открытие ордеров
void OrderOpen(int otype, double OpenPriceW1)
{
 int msl = (int) MarketInfo(Symbol(),MODE_STOPLEVEL);
 int stsl = (int) SymbolInfoInteger(Symbol(),SYMBOL_TRADE_STOPS_LEVEL);
 
 if(otype == OP_BUY)
 {
  StepSTBAY = (int)(Ask/Point - OpenPriceW1/Point);
  
  if(StepSTBAY < msl) StepSTBAY = msl;
  if(StepSTBAY < stsl) StepSTBAY = StepSTBAY + stsl;
  
  lots = LotsByRisk(OP_BUY,StepSTBAY);
  ST_BAY = NormalizeDouble(Ask - StepSTBAY*Point,Digits);
  TP_BAY = NormalizeDouble(Ask + StepSTBAY*RR*Point,Digits);
      
  OrderSendX(Symbol(),OP_BUY,lots,Ask,slipage,ST_BAY,TP_BAY,"",Magic,0,clrGreen);
 }
 if(otype == OP_SELL)
 {
  StepSTSELL = (int)(OpenPriceW1/Point - Bid/Point);
  
  if(StepSTSELL < msl) StepSTSELL = msl;
  if(StepSTSELL < stsl) StepSTSELL = StepSTSELL + stsl;
  
  lots = LotsByRisk(OP_SELL,StepSTSELL);
  ST_SELL = NormalizeDouble(Bid + StepSTSELL*Point,Digits);
  TP_SELL = NormalizeDouble(Bid - StepSTSELL*RR*Point,Digits);
     
  OrderSendX(Symbol(),OP_SELL,lots,Bid,slipage,ST_SELL,TP_SELL,"",Magic,0,clrRed);
 }
}
//+------------------------------------------------------------------+
 
barudkinarseniy:
Please tell me what the problem is. The compiler does not give out any errors. In the tester, most trades are ok, but sometimes the error handler in the printer writes wrong stops and open price writes with 6 decimal places: Invalid price (stop) OrderSendX(symbol=AUDCAD,cmd=SELL,volume=0.29,price=0.995120,slippage=50,stoploss=0.996470,takeprofit=0.991070)

The first thing that caught my eye was this code fragment, these two functions are the same
 int msl = (int) MarketInfo(Symbol(),MODE_STOPLEVEL);
 int stsl = (int) SymbolInfoInteger(Symbol(),SYMBOL_TRADE_STOPS_LEVEL);
the first is old, the second is new
 
Can you please advise whether an EA will continue to work if I change the profile in MT4? Or do all EA windows have to be open in the same profile to work permanently?
 

Good day dear programmers!

Is it possible to write a program in MQL4 that will draw a chart in the form of candlesticks according to calculated values at different timeframes? Maybe there are ready-made codes for such problems?

 
Ivan Molchanov:
Can you please advise whether the EA will continue working when I change the profile in MT4? Or do all EA windows have to be opened in one profile to work permanently?

Tools => Settings



and do what you want...

 
Hello, could you please tell me how to prescribe in the set parameters extern timeframe selection? It would be exactly a selection and not to print manually.
 
barudkinarseniy:
Hello, could you please tell me how to write in the set parameters extern to select the timeframe? That would be exactly a selection and not print manually.

Use ENUM_TIMEFRAMES enumeration type variable.