From 5100d2732b57e8f0ab3c6b61c2dd8274abbde53f Mon Sep 17 00:00:00 2001 From: Sirius Claw Date: Mon, 20 Apr 2026 04:39:49 +0000 Subject: [PATCH] feat: Add Sirius Mean Reversion Pine Script --- trading/pinescript/README.md | 20 ++++++++ trading/pinescript/SiriusMeanReversion.pine | 52 +++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 trading/pinescript/README.md create mode 100644 trading/pinescript/SiriusMeanReversion.pine diff --git a/trading/pinescript/README.md b/trading/pinescript/README.md new file mode 100644 index 0000000..3ae04db --- /dev/null +++ b/trading/pinescript/README.md @@ -0,0 +1,20 @@ +# Sirius Trading - Pine Scripts + +This directory contains custom algorithmic trading scripts designed for TradingView (Pine Script v5). + +## Scripts + +### 1. `SiriusAITrendMaster.pine` +A robust, trend-following strategy designed for crypto and equities. + +**Core Logic:** +- **Entry:** Uses a Fast/Slow EMA crossover. +- **Filter:** Validates momentum by requiring the price to be above/below the Volume Weighted Average Price (VWAP) before taking the cross. +- **Risk Management:** Implements an automated, dynamic ATR-based trailing stop-loss. + +### 2. `SiriusMeanReversion.pine` +A mean-reversion counter-trend strategy designed to catch over-extended moves in ranging markets. + +**Core Logic:** +- **Entry:** Buys when the price crosses below the lower Bollinger Band and RSI is oversold (< 30). Shorts when price crosses above the upper Bollinger Band and RSI is overbought (> 70). +- **Risk Management:** Uses strict percentage-based Take Profit and Stop Loss limits set via the script inputs. diff --git a/trading/pinescript/SiriusMeanReversion.pine b/trading/pinescript/SiriusMeanReversion.pine new file mode 100644 index 0000000..6f26350 --- /dev/null +++ b/trading/pinescript/SiriusMeanReversion.pine @@ -0,0 +1,52 @@ +// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ +// © Sirius Trading + +//@version=5 +strategy("Sirius Mean Reversion", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.05) + +// --- Inputs --- +lengthRSI = input.int(14, title="RSI Length", group="Oscillator") +overbought = input.float(70.0, title="Overbought Level", group="Oscillator") +oversold = input.float(30.0, title="Oversold Level", group="Oscillator") + +bbLength = input.int(20, title="Bollinger Band Length", group="Bands") +bbMult = input.float(2.0, title="Bollinger Band Multiplier", group="Bands") + +tpPercent = input.float(2.0, title="Take Profit (%)", step=0.1, group="Exit Strategy") +slPercent = input.float(1.0, title="Stop Loss (%)", step=0.1, group="Exit Strategy") + +// --- Calculations --- +rsiVal = ta.rsi(close, lengthRSI) +[basis, upper, lower] = ta.bb(close, bbLength, bbMult) + +// --- Plotting --- +plot(basis, "BB Basis", color=color.new(color.white, 50)) +plot(upper, "BB Upper", color=color.new(color.blue, 50)) +plot(lower, "BB Lower", color=color.new(color.blue, 50)) + +// --- Logic --- +longCond = ta.crossunder(close, lower) and rsiVal < oversold +shortCond = ta.crossover(close, upper) and rsiVal > overbought + +// --- Execution --- +var float longEntryPrice = na +var float shortEntryPrice = na + +if (longCond and strategy.position_size == 0) + strategy.entry("Long", strategy.long) + longEntryPrice := close + +if (shortCond and strategy.position_size == 0) + strategy.entry("Short", strategy.short) + shortEntryPrice := close + +// Fixed Percentage Exits +if (strategy.position_size > 0) + longTp = longEntryPrice * (1 + tpPercent / 100) + longSl = longEntryPrice * (1 - slPercent / 100) + strategy.exit("Exit Long", "Long", limit=longTp, stop=longSl) + +if (strategy.position_size < 0) + shortTp = shortEntryPrice * (1 - tpPercent / 100) + shortSl = shortEntryPrice * (1 + slPercent / 100) + strategy.exit("Exit Short", "Short", limit=shortTp, stop=shortSl)