Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 531
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
Compare the next bar, and if the sequence is broken, reset the flag and record how many were correct, and go on in the loop.
It is enough to find out that the bar is bullish and the next one is bearish, the next one, if it is the same as the previous one, you write down the value and reset the flag. And so on to the end.
But the first one may not be bullish.
but the first one might not be a bull, but there is no way.
Here's a variant, though not quite right, always counting from a bearish candle
Here's a variant, though not quite right, always counting from a bearish candle
Thank you. If you square this number and add one, the result is correct.
Is it checked if(i%2==0)?but the first one may not be a bull, no way.
Here's an example of finding the same candles and changing the direction of the chain:
Now where the chain continues, you can count the number of candles in the chain and save to a list, and where the chain changes to a new one, start a new count.
The number of candles in each chain can be stored in a sorted list. Then, by sorting the list, the maximum and minimum sequences can be found.
Thank you. If the number obtained is squared and one is added, the result is correct.
Is that what we're checking if(i%2==0)?If i is a multiple of two.
It is the remainder of i divided by 2
Here the size of local variables is too large (more than 512kb) during compilation.
Where to look and what to do? There is a string array CArrayString in the function, I suspect it may be an error.
I fill it using Add() method, then do Clear() and Shutdown() again. And then I fill it again with new data using Add() method. In this case, will the array be filled with zero items again?
We have to remove such members from the classes that already occupy memory at the compilation stage. This data will be allocated in the stack memory, which is always very small. The solution to this problem is to allocate memory for class members occupying a lot of memory dynamically.
For example, if there is a class member:
it should be replaced with:
We need to remove from the classes those members that already occupy memory at the compilation stage. This data will be placed in stack memory, which is always very small. The solution to this problem is to allocate memory for class members occupying a lot of memory dynamically.
For example, if there is a class member:
then it should be replaced with:
Thanks. Somehow I got rid of this problem by removing the class from the parameters in each function. In general, it was possible to initialise this object once for all methods.
I have another question about the CArray class, more specifically CArrayObj. Is there a Delete() method, but it doesn't move an element in the array? That is, I delete Delete(18), it removes an item at this position and later if I want to query the item by this index, I get an invalid pointer. Is there such a method that would delete and move elements so that in this case the 18th element would be the 19th one after deletion?
Thank you. Somehow I got rid of this problem by removing the class from the parameters in each of the functions. In general, it was possible to initialize this object once for all methods.
I have another question about the CArray class, more specifically CArrayObj. Is there a Delete() method, but it doesn't move an element in the array? That is, I delete Delete(18), it removes an item at this position and later if I want to query the item by this index, I get an invalid pointer. Is there such a method that would delete and move items so that the 18th item would be the 19th one after deletion?
I haven't worked with the standard library, but according to the help, the Delete() method should physically remove the element, changing the size of the array. Exception: if the memory management mechanism is disabled. By default, this mechanism is enabled. The FreeMode method is used to check the state of the memory management flag.
For my part, I would recommend using my own arrays in MQL (although in C++ I use vectors and lists) and memory management myself, because I do not see any particular convenience or advantage in the CArray class. I delete array items in my own arrays rather quickly using this method:
Its only disadvantage is that it does not keep the sequence of array items. That is, it can be applied to all arrays, except for ordered (sorted) ones.
Hello, could you please tell me where I can find a script that allows me to place pending buy and sell orders in MT4 at once for a certain number of pips from the current price, i.e. not to count manually and maybe not even to enter the order window? I do not want to go to the order window. Thank you.
PS: maybe i am asking something wrong, i have never used scripts before.
Please explain me the point -"Market orders cannot be closed if their StopLoss or TakeProfit values violate the FreezeLevel parameter."
Does this literally mean that a market order cannot be closed if its TakeProfit or StopLoss does not meet the FreezeLevel? I just don't quite understand how an open market order can have stops that violate the StopLevel or FreezeLevel rules? After all, if the wrong stops are set, the server will just give an error and no stops will be set.
Also please advise what else we need to know when closing a market order, when a broker uses FreezeLevel?