Machine learning-based strategy that uses a TensorFlow neural network to predict next candle close prices.

The strategy trains a simple feed-forward neural network (8→6→4→1 architecture) on normalized candle data every 8 hours. It predicts where the next candle will close within its high-low range. When current price is below the predicted price, it opens a $100 position via Position.moonbag with 1% hard stop. Positions close automatically via trailing take profit when profit retraces by 1% from peak.
Strategy: oct_2021_strategy | Exchange: ccxt-exchange | Frame: oct_2021_frame
Link to the source code
npm start -- --backtest --symbol BTCUSDT ./content/oct_2021.strategy/oct_2021.strategy.ts
Input Layer: 8 neurons (8 normalized candles)
Hidden Layer 1: 6 neurons (ReLU activation, He Normal init)
Hidden Layer 2: 4 neurons (ReLU activation, He Normal init)
Output Layer: 1 neuron (Sigmoid activation, outputs [0,1])
Training Parameters:
Normalization: Each candle is normalized as (close - low) / (high - low), mapping the close position within the candle's range to [0, 1].
| Metric | Value |
|---|---|
| Frame start | Oct 1, 2021 |
| Frame end | Oct 14, 2021 |
| Period | 13 days |
| Timeframe | 8h candles |
| Signal check | Every 15 minutes |
| Metric | Value |
|---|---|
| Total trades | 28 |
| Win trades | 17 |
| Loss trades | 11 |
| Win rate | 60.71% |
| Total deployed capital | $2,800 |
| Net PNL ($) | +$18.26 |
| Net PNL (%) | +18.26% |
| ROI on capital | +0.65% |
| Avg PNL per trade | +$0.65 (+0.65%) |
| Best trade | +$5.37 (+5.37%) |
| Worst trade | −$1.40 (−1.40%) |
| Worst drawdown (%) | −1.40% |
| Worst drawdown ($) | −$1.40 |
| Max consecutive wins | 6 |
| Max consecutive losses | 4 |
| Metric | Value |
|---|---|
| Sharpe Ratio | 0.312 |
| Hard stop distance | 1% |
| Trailing take distance | 1% from peak |
| Max loss per position | $1 (1% of $100) |
| Avg trade duration | ~8-24 hours |
Training Phase (cached for 8h):
Prediction:
price = low + prediction * (high - low)Entry Signal:
if (currentPrice < prediction.price) {
Position.moonbag({
position: "long",
currentPrice,
percentStopLoss: 1.0, // 1% hard stop
})
}
Exit Logic (trailing take):
| Position Type | Count | Total PNL |
|---|---|---|
| LONG | 28 | +$18.26 |
| SHORT | 0 | $0.00 |
npm start -- --backtest --symbol BTCUSDT \
--strategy oct_2021_strategy \
--exchange ccxt-exchange \
--frame oct_2021_frame \
./content/oct_2021.strategy/oct_2021.strategy.ts
Add --ui to open the web dashboard at http://localhost:60050:
npm start -- --backtest --symbol BTCUSDT --ui \
./content/oct_2021.strategy/oct_2021.strategy.ts
Create a .env file in the project root (copy from .env.example):
# Telegram notifications (optional)
CC_TELEGRAM_TOKEN=your_bot_token_here
CC_TELEGRAM_CHANNEL=-100123456789
# Web UI server (optional, defaults shown)
CC_WWWROOT_HOST=0.0.0.0
CC_WWWROOT_PORT=60050