Questions from Beginners MQL4 MT4 MetaTrader 4 - page 103

 

Teach how to stop the EA and start it when a new candle appears.

 
msl271170:Teach how to stop the Expert Advisor and run it when a new candle appears.

The terminal has an example of an Expert Advisor Moving Average.mq4 - it has this:

//--- go trading only for first tiks of new bar
   if(Volume[0]>1) return;

Try this EA - it shows the start of a new bar

datetime LastTime;  // Время начала тика для побарного режима
void OnTick()
{
  if (Time[0] == LastTime) return;
  LastTime = Time[0];
  Alert("Новый бар");
}
 
STARIJ:

The terminal has an example of an Expert Advisor Moving Average.mq4 - it has this:

Try this EA - it shows the start of a new bar

I tried to insert it in my EA, but when I compile it, it gives me

Possible use of uninitialized variable 'LastTime'

 
msl271170: when compiling it gives: possible use of uninitialized variable 'LastTime'
Write to
datetime LastTime=0;  // Время начала тика для побарного режима    ГЛОБАЛЬНАЯ переменная за пределами функции !!!!!
void OnTick()
{
  if (Time[0] == LastTime) return;
  LastTime = Time[0];
  Alert("Новый бар");
}
For the program to work in MT5 use MT4Orders - library for MetaTrader 5
 
STARIJ:
Write to

Thank you, it's working.

 
msl271170:

Thank you, everything works.

What is wrong here?

res=OrderModify(OrderTicket(),OrderOpenPrice(),SL,OrderTakeProfit(),0,Blue);

the stop loss rollover failed

Error in the alert: error 1

 
msl271170:
What is wrong here?

res=OrderModify(OrderTicket(),OrderOpenPrice(),SL,OrderTakeProfit(),0,Blue);

the stop loss rollover failed

Error in the Alert: error 1

Insert above Alert("Ticket=",OrderTicket(), " SL=", SL); and see what it shows. And do this more often - many errors become clear immediately

Use MT4Orders - library for MetaTrader 5 when you transfer your program from MT4 to MT5

 
Good afternoon everyone. I have a question about MT4. I have a chart set up with japanese candlesticks, on TF H1 only 12 days fit in the window, so that the candlesticks were legible, if you click to zoom out the chart, the candlesticks turn into lines. I would like to put at least 16 days in the chart window, but so that the candles remain legible.
 
ualexzt:
Good afternoon everyone. I have a question about MT4. I have a chart set up with japanese candlesticks, on TF H1 only 12 days fit in the window, so that the candlesticks were legible, if you click to zoom out the chart, the candlesticks turn into lines. I would like to put at least 16 days in the chart window, but so that the candlesticks remain legible.

You need a MONITOR (resolution) ... a bigger one :)

 

Hi all.

How do I get rid of the following comment when compiling:

possible use of uninitialized variable 'SL1'

Reason: