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

 
jarikn:
I have such a problem.
I need to open an order when the price Ask crosses e.g. a moving MA. i.e. Ask==MA. is it possible to do that? Or if the price is higher than MA by 3 points for example. Please advise

The correct condition for crossing from bottom to top, Ask was below or equal to the MA and became higher. Either it was on the previous bar and became on the current one, or by ticks, the previous tick and the last one.

 
Alexey Viktorov:

The correct condition would be a bottom-up crossing condition, Ask was below or equal to the MA and became higher. Either it was on the previous bar and became on the current bar, or by ticks, previous tick and last tick.

Thank you. It will be of the Open[0]<MA && Close[0]>MA type ???? if not, please show me an example.
 
jarikn:
Thank you. it will be like Open[0]<MA && Close[0]>MA ???? if not, please show me an example.

It's exactly like that, except it doesn't take into account the option that if the price is equal to the MA. Over time you will realise many variations on your own.

You can replace Open[0] with Close[1] and it may be even more reasonable. After all, Close[1] can be below the MA and Open[0] is already above it.

Close[0] == SymbolInfoDouble(_Symbol, SYMBOL_BID), but it does not really matter.

 
Alexey Viktorov:

It's exactly like that, except it doesn't take into account the option that if the price is equal to the MA. With time you will understand a lot of variants on your own.

Open[0] can be replaced with Close[1] and is probably more reasonable. Indeed, Close[1] may be below the MA and Open[0] is above it.

Close[0] == SymbolInfoDouble(_Symbol, SYMBOL_BID), but it does not matter much.

Got it. Thank you very much.
 
If there are 2 or more checks, which is faster withswitch orif?
 
Having tested the Expert Advisor with different brokers on MT5 with the simulation quality of 99-100% with the same input parameters I got completely different results: from cosmic profits to losses. Before that I purposely left MT4 because it is more difficult to achieve the same quality of modelling there. So what was the result? How would the Expert Advisor behave in real trading? Maybe somebody will give me a good tip?
 
ganri:
Having tested the Expert Advisor with different brokers on MT5 with the modeling quality of 99-100% with the same input parameters I got completely different results: from cosmic profits to losses. Before that I purposely left MT4 because it is more difficult to achieve the same quality of modelling there. So what was the result? How would the Expert Advisor behave in real trading? Maybe somebody will give me a good tip?

Try to test it on real ticks.

 
Alexey Viktorov:

Try testing on real ticks.

Same story: 2019 net profit differs by a factor of 12.9!!! Maybe it depends on the latency of the signal received at each broker? This is the only indicator that differs in the tester. However, setting a fixed delay value does not change the situation. Maybe just choose the "best" broker and don't bother?

 

What does this warning mean and what is the risk to the EA?


the size of local variables is too large (more than 512kb)

 
Viatcheslav Pashkov:

What does this warning mean and what is the risk to the EA?


the size of local variables is too large (more than 512kb)

And if developers didn't care about stack size, and it's 1MB by default, the array (is it?) declared on the stack immediately took half of it. So it's not a big deal, but if the robot crashes in run-time with stack overflow error, you now know one of the possible reasons)))

Reason: