3) I don't see how the condition (Volume[0] == 1) would be of help.
Volume is the number of received ticks for the bar. So when Volume[0] == 1, you have only one tick value : the open one.
But the best way is something like this :
if(Time[0] > Last)
{
// you are at open, do what you want
Last = Time[0];
}
Hi Michel,
I should have read carefully ME's info about Volume, and your global/static Last variable is a good solution!
Thanks for your help
Michel:
Volume is the number of received ticks for the bar. So when Volume[0] == 1, you have only one tick value : the open one.
Volume is the number of received ticks for the bar. So when Volume[0] == 1, you have only one tick value : the open one.
But the best way is something like this :
if(Time[0] > Last)
{
// you are at open, do what you want
Last = Time[0];
}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
Hi everyone,
here's my question: is there a foolproof way to catch the Open of a bar (and only the Open of the bar)?
A few options that are not foolproof IMO:
1) if(Open[0] == Close[0] &&
Open[0] == High[0] &&
Open[0] == Low[0] )
{Action};
It is not foolproof because we can have a candle that is flat from beginning to end. So Action will not be executed only at the open of the candle.
2) if(CurTime() == Time[0])
{Action};
It is not foolproof because we have no guarantee that we will receive data at the beginning of a bar (for example because of a long execution of the previous start{} function, or because of thousands of possible IT problems).
3) I don't see how the condition (Volume[0] == 1) would be of help.
I must add something: I don't mind if I don't catch the Open "live", provided I can retrieve the data of the Open in a resonnable amount of time.
Let's take an extreme case as an example: the first data I receive for a bar is 10 seconds after the Open. I don't mind getting the Open data and taking {Action} on it, despite it will be after the Open happened.
Do you see a a solution?
How would you code it?
Thanks for your help!
pipeline