OPEN-SOURCE SCRIPT
BTC Momentum Trading - RSI Cross

For the third algorithm (the “trading” strategy), I built a momentum-based system using RSI crossovers on BTCUSD. This algorithm is different from my mean-reversion and trend-trading strategies because it reacts directly to short-term momentum shifts rather than trend direction or oversold conditions.
IF / THEN Logic Used (Momentum Trading)
Long Entry (Buy):
IF the RSI(14) crosses above 55,
THEN the algorithm enters a long position.
(This signals short-term upward momentum.)
Short Entry (Sell):
IF the RSI(14) crosses below 45,
THEN the algorithm enters a short position.
(This signals downside momentum.)
Long Exit:
IF I am in a long position AND RSI crosses below 50,
THEN exit the long position.
Short Exit:
IF I am in a short position AND RSI crosses above 50,
THEN exit the short position.
Purpose of the Strategy
This strategy demonstrates real-time trading behavior, where entries and exits are driven by momentum signals rather than mean reversion or trend structure. It is meant to show how an algo reacts quickly to shifts in strength/weakness in price movement.
Backtest Requirements
I ran the strategy on BTCUSD, 10-minute timeframe (Feb 16–23, 2026).
This produced:
Total trades: 1,284
Profitable trades: 27.92%
Profit factor: 0.886
Drawdown: 2.13%
The large number of trades provides a sufficient sample size for analysis, as required by the assignment.
IF / THEN Logic Used (Momentum Trading)
Long Entry (Buy):
IF the RSI(14) crosses above 55,
THEN the algorithm enters a long position.
(This signals short-term upward momentum.)
Short Entry (Sell):
IF the RSI(14) crosses below 45,
THEN the algorithm enters a short position.
(This signals downside momentum.)
Long Exit:
IF I am in a long position AND RSI crosses below 50,
THEN exit the long position.
Short Exit:
IF I am in a short position AND RSI crosses above 50,
THEN exit the short position.
Purpose of the Strategy
This strategy demonstrates real-time trading behavior, where entries and exits are driven by momentum signals rather than mean reversion or trend structure. It is meant to show how an algo reacts quickly to shifts in strength/weakness in price movement.
Backtest Requirements
I ran the strategy on BTCUSD, 10-minute timeframe (Feb 16–23, 2026).
This produced:
Total trades: 1,284
Profitable trades: 27.92%
Profit factor: 0.886
Drawdown: 2.13%
The large number of trades provides a sufficient sample size for analysis, as required by the assignment.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.