Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1266
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 don't remember, I have to check it, but I don't want to. Perhaps, in mql4 when trying to create an object with the name of an existing one, an error was returned, and in mql5 not an error, but modification of parameters if the coordinates are different.
As Artem said - check the existence of the object.
Yes, that's right.
suddenly (as usual) ObjectGetInteger(0,objectName,OBJPROP_TYPE) works faster.
ObjectFind is a synchronous command, i.e. it waits for a complete update(and availability) of the chart objects...The use is fraught with significant delays.
If you work with your own objects (ie, created in your own stock), then you should not use ObjectFind - you already know in which window object was created and that it most likely exists and it is the right type.
The worst that could happen is that the user deleted the object or changed the property.
Thank you. That's interesting.
Good day to you all.
Kovalev's book says that indexes of arrays can be set to integer values as constants,variables or expressions.
When I set the index in mql4 as a variable, the compiler gives me only one error
This is how I set the index
intW=1000;
double T_P[W]={0};
void OnTick()
{
code
}
Please tell me what I am doing wrong.
Thank you.
Good day to you all.
Kovalev's book says that indexes of arrays can be set to integer values as constants,variables or expressions.
When I set the index in mql4 as a variable, the compiler gives me only one error
This is how I set the index
intW=1000;
double T_P[W]={0};
void OnTick()
{
code
}
Please tell me what I am doing wrong.
Thank you.
The array index is not the size of the array.
Got it, thanks. Is there any way to set the size of the array using a variable?
Got it, thanks. Is there any way to set the size of the array using a variable?
Sets a new size in the first array dimension
intArrayResize(
void&array[],// array passed by the reference
intnew_size,// new array size
intreserve_size=0// reserve_size value (redundant)
)
Sets the new size in the first array dimension
intArrayResize(
void&array[],// array passed by reference
intnew_size,// new array size
intreserve_size=0// reserve_size value (redundant)
);
Thanks for the valuable information.
Hello! Please help me with a simple code.
I'm dealing with order opening/closing mechanisms at the moment and have run into a problem with closing open positions.
The code is simple. The idea of the algorithm is to draw the MA (moving average) with a period of 100 on the chart. If the previous candle [1] opened above the MA, and closed below the MA, then the next candle [0] opens a SELL orderto sell.
//(The conditions to buy are different, I will not describe them)
For closing of the order the following conditions - the current price has passed from the price of opening of the order the set value of points, for example 40.
Example: A lot is opened at Bid= 1.20045, it should close at Ask= 1.20005.
The code of opening and closing is packed into two corresponding functions - CheckForOpen() and CheckForClose() which in their turn are called with OnTick() function. In fact, the price can pass a certain value of points (go past the close level) but the order won't be closed.
I can't figure out what's wrong.
p/s/ Screenshots and code attached.
Hello! Please help me with a simple code.
I'm dealing with order opening/closing mechanisms at the moment and have faced the problem of closing open positions.
The code is simple. The idea of the algorithm is to draw the MA (moving average) with a period of 100 on the chart. If the previous candle [1] opened above the MA, and closed below the MA, then the next candle [0] opens a SELL orderto sell.
//(The conditions to buy are different, I will not describe them)
For closing of the order the following conditions - the current price has passed from the price of opening of the order the set value of points, for example 40.
Example: A lot is opened at Bid= 1.20045, it should close at Ask= 1.20005.
The code of opening and closing is packed into two corresponding functions - CheckForOpen() and CheckForClose() which in their turn are called with OnTick() function. In fact, the price can pass a certain value of points (go past the close level) but the order won't be closed.
I can't figure out what's wrong.
p/s/ Screenshots and code attached.
The CheckForOpen() should not be called directly in OnTick, but in a self-written OnBar (which should be called in OnTick) - at bar opening. But this is a trivial thing
, instead of Open[1], Close[1] (previous candle has broken through MA100) we should look at Open[1],Open[0] (previous candle opened from one side of MA, current one from the other side). Otherwise a shallow gap between candlesticks will be seen and the logic will be forgiven.
The SMA of the Median changes on the 0th bar, i.e. it is not constant. It cannot be compared to it. Correct the algorithm.
Sets the new size in the first array dimension
intArrayResize(
void&array[],// array passed by reference
intnew_size,// new array size
intreserve_size=0// reserve_size value (redundant)
);
Thanks again for your hint, but..... in Help it is written that this function applies only to dynamic arrays. And my code is NOT a dynamic array, but a usual one.
I will be very grateful if you tell me (or, better, show me) how to change the size of a regular array in the first dimension.
Thanks again for your help.