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

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I want to check the condition on different instruments.
So that the external ones can be written as follows
I want to check the condition on different instruments.
I want to be able to write it in the external ones like this
Use an array instead of a variable
and check it in the loop.
To enter all this through the input, you need a string
"EURUSD, GBPUSD, USDJPY, USDCHF"
in the input to split it and put it into an array. There are string functions for this. And you can find examples of such manipulations in CodeBase.
An array is best defined as follows
It is better to set the array as follows
Hello. I have a problem with the indicators, it usually happens on m1 and m5. It looks like a jump on all indicators of the basement window and the main one at the same time, can be seen on the screenshots. The code of one of the indicators.
Use an array instead of a variable
and check it in the loop.
To enter all this via input you need a string
Inite split and shove it into an array. There are string functions for this. And you can find examples of such manipulations in CodeBase.
Sometimes it just says "UP" without currency pair. How to fix it?
Sometimes it just says "UP" without the currency pair. How to fix it?
Why do you need to loop for 100 iterations? Why do you need 100's of array?
Why not make it dynamic, and increase its size and fill the array as you find a new symbol in the initializing string?
And then loop in the number of iterations on the size of the filled array.
Have you checked what you have in the array?
Sometimes it just says "UP" without the currency pair. How can I fix it?
Make it like this
Dob. And in the inite, increase the array as you add a value to it
Sometimes it just says "UP" without the currency pair. How to fix it?
Well, try it:
About "...but if simultaneously on several pairs the condition is fulfilled, the alert is only on one pair..." I will say this:
You check the time on a symbol, but you write it into one single variable for all the symbols you have. Naturally, and there will only be an alert on the very first symbol on this current bar. You need an array of structures with two fields for each symbol - name field and time field, and already write alert times for each symbol into it.
For example, like this:
Sometimes it just says "UP" without the currency pair. How can I fix it?
The problem is in this line
Since I check several currencies on one bar, besides time I should also check the currency to avoid repeating the alert on one bar and one symbol but allow making an alert on the same bar with a different symbol. At first glance, we need one more array with flags whether the symbol is viewed or not.
In general either add symbol check to this line, or repeat cycle only on condition of new bar opening. But I have a fear that when there is a new bar on the symbol with this indicator, the new bar has not yet been drawn on the other symbol.
The conclusion: we must strain our head muscles to determine whether a new bar appears on each symbol separately, but at the same time not to stretch the number of lines to infinity. I have no ready-made solution. And I don't like to suggest it by writing code...