Please find attached two indicators :
- ExampleIndicator, and
- HostIndicator.
The crux of ExampleIndicator is simple. It attempts to set the _lastCompleteBar based on the value of Calculation. This _lastCompleteBar would be used in indicator calculations but is outside of this question.
_lastCompleteBar = Calculate == Calculate.OnBarClose ? 0 : 1;
To illustrate:
- Add ExampleIndicator to chart (NinjaScript Output window prints as expected)
- In NinjaScript Editor, change the Calculation to OnPriceChange and compile
- Refresh the chart (NinjaScript Output window does NOT print as expected)
- Remove ExampleIndicator from chart
- Add ExampleIndicator to chart (NinjaScript Output window again prints as expected)
Please find a brief video showing above at http://screencast.com/t/t36pAQyU
The HostIndicator simply "hosts" ExampleIndicator with the potential to "host" other indicators. The purpose is to set and align Calculation of ExampleIndicator with the Calculation of other indicators.
While a long winded, is there a better approach to effect this functionality?
Both the hosting and aligning functionality, and negating the requirement to remove and re-add an indicator to have it correctly evaluate _lastCompletedBar.
Thanks
Shannon
Comment