Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 426
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
Good day, dear forum users.
Please help me with the following task:
I need to get the indicator data in mt4 using mql, e.g. MA5 with 1d timeframe, as of 14.30 of the day before yesterday.
i.e., if i ran the iMA script the day before yesterday at 14.30, no questions would arise, but how do i get it today.
at least tell me where to dig
It is very simple. You need to set 7 parameters to calculate the iMA. The first parameter, the name of the symbol, is obvious. As the second, time frame, set M1. The third parameter - the period - set as many times as you need, how many days is more than one minute. The fourth parameter - shift = 0. The next two parameters - the method of averaging and price type - you know. The last one is the bar number. Please calculate the bar number if you know the time you need. That's all! Double-check it by making calculations for M5 and M15 timeframes. Maybe even for M30.
It is very simple. In order to calculate the iMA, 7 parameters are required. The first parameter, the name of the symbol, is obvious. As the second parameter, timeframe, set M1. The third parameter - the period - set as many times as you need, how many days is more than one minute. The fourth parameter - shift = 0. The next two parameters - the method of averaging and price type - you know. The last one is the bar number. Please calculate the bar number if you know the time you need. That's all! Double-check it by making calculations for M5 and M15 timeframes. Maybe even for M30.
Unfortunately it is not easy. If we take the MA5, time frame 1440 (1 day), select bar number 2 (the day before yesterday), we will get the MA5 for the opening or closing of the last candle, but not the 14.30 moment. And that is what we need to specify. Once again. The technical indicators are calculated from several candlesticks, they open at 00.00 (if we're talking about a day), they close at 23.59, but the last candlestick (if it's 0 bar) is not closed, and we take the last price of the 0 bar for its calculation. If the MA is on the zero bar, this is easy, but if it is not zero bar but the middle of the previous day, what should we do? How can we calculate МА in the middle of the previous day in TF 1440?
Thank you very much! I'll get down to writing the code :) I'll let you know the results.
Unfortunately it is not easy. If we take the MA5, time frame 1440 (1 day), select bar number 2 (the day before yesterday), we will get the MA5 for the opening or closing of the last candle, but not the 14.30 moment. And that is what we need to specify. Once again. The technical indicators are calculated from several candlesticks, they open at 00.00 (if we're talking about a day), they close at 23.59, but the last candlestick (if it's 0 bar) is not closed, and we take the last price of the 0 bar for its calculation. If the MA is on the zero bar, this is easy, but if it is not zero bar but the middle of the previous day, what should we do? How can I calculate МА in the middle of the previous day with time frame 1440?
It is very simple
Like this
Any idea how to organise the sending of signals by script?
I need help from the knowledgeable
I have an EA source code, it compiled in 2014 and everything was fine.
I have decided to write a new account and compile the EA on it, but it does not want to compile
I got 23 errors like these ( } )
What should I do and what has changed since 2014 ?
Unfortunately it is not easy. If we take the MA5, time frame 1440 (1 day), select bar number 2 (the day before yesterday), we will get the MA5 for the opening or closing of the last candle, but not the 14.30 moment. And that is what we need to specify. Once again. The technical indicators are calculated from several candlesticks, they open at 00.00 (if we're talking about a day), they close at 23.59, but the last candlestick (if it's 0 bar) is not closed, and we take the last price of the 0 bar for its calculation. If the MA is on the zero bar, this is easy, but if it is not zero bar but the middle of the previous day, what should we do? How can I calculate МА in the middle of the previous day in TF 1440?
Hello. Thanks toSTARIJ andArtyom Trishkin for the last consultation. But since I am still a newbie, other questions arise. For example, the following. I use the following function to open only one position in one bar:
And a question immediately arises: Why do I need to send a static variable "to the beginning of time" each time I access the function? After all, it accepts zero value by itself at the first call, and then let it store the value of the previous zero bar till the next call, instead of being reset to zero. Perhaps this simple function could be simplified. However, I myself am afraid of screwing it up. And one more question about this function: may it not be the case that expressionNew_Time=Time[0]; does not catch the millisecond when a new bar opens? What will happen then? Thanks.
Hello. Thank youSTARIJ for the last consultation as well. But since I am still a newbie, other questions arise. For example, the following. I use the following function to open only one position in one bar:
And immediately a question arises: Why do I need to send a static variable "to the beginning of time" each time I access the function? After all, it accepts zero value by itself at the first call, and then let it store the value of the previous zero bar till the next call, instead of being reset to zero. Perhaps this simple function could be simplified. However, I myself am afraid of screwing it up. And one more question about this function: may it not be the case that expressionNew_Time=Time[0]; does not catch the millisecond when a new bar opens? What will happen then? Thanks.
Hello. Thanks toSTARIJ andArtyom Trishkin for the last consultation. But since I am still a newbie, other questions arise. For example, the following. I use the following function to open only one position in one bar:
And a question immediately arises: Why do I need to send a static variable "to the beginning of time" each time I access the function? After all, it accepts zero value by itself at the first call, and then let it store the value of the previous zero bar till the next call, instead of being reset to zero. Perhaps this simple function could be simplified. However, I myself am afraid of screwing it up. And I have one more question concerning this function: isn't it possible that the expressionNew_Time=Time[0]; will not catch the millisecond when a new bar opens? What will happen then? Thanks.
Regarding the second question,
if the first tick doesn't catch, the second one will.