Self-Learning Algorithms

Automatic parameter optimization, inverse detection, and performance tracking

For research and educational purposes only. Past performance does not guarantee future results.
Data types: Backtest Algorithm performance from historical simulations | Live Current parameter values & run status | Forward-Looking Recommended parameter changes
🧠 How Self-Learning Works

Daily Automated Optimization Pipeline

Every trading day after market close (6:30 PM ET), our GitHub Actions workflow triggers the learning engine. It:

  1. Fetches latest price data from Yahoo Finance
  2. Runs backtests for every algorithm across 180 parameter combinations
  3. Identifies the optimal TP/SL/Hold for each algorithm based on historical performance
  4. Detects algorithms that work better as inverse (SHORT) signals
  5. Stores recommendations in algorithm_performance table
  6. Caches horizon picks and consensus data for 6 hours

API endpoint: learning.php?action=analyze_and_adjust

Variables Being Tuned

Parameter Grid Search

For each algorithm, the learning engine tests every combination of these parameters:

Take Profit (TP %)
5, 10, 15, 20, 30, 50
Stop Loss (SL %)
3, 5, 8, 10, 15
Max Hold Days
1, 2, 5, 7, 14, 30
Initial Capital
$10,000
Commission / Trade
$10
Slippage
0.5%

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.

What Each Variable Controls

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 DaysMaximum trading days before forced exit at closing price. Prevents dead money sitting in stale positions.
CommissionPer-trade cost ($10 buy + $10 sell = $20 round trip). Questrade CDR stocks pay $0.
Slippage0.5% price impact assumed on entry and exit to model real-world fills.

Verdict System

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.
📊 Algorithm Performance & Recommendations
Loading data...

Loading algorithm recommendations...

🐻 Inverse Algorithm Detection (Bear Analysis)

When Long Picks Fail, Short Signals Emerge

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.

Loading bear analysis...
🔍 Exhaustive Permutation Scan

1,287 Parameter Combinations

The exhaustive scan tests a wider grid to find global optima:

Take Profit Grid
3, 5, 7, 10, 15, 20, 25, 30, 40, 50, 75, 100, 999
Stop Loss Grid
2, 3, 5, 7, 10, 15, 20, 30, 999
Max Hold Grid
1, 2, 3, 5, 7, 10, 14, 21, 30, 60, 90

999 = no limit (hold until other exit triggers)

Loading permutation data...