Automatic parameter optimization, inverse detection, and performance tracking
Every trading day after market close (6:30 PM ET), our GitHub Actions workflow triggers the learning engine. It:
algorithm_performance tableAPI endpoint: learning.php?action=analyze_and_adjust
For each algorithm, the learning engine tests every combination of these parameters:
Total: 6 TP × 5 SL × 6 Hold = 180 combinations per algorithm.
The exhaustive permutation_scan tests an even larger grid of 13 TP × 9 SL × 11 Hold = 1,287 combinations.
| Take Profit (TP) | % price increase from entry that triggers a sell. Higher = more room to run, but risk giving back gains. |
| Stop Loss (SL) | % price decrease from entry that triggers a sell. Tighter = less loss per trade, but more whipsaws. |
| Max Hold Days | Maximum trading days before forced exit at closing price. Prevents dead money sitting in stale positions. |
| Commission | Per-trade cost ($10 buy + $10 sell = $20 round trip). Questrade CDR stocks pay $0. |
| Slippage | 0.5% price impact assumed on entry and exit to model real-world fills. |
| PROFITABLE_PARAMS_EXIST | At least one parameter combination yields positive returns. Best params are stored. |
| IMPROVABLE_BUT_STILL_LOSING | Best combo is better than default, but still negative. May work as inverse/SHORT signal. |
| NO_PROFITABLE_PARAMS_FOUND | No parameter combination yielded profit. Strong candidate for inverse algorithm. |
Loading algorithm recommendations...
The learning engine detects algorithms whose picks consistently decline. Instead of discarding them, we invert the signal — when they say BUY, we SHORT. This turns a losing long strategy into a potentially winning short strategy.
The exhaustive scan tests a wider grid to find global optima:
999 = no limit (hold until other exit triggers)