#define HR0900 14400//All times were changed for the test to see which is the Reference.#define HR1500 10800#define HR1900 7200#define HR2300 3600externstring Heures="11:41;11:42;12:00;11:42;"; // Times for my test today...string HeureSH[];
datetime TC = TimeCurrent();
int times[]={HR1500, HR2300, HR0900, HR1900};
for(int k=0; k<ArraySize(HeureSH); k++)
{
datetime want= TC - times[k];
}
int iBar= iBarShift(Symbol(), PERIOD_H1, want);
double OpenPrice= iOpen(Symbol(), PERIOD_H1, iBar);
Onlyone of #define is considered. The Array HeureSH[] is correctly executed and if the time writed arrives, it's true, it's correct, this is only times[k] don't consider all the four #define.
Onlyone of #define is considered. The Array HeureSH[] is correctly executed and if the time writed arrives, it's true, it's correct, this is only times[k] don't consider all the four #define.
The problem is pretty obvious . . .
string HeureSH[];
so this array has a size of 0 as you have declared it that way . . . so this loop . . .
for(int k=0; k < ArraySize(HeureSH); k++)
starts at 0 and ends when k >= 0 ( 0 being the array size )
I think you need to do some string manipulation, you need to break your string into individual times, convert each of these to a datetime and store them in your HeureSH[] array . . . working with strings in this way can be a little tricky, not hard buy easy to screw up. Then your code might start to make a little sense . . .
By the way, these are the string functions you have to work with, study them carefully, enjoy.
The code you showed will result in what I have described, if you have more code that has an impact on the question you are asking then you need to show it . . . . or don't show it if you need no more help.
So for example, when it's 09:00, the iBar is the bar of yesterday 23:00, 10 hours less than TimeCurrent. When it's 15:00, the iBar is the bar of today 09:00, ....... What i want: If selected hour comes, have a reference bar which is before Now (TimeCurrent). My problem is the program only take the last item of "times[]" no others. I want if HeureSH[0], use times[0] and continu. What can i do?
You don't make it easy for anyone to help you, you post bits and pieces of your code here and there . . . I'm trying to understand your code, I can't run it to see what it does as I don't have the full code, you have a function the same name as your array, that is OK but it doesn't help readability.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Ok ok i give you that:
Onlyone of #define is considered. The Array HeureSH[] is correctly executed and if the time writed arrives, it's true, it's correct, this is only times[k] don't consider all the four #define.Ok ok i give you that:
Onlyone of #define is considered. The Array HeureSH[] is correctly executed and if the time writed arrives, it's true, it's correct, this is only times[k] don't consider all the four #define.The problem is pretty obvious . . .
string HeureSH[];so this array has a size of 0 as you have declared it that way . . . so this loop . . .
starts at 0 and ends when k >= 0 ( 0 being the array size )
Ok, i writed that cause i thought:
Ok, i writed that cause i thought:
By the way, these are the string functions you have to work with, study them carefully, enjoy.
Hi
i work about it but i don't understand this:
The problem is pretty obvious . . .
so this array has a size of 0 as you have declared it that way . . . so this loop . . .
starts at 0 and ends when k >= 0 ( 0 being the array size )
Can you try to tell me with more details?
For HeureSH[] i used lines to cut this in 4 strings parts to have 4 differents hours.
Edite again:
I writed ArraySize(HeureSH) in a print function and it give me: 4
2013.01.19 13:57:21 2012.11.19 19:00 Tester EURUSD,H1: Open:1.27701 ArraySise=4
i tested again and it select only the last of this:
So the last "14400". Why don't it select others in the same order of the Array "HeureSH[]" ?
Is there a problem with the cycle "For"?Hi
i work about it but i don't understand this:
Can you try to tell me with more details?
For HeureSH[] i used lines to cut this in 4 strings parts to have 4 differents hours.
Edite again:
I writed ArraySize(HeureSH) in a print function and it give me: 4
2013.01.19 13:57:21 2012.11.19 19:00 Tester EURUSD,H1: Open:1.27701 ArraySise=4
Ok ok sorry.
So for example, when it's 09:00, the iBar is the bar of yesterday 23:00, 10 hours less than TimeCurrent. When it's 15:00, the iBar is the bar of today 09:00, ....... What i want: If selected hour comes, have a reference bar which is before Now (TimeCurrent). My problem is the program only take the last item of "times[]" no others. I want if HeureSH[0], use times[0] and continu. What can i do?
PS: it's all i have and i need.
Hi,
oh can anyone help me?
Hi,
oh can anyone help me?
You don't make it easy for anyone to help you, you post bits and pieces of your code here and there . . . I'm trying to understand your code, I can't run it to see what it does as I don't have the full code, you have a function the same name as your array, that is OK but it doesn't help readability.
When is UpdateHSeSpeciales() called ?
Sorry really,
I have only that but it's true i forget "UpdateHSeSpeciales".
It's called in "init" when program begin.