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 tested it on M1 & M5 and it was fine.
Only observation was that if you switch timeframes on the chart it can return true on the first tick - I had that issue too... small bug but easily fixed
The first IsNewBarOnTimeframes() I posted above does not have such issue. It can work even if you require that multiple timeframes be ended to trade, e.g. M1, M15 and H4 simultaneousely. Only issue might be "Requote error" due to time wasted.
The first IsNewBarOnTimeframes() I posted above does not have such issue. It can work even if you require that multiple timeframes be ended to trade, e.g. M1, M15 and H4 simultaneousely. Only issue might be "Requote error" due to time wasted.
I see - your's is quite elaborate.
My feeling was that it could be done with less code - this was my attempt.
Seems to work unless someone finds a bug...
Here is the test code:
I tested it on M1 & M5 and it was fine.
Only observation was that if you switch timeframes on the chart it can return true on the first tick - I had that issue too... small bug but easily fixed
I did not see such a problem when switching timeframes.
I wrote a test indicator using an array of objects. Only in the case of an array class instance via pointers, you must remember to delete these objects.
It is also necessary to remember that if you use other Symbols, then it is better to poll them in a timer, since you can skip the ticks of another symbol in OnCalculate.
And also you must make sure that this symbol is present in Market Watch.
I did not see such a problem when switching timeframes.
I wrote a test indicator using an array of objects. Only in the case of an array class instance via pointers, you must remember to delete these objects.
It is also necessary to remember that if you use other Symbols, then it is better to poll them in a timer, since you can skip the ticks of another symbol in OnCalculate.
ok - that's a lot more complicated. My test was simple, the same way I tested mine (see below).
If you leave it running and switch timeframes you get a true result even when the bar is not new.
It is a problem I faced in my code (shown above), so I had to put a check in there to prevent it
Every time I click a new timeframe it shows new bar detected:
ok - that's a lot more complicated. My test was simple, the same way I tested mine (see below).
If you leave it running and switch timeframes you get a true result even when the bar is not new.
It is a problem I faced in my code (shown above), so I had to put a check in there to prevent it
Every time I click a new timeframe it shows new bar detected:
The code that I have presented is no more complicated than yours, but more versatile, as it can be used in multi-symbol strategies. Your function cannot be used for different Symbols. Moreover, in the variant presented by me, the performance is higher, since there is no timeframe search.
If you love programming and want to further develop in this direction, but at the same time you are not friends with OOP, then you urgently need to make friends with OOP, because without OOP you will not be able to compete in the future.
Yes, really. The class as only one remembered time.
Every time I click a new timeframe it shows new bar detected:
This is because you are declaring an instance of the class, but you are initializing it:
should be like this:
or like this:
or like this:
CIsNewBar objDetector(PERIOD_M5);
The code that I have presented is no more complicated than yours, but more versatile, as it can be used in multi-symbol strategies. Your function cannot be used for different Symbols. Moreover, in the variant presented by me, the performance is higher, since there is no timeframe search.
If you love programming and want to further develop in this direction, but at the same time you are not friends with OOP, then you urgently need to make friends with OOP, because without OOP you will not be able to compete in the future.
My code was a quick example - I was thinking of how one could do this with a simple function and the least amount of code, but that does not mean I am not friends with OOP or that it cannot be expanded to handle multi symbol strategies.
If that is your inference because I observed a bug in your implementation, so be it - there are so many other aspects to master beyond OOP to stay competitive, but I guess you know that already...
Yes, really. The class as only one remembered time.
?
My code was a quick example - I was thinking of how one could do this with a simple function and the least amount of code, but that does not mean I am not friends with OOP or that it cannot be expanded to handle multi symbol strategies.
If that is your inference because I observed a bug in your implementation, so be it - there are so many other aspects to master beyond OOP to stay competitive, but I guess you know that already...
what bug ?
My inference was only based on what you said my code was a lot more complicated.
Especially since you haven't initialized the object. This clearly indicates that you are not friends with classes.