| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| IsNewBar code https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=4915 |
Page 1 of 1 |
| Author: | renexxxx [ Sun Sep 25, 2016 10:57 pm ] |
| Post subject: | IsNewBar code |
I here like to post a little class that I created for detecting whether a new bar has started on a given SYMBOL and TIMEFRAME. For those of you coders, who are only ever creating single-symbol, single-timeframe EAs, you don't need this as you can just use the good old: Code: Select all The attached CBar class is to be used if you (like myself) are running multi-symbol/multi-timeframe code. As you know ticks for different symbols are arriving at different times. So, it is possible that one symbol has started a new candle (bar) whilst the other is still on the old candle. Is this important? I don't know -- that depends on your code. The use of the CBar class is dead-simple: 1. Somewhere at the top of you file, you create a CBar object like so Code: Select all Code: Select all I am a big fan of building (and sharing) a set of re-usable software components. This makes the task of creating new EAs much easier and quicker. Hope this is useful for some of the coders. Edit: I have made a little change to CBar, to stop it from reporting a new bar when it is first loaded, whilst in the middle of a bar. It should now patiently wait for a real new bar. |
|
| Author: | oligodar [ Mon Sep 26, 2016 11:37 am ] |
| Post subject: | IsNewBar code |
Very useful. Thank you. |
|
| Author: | gprince66 [ Mon Sep 26, 2016 4:58 pm ] |
| Post subject: | IsNewBar code |
Many thanks renexxxx. I learn something new every time I read one of your posts or scan your code. Gary |
|
| Author: | heart1010 [ Tue Sep 27, 2016 7:19 am ] |
| Post subject: | IsNewBar code |
Thanks |
|
| Author: | Raj4x [ Tue Nov 29, 2016 8:16 pm ] |
| Post subject: | IsNewBar code |
Here's an alternative: Code: Select all |
|
| Author: | alecsa72 [ Wed Nov 30, 2016 1:27 pm ] |
| Post subject: | IsNewBar code |
@renexxxx If I use +15 instead of +1 in that code snippet - will that mean that I will detect the new bar exactly 15 seconds after the new bar actually started? PS: I actually do need such functionality |
|
| Author: | renexxxx [ Fri Dec 02, 2016 7:47 pm ] |
| Post subject: | IsNewBar code |
No, it doesn't. If you need this functionality, you will need to do something like this: Code: Select all |
|
| Author: | alecsa72 [ Fri Dec 02, 2016 9:41 pm ] |
| Post subject: | IsNewBar code |
Thanks! |
|
| All times are UTC | Page 1 of 1 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|