I've tried to ask this question at "quantitive finance" but it seems this is better place because the question more about programing than trading
How do you declare Indicator
interface? What would be the correct way to model an "Indicator"?
I'm using c# and I want to declare Indicator
interface like this:
interface Indicator
{
double Value { get; }
event Action<Void> ValueUpdated;
}
or probably even like this:
interface Indicator
{
event Action<Double> ValueUpdated;
}
I consider "pure price" also as trivial indicator:
class PriceIndicator : Indicator {
PriceIndicator(string ticker) {
....
}
}
Example of MA:
class MovingAverage : Indicator {
private PriceIndicator price;
public MovingAverage(PriceIndicator price, int period) {
....
}
// when price.ValueUpdated event occurs need to recalculate MA and raise ValueUpdated event
}
What do you think? Any suggestions are welcome!