but on 2 different objects
- One works with the strategy
- Second works with the Indicator
For example, let's have a method that find the highest bar in the range.
Method, that works with indicator is
public int GetIndexOfTheHighestBar(Indicator indicator, int fromIndex, int toIndex) { ... }
Method that works with strategy is:
public int GetIndexOfTheHighestBar(Strategy strategy, int fromIndex, int toIndex) { ... }
The logic inside both is exactly the same, so ideally, we would not need to have 2 methods, just provide Bars instance, that will be processed inside the method.
Is it OK according to public API or should I use some another approach?
Finally, it could look like:
public int GetIndexOfTheHighestBar(Bars bar, int fromIndex, int toIndex) { ... }
I expect, this code can be called from Strategy and Indicator the same
Bars primaryBars = BarsArray[0] int index = GetIndexOfHighestBar(primaryBars, 0, 100); // returns index of highest bar within last 100 bars
Problem is, that I didn't find some good documentation about usage of the Bars class.
Help talks about 6 properties/methods that are not of my primary interest:
- BarsSinceSession
- GetBar
- GetDayBar
- FirstBarOfSession
- PercentComplete
- Session
- TickCount
On the other hand, I found there are present many other methods, that look very useful for accessing the dataseries:
- GetOpen(index),
- GetHigh(index),
- GetLow(index),
- GetClose(index)
- GetVolume(index)
These could be most useful for accessing the bars and their OHLC(V) values.
Then Bars object could be used for accessing the bars-data without locking to Strategy/Indicator instance.
Can these public methods of the Bars object be used freely, or is there any reason, they are not in documentation? I find them to be quite important to be mentioned in the docs, to see a big picture.
Comment