Questions from Beginners MQL5 MT5 MetaTrader 5 - page 577
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
Well, I would form it all into a function, and call it when I need it - even at every tick (if it is reasonable and necessary), or at opening of a new candle - for example, once an hour, if we work at H1.
With the function, of course, it's handy. I've got the code figured out. It's clear now. I will think, how to bring it to those purposes I want and understand, when and at what stage to take the necessary data.
If it was outright "the height of recklessness", it would be banned.
WinAPI greatly extends the capabilities of MQL. And you can do something stupid even without dll.
And here is an example of string passing to the clipboard:
Well done, and with comments too.
Thank you.
Here is another question.
Would it be possible to emulate a mouse click at given coordinates?
Great, and with a commentary too.
Thank you.
One more question.
Is it possible to make an emulation of a mouse click at the given coordinates?
Great, and with a commentary too.
Thank you.
One more question.
Is it possible to make an emulation of a mouse click at the given coordinates?
Yes, we can.
Well, I would form it all into a function and call it when I needed - at every tick (if needed and reasonable) or at opening of a new candle - for example, once an hour, if we work with H1.
Artem, I understand correctly, if we have a loop:for(int i=0; i<copy_bars; i++) and there is a loop for(int j=0; j<copy_bars; j++) where if(j==i) continue; ,
it will mean that the counting is parallel and if we have roughly 5 candlesticks, the comparison will continue:
1 with 1 - discard.
1 with 2, 1 with 3, 1 with 4, 1 with 5.
Then a cycle will start where it will be:
2 with 1, 2 with 3, 2 with 4, 2 with 5.
and so on.
Is this how it's going to be?
Artem, I understand correctly, if we have a loop:for(int i=0; i<copy_bars; i++) and there is a loop for(int j=0; j<copy_bars; j++) where if(j==i) continue; ,
it will mean that the counting is parallel and if we have roughly 5 candlesticks, the comparison will continue:
1 with 1 - discard.
1 with 2, 1 with 3, 1 with 4, 1 with 5.
Then a cycle will start where it will be:
2 with 1, 2 with 3, 2 with 4, 2 with 5.
and so on.
Will it be the same?
Yes.
Another question: If we don't need to compare the current candle, then don't we need to start the count from 1 and not zero?
Or should we understand that here 0 is candle 1, 1 is candle 2, etc.?
Another question: If we don't need to compare the current candle, then don't we need to start the count from 1 and not zero?
or should we understand that here 0 is candle 1, 1 is candle 2, etc.?
Here zero is the beginning of the array. And in the array we write the candlesticks from the first to ..., not "to", but in the number we need:
1 is the number of candlestick to copy, and copy_bars is the number of candlesticks to copy.
Therefore, array[] contains the needed candlestick in the cell with index 0 - either 1 or 1+copy_bars-1. Depending on indexing direction of array[] (ArraySetAsSeries() sets the indexing direction, which can be checked using ArrayGetAsSeries(), ArrayIsSeries())
Here zero is the beginning of the array. And in the array we write candlesticks from first to ..., not "to", but in number of candlesticks we need:
1 is the number of candlestick to copy, and copy_bars is the number of candlesticks to copy.
Therefore, array[] contains the required candle in the cell with index 0 - either 1 or 1+copy_bars-1. Depending on indexing direction of array[] (ArraySetAsSeries() sets indexing direction, which can be checked with ArrayGetAsSeries(), ArrayIsSeries())
This programming. The further into the woods....
I first just checked what it shows via Alert. It seems to be vice versa, i.e. the candle closest to the current one has maximal number.
Then I checked it via:
bool series=ArrayIsSeries(dataCandle);
Alert (series);
and the script shows "false".
By my logic, if false is on the wrong end, then true will be on the right end.
I prescribed:
ArraySetAsSeries (dataCandle, true); //change direction
bool series=ArrayIsSeries(dataCandle); //check again
Alert (series); //write the result on the screen.
But I still get "false" after that.
What's my problem?
Oh this programming. The further into the woods....
I first checked just through Alert what it was giving out. It turns out to be the opposite, i.e. the candle closest to the current candle has the maximum number.
Then I checked it via:
bool series=ArrayIsSeries(dataCandle);
Alert (series);
and the script shows "false".
By my logic, if false is on the wrong end, then true will be on the right end.
I prescribed:
ArraySetAsSeries (dataCandle, true); //change direction
bool series=ArrayIsSeries(dataCandle); //check again
Alert (series); //write the result on the screen.
But I still get "false" after that.
What's my problem?
The dataCandles is a structure. The array where we write the candles from the history - array[]. And we need to make it as a time series so that its indexing coincides with indexing of candlesticks on the chart. I.e. the zero cell of array[] will correspond to the closest candlesticks to the current date.
I.e. 1. copy candlesticks into array array[], 2. make it a time series, then read values from it into the structure.
You can do without array[] - just write data directly from the chart into the structure, but I suggested this for compatibility with Five - it allows to copy directly only in the indicator using high[i], low[i] and other data, but in the script or Expert Advisor, we have to first copy the necessary history interval into the array, which I did.