Level 41
So what exactly is your question? That's a clean design btw.
I'm building a trading algo and I'm currently working on the scanner bit. It checks $periods/$candles. Seems there are two approaches to dealing with indicators...
Indicator.Indicator in the Scanner and give the Indicator one period at a time (as I'm already dealing with each period) and let the Indicator manage its own data.The latter is what I'm beginning to implement. Am I missing something? Does this make sense?
protected $indicators = [
BullishEngulf::class,
BearishEngulf::class,
PriceClosedHigherForTwoDays::class,
PriceClosedLowerForTwoDays::class,
...
];
public function __construct()
{
$this->indicators = collect($this->indicators)
->transform( fn($indicator) => app($indicator));
}
public function check($period)
{
return $this->indicators
->map( fn ($indicator) => $indicator->check($period) )
->filter()
->toArray();
}
So if a particular Indicator needs two periods or three periods the Indicator can manage its own rolling two periods.
Edit: mainly I'm after the ease of management, and performance... naturally.
So what exactly is your question? That's a clean design btw.
Please or to participate in this conversation.