Sample Breakout cBot question
Sample Breakout cBot question
29 Apr 2015, 02:43
Hi all,
Having a question about some code present in Sample Breakout cBot.
In the below code we see the initialisation of bollingerBands in the OnStarrt(). In the OnBar() we request the top and bottom values of the BB.
My questions:
- why is this initialisation of bollingerBands done in the OnStart() and not in the OnBar()?
- is bollingerBands updated every tick even if it is defined in the OnStart()?
Thanks in advance.
protected override void OnStart() { bollingerBands = Indicators.BollingerBands(Source, Periods, Deviations, MAType); } protected override void OnBar() { var top = bollingerBands.Top.Last(1); var bottom = bollingerBands.Bottom.Last(1); if (top - bottom <= BandHeightPips * Symbol.PipSize) { consolidation = consolidation + 1; }
Replies
9718853
07 May 2015, 00:41
RE:
In OnStart() the indicator is defined...
In OnBar() the last result of the indicator is used to trigger an action...
If you wanted anything to happen on tick you would have to use OnTick()
.ics said:
Hi all,
Having a question about some code present in Sample Breakout cBot.
In the below code we see the initialisation of bollingerBands in the OnStarrt(). In the OnBar() we request the top and bottom values of the BB.
My questions:
- why is this initialisation of bollingerBands done in the OnStart() and not in the OnBar()?
- is bollingerBands updated every tick even if it is defined in the OnStart()?
Thanks in advance.
protected override void OnStart() { bollingerBands = Indicators.BollingerBands(Source, Periods, Deviations, MAType); } protected override void OnBar() { var top = bollingerBands.Top.Last(1); var bottom = bollingerBands.Bottom.Last(1); if (top - bottom <= BandHeightPips * Symbol.PipSize) { consolidation = consolidation + 1; }
@9718853
.ics
01 May 2015, 12:27
Anyone?
@.ics