Questions from Beginners MQL5 MT5 MetaTrader 5 - page 493

 
INGFX:

Vladimir, thank you for your patience and help!
Really made a mistake in the code ...
I'll be more careful from now on.

Yay! I can now go to sleep in peace.
 

Good afternoon.

Please advise how to solve the problem. When trying to send a file with SendFTP() there is a 4014 error - System function is not allowed to be called.

The FTP settings are OK - reports and test file are sent.

Thank you in advance.

 
Nikita Solodko:

Good afternoon.

Please advise how to solve the problem. When trying to send a file with SendFTP() there is a 4014 error - System function is not allowed to be called.

The FTP settings are OK - reports and test file are sent.

Thank you in advance.

Are you trying to send from indicator by any chance?
 
Karputov Vladimir:
Are you by any chance trying to send from an indicator?
Accidentally, yes... Why can't you?
 
Nikita Solodko:
Accidentally yes... Why can't you?
You can't because in case of ftp network delays, the indicator may slow down the whole terminal. But you can do it from the EA.
 
Karputov Vladimir:
Not possible due to the fact that in case of ftp network delays, the indicator may slow down the entire terminal. But from the EA, you are welcome to do so.
Thank you.
 

Hi all. I am writing my first EA and I'm facing a problem I can't win.

void OnTick()
{
 datetime EaStartTime = StringToTime(StartTime);  // время начала работы советника
 datetime EaEndTime = StringToTime(EndTime);      // время окончания работы советника
 datetime CurrTime = TimeCurrent();               // это если нужно взять время терминала
 if (CurrTime < EaStartTime || CurrTime >= EaEndTime)
  return;                                         // если еще не время торговать - выход
{
 PriceLow=iEnvelopes(NULL,0,MA_Period,MA_Shift,MA_Method,Applied_Price,Deviation,0,1);
 PriceHigh =iEnvelopes(NULL,0,MA_Period,MA_Shift,MA_Method,Applied_Price,Deviation,1,1);
 MacdCurrent=iMACD(NULL,0,InpFastEMA,InpSlowEMA,InpSignalSMA,PRICE_CLOSE,MODE_MAIN,0);
 SignalCurrent=iMACD(NULL,0,InpFastEMA,InpSlowEMA,InpSignalSMA,PRICE_CLOSE,MODE_SIGNAL,0);
 SignalMAPrevious=iMA(NULL,0,InpMAPeriod,InpMAShift,InpMAMethod,PRICE_MEDIAN,1);
 SignalMAThis=iMA(NULL,0,InpMAPeriod,InpMAShift,InpMAMethod,PRICE_MEDIAN,0);
 PriceCurrentOpen=iOpen(NULL,0,1);
 PriceCurrentClose=iClose(NULL,0,1);
  if (CountTrades()==0) CheckForOpen();
   else
  {
   if(CountTrades()<max_trades) CheckForOpen();
  }
 }
}  
void CheckForOpen()
{
//-----Ставим ордер на покупку.
 if(PriceCurrentOpen<PriceLow&&PriceCurrentOpen<PriceCurrentClose&&SignalCurrent<MacdCurrent&&SignalMAPrevious<SignalMAThis)
 {
  ticket=OrderSend(NULL,OP_BUY,Lots,Ask,slippage,0,0,"5",magic,0,Blue);
   if(ticket>0)
    return; 
 }
//-----Ставим ордер на продажу.
 if(PriceCurrentOpen>PriceLow&&PriceCurrentOpen>PriceCurrentClose&&SignalCurrent>MacdCurrent&&SignalMAPrevious>SignalMAThis)
 {
  ticket=OrderSend(NULL,OP_SELL,Lots,Bid,slippage,0,0,"5",magic,0,Red);
   if(ticket>0)
    return; 
 }
}

My EA should give a buy and sell signal if the previous bar was opened outside the channel"Envelopes",if it was above the channel, then sell, if it was below buy, but in fact it always sends orders when it feels like, it may go long inside the channel and suddenly start buying orders, although all the other conditions are ok, if the sell signal sells and buy, buy.

How to make him buy one order per bar, rather than all at once allowed number of orders every second?

 
Nickolay72:

Hi all. I am writing my first EA and I'm facing a problem I can't win.

My EA should give a buy and sell signal if the previous bar was opened outside the channel"Envelopes",if it was above the channel, then sell, if it was below buy, but in fact it always sends orders when it feels like, it may go long inside the channel and suddenly start buying orders, although all the other conditions are ok, if the sell signal sells and buy, buy.

How to make him buy one order per bar, rather than all at once allowed number of orders every second?

Good day. Before sending an order, check if you already have open positions. If there are any, do not send an order to open, otherwise send it. As far as I understand your code, this function CountTrades() deals with it. So, check values returned by this function.
 
Until yesterday one order was opened and the next one will not open until the next order is opened, but how to make my EA open the orders when the previous bar was above (below) the channel?
Files:
Zmey.mq4  5 kb
 
Nickolay72:
Until yesterday I had one order each, and while there is an order, the next one will not open.How to make my EA open orders according to the order when the previous bar has opened above (below) the channel? Right now, most of the orders are losing, because they are not opened according to the conditions.
If Open Bar 1 is higher/lower than the channel.
Reason: