| Conditions | 8 | 
| Paths | 15 | 
| Total Lines | 30 | 
| Code Lines | 17 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 0 | 
| CRAP Score | 72 | 
| Changes | 0 | ||
| 1 | <?php  | 
            ||
| 22 | public function __invoke(Collection $ohlcv, int $timePeriod = 4): int  | 
            ||
| 23 |     { | 
            ||
| 24 |         $htl = trader_ht_trendline($ohlcv->get('close')); | 
            ||
| 25 | |||
| 26 | throw_unless($htl, NotEnoughDataException::class);  | 
            ||
| 27 | |||
| 28 |         $wma = trader_wma($ohlcv->get('close'), $timePeriod); | 
            ||
| 29 | |||
| 30 | throw_unless($htl, NotEnoughDataException::class);  | 
            ||
| 31 | |||
| 32 | $uptrend = $downtrend = $declared = 0;  | 
            ||
| 33 | |||
| 34 |         for ($i = 0; $i < 5; $i++) { | 
            ||
| 35 | $htlValue = array_pop($htl);  | 
            ||
| 36 | $wmaValue = array_pop($wma);  | 
            ||
| 37 | |||
| 38 | $uptrend += ($wmaValue > $htlValue ? 1 : 0);  | 
            ||
| 39 | $downtrend += ($wmaValue < $htlValue ? 1 : 0);  | 
            ||
| 40 | |||
| 41 | $declared = (($wmaValue - $htlValue) / $htlValue);  | 
            ||
| 42 | }  | 
            ||
| 43 | |||
| 44 |         if ($uptrend || $declared >= 0.15) { | 
            ||
| 45 | return static::BUY;  | 
            ||
| 46 |         } elseif ($downtrend || $declared <= 0.15) { | 
            ||
| 47 | return static::SELL;  | 
            ||
| 48 | }  | 
            ||
| 49 | |||
| 50 | return static::HOLD;  | 
            ||
| 51 | }  | 
            ||
| 52 | }  | 
            ||
| 53 |