# Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 684

Sprut112:
How to explain to the Expert Advisor (standard ma) that we should buy (sell) only at the moment of crossing the averages, and not in general, when ma_1>ma_2. And he constantly buys, he can't stop

You need to remember in the variable that the crossing has already happened, and when it crosses back, rewrite the variable that it has already crossed again. This is variant №1.

Look at the history of transactions, if the last Buy, then wait for the signal to Sell, and then alternate like this, this way is more reliable

Vitaly Muzichenko:

You need to remember in the variable that the crossing has already happened, and when it crosses back, rewrite the variable that it has already crossed again. This is variant №1.

Look at the history of trades, if the last Buy, then wait for the signal to Sell, and then alternate in a circle, this way is more reliable

Something very wise, can't you add something to the condition?

Sprut112:
Isn't it complicated to add something to the condition itself?

What's the big deal? It's not hard to work with history, and it's even easier to write the intersection into a variable.

Vitaly Muzichenko:

You need to remember in the variable that the crossing has already happened, and when it crosses back, rewrite the variable that it has already crossed again. This is variant №1.

Look at the history of transactions, if the last Buy, we will wait for the signal to Sell, and so we will alternate around, this method is more reliable

If we are talking about the last MA crossing, trading along the MA is usually easier:

1. control the new bar

2. at the new bar we check the condition:

ma_1[1] >ma_2[1] && ma_1[2]<ma_2[2] - top-down crossover

or ma_1[1]<ma_2[1] && ma_1[2]>ma_2[2] - top-down crossover

if it does not make any difference which MA crosses from above, then both conditions shall be used:

`if((ma_1[1]>ma_2[1]  && ma_1[2]<ma_2[2]) || (ma_1[1]<ma_2[1]  && ma_1[2]>ma_2[2])) // пересечение!!!`

Vitaly Muzichenko:

What's the big deal? It's not hard to work with history, and it's even easier to write the intersection into a variable.

All right, thanks.

Igor Makanu:

When it comes to the last MA crossing, trading on the MA is usually easier:

1. monitor the new bar

2. At the new bar we check the condition:

ma_1[1] >ma_2[1] && ma_1[2]<ma_2[2] - top-down crossover

or ma_1[1]<ma_2[1] && ma_1[2]>ma_2[2] - top-down crossover

if it does not make any difference which MA crosses from above, then both conditions shall be used:

Well, that still makes sense.

Friends, could you please tell me why when optimizing an EA, the \Terminal\tester\logs folder accumulates huge log files of the following content:

2 00:00:01.796 2014.04.01 10:57:30 Tester: #102 deleted due expiration

2 00:00:02.221 2014.04.24 08:59:59 Tester: #103 deleted due expiration

2 00:00:02.326 2014.04.30 12:57:30 Tester: #104 deleted due expiration

2 00:00:02.852 2014.05.29 10:20:00 Tester: order #105, sell 0.10 EURUSD is opened at 1.35871

0 00:00:02.852 2014.05.29 10:22:30 Tester: stop loss #105 at 1.35910 (1.35876 / 1.35926)

2 00:00:02.941 2014.06.04 01:20:00 Tester: order #106, buy 0.10 EURUSD is opened at 1.36306

0 00:00:02.941 2014.06.04 01:22:30 Tester: stop loss #106 at 1.36259 (1.36253 / 1.36303)

2 00:00:03.133 2014.06.13 14:03:20 Tester: order #107, sell 0.10 EURUSD is opened at 1.35382

And some of my EAs write such logs and some don't. I cannot make it out.

How is that possible?

How can I make the input variables in the EA code immutable? For example p, I am using an EA on a Macd and I don't want its variables to be displayed in the settings window

Sprut112:
How to make input variables unchangeable in EA code? For example p, I am using an EA on Macd and I don't want its variables to be displayed in the settings window

read help by pressing F1 in the source code on "commands" on input or extern ;)