0bps

Strategy vault / Other

SSL CHANNEL STOCH RSI

The default opening quantity is 20 coins Take profit and stop loss 10000%, i.e., no take profit or stop loss set

Author
luqi0212
Complexity
Intermediate · 121 lines
Parameters
32
Backtest bar
5m · intraday
Tested on
ETH/USDT · futures

The default opening quantity is 20 coins Take profit and stop loss 10000%, i.e., no take profit or stop loss set

Parameters

NameDefaultWhat it controls
v_input_1falseTake Wicks into Account ?
v_input_2trueHighlight State ?
v_input_int_53K
v_input_int_63D
v_input_int_714RSI Length
v_input_int_814Stochastic Length
v_input_17_close0RSI Source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4
v_input_1820Open position quantity
v_input_1910000take profit
v_input_2010000stop loss
v_input_3true(?Channel №1)MA High
v_input_string_10ma1_type: SMA | EMA | SMMA (RMA) | WMA | VWMA
v_input_4_high0ma1_source: high | close | low | open | hl2 | hlc3 | hlcc4 | ohlc4
v_input_int_1200ma1_length
v_input_5greenma1_color
v_input_6trueMA Low
v_input_string_20ma2_type: SMA | EMA | SMMA (RMA) | WMA | VWMA
v_input_7_low0ma2_source: low | high | close | open | hl2 | hlc3 | hlcc4 | ohlc4
v_input_int_2200ma2_length
v_input_8redma2_color
v_input_9trueShow Buy/Sell Labels ?
v_input_10false(?Channel №2)MA High
v_input_string_30ma3_type: SMA | EMA | SMMA (RMA) | WMA | VWMA
v_input_11_high0ma3_source: high | close | low | open | hl2 | hlc3 | hlcc4 | ohlc4
v_input_int_320ma3_length
v_input_12orangema3_color
v_input_13falseMA Low
v_input_string_40ma4_type: SMA | EMA | SMMA (RMA) | WMA | VWMA
v_input_14_low0ma4_source: low | high | close | open | hl2 | hlc3 | hlcc4 | ohlc4
v_input_int_420ma4_length
v_input_15bluema4_color
v_input_16trueShow Buy/Sell Labels ?

Source Pine Script

/*backtest
start: 2021-12-01 00:00:00
end: 2022-11-13 05:20:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
args: [["v_input_18",20]]
*/



//ssl channel
//@version=5
indicator("SSL Channel", shorttitle="SSL Channel", overlay=true, timeframe="", timeframe_gaps=false)

wicks = input(false, "Take Wicks into Account ?")
highlightState = input(true, "Highlight State ?")
ma(source, length, type) =>
    type == "SMA" ? ta.sma(source, length) :
     type == "EMA" ? ta.ema(source, length) :
     type == "SMMA (RMA)" ? ta.rma(source, length) :
     type == "WMA" ? ta.wma(source, length) :
     type == "VWMA" ? ta.vwma(source, length) :
     na

show_ma1   = input(true   , "MA High", inline="MA #1", group="Channel №1")
ma1_type   = input.string("SMA"  , ""     , inline="MA #1", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Channel №1")
ma1_source = input(high  , ""     , inline="MA #1", group="Channel №1")
ma1_length = input.int(200     , ""     , inline="MA #1", minval=1, group="Channel №1")
ma1_color  = input(color.green, ""     , inline="MA #1", group="Channel №1")
ma1 = ma(ma1_source, ma1_length, ma1_type)

show_ma2   = input(true   , "MA Low", inline="MA #2", group="Channel №1")
ma2_type   = input.string("SMA"  , ""     , inline="MA #2", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Channel №1")
ma2_source = input(low  , ""     , inline="MA #2", group="Channel №1")
ma2_length = input.int(200     , ""     , inline="MA #2", minval=1, group="Channel №1")
ma2_color  = input(color.red, ""     , inline="MA #2", group="Channel №1")
ma2 = ma(ma2_source, ma2_length, ma2_type)
showLabels1 = input(true, "Show Buy/Sell Labels ?", group="Channel №1")

show_ma3   = input(false   , "MA High", inline="MA #3", group="Channel №2")
ma3_type   = input.string("SMA"  , ""     , inline="MA #3", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Channel №2")
ma3_source = input(high  , ""     , inline="MA #3", group="Channel №2")
ma3_length = input.int(20    , ""     , inline="MA #3", minval=1, group="Channel №2")
ma3_color  = input(color.orange, ""     , inline="MA #3", group="Channel №2")
ma3 = ma(ma3_source, ma3_length, ma3_type)

show_ma4   = input(false   , "MA Low", inline="MA #4", group="Channel №2")
ma4_type   = input.string("SMA"  , ""     , inline="MA #4", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Channel №2")
ma4_source = input(low  , ""     , inline="MA #4", group="Channel №2")
ma4_length = input.int(20    , ""     , inline="MA #4", minval=1, group="Channel №2")
ma4_color  = input(color.blue, ""     , inline="MA #4", group="Channel №2")
ma4 = ma(ma4_source, ma4_length, ma4_type)
showLabels2 = input(true, "Show Buy/Sell Labels ?", group="Channel №2")

Hlv1 = float(na)
Hlv1 := (wicks ? high : close) > ma1 ? 1 : (wicks ? low : close) < ma2 ? -1 : Hlv1[1]
sslUp1   = Hlv1 < 0 ? ma2 : ma1
sslDown1 = Hlv1 < 0 ? ma1 : ma2

Color1 = Hlv1 == 1 ? ma1_color : ma2_color
fillColor1 = highlightState ? (color.new(Color1, 90)) : na

highLine1 = plot(show_ma1 ? sslUp1 : na, title="UP", linewidth=2, color = Color1)
lowLine1 = plot(show_ma2 ? sslDown1 : na, title="DOWN", linewidth=2, color = Color1)

plotshape(show_ma1 and showLabels1 and Hlv1 == 1 and Hlv1[1] == -1, title="Buy Label", text="Buy", location=location.belowbar, style=shape.labelup, size=size.tiny, color=Color1, textcolor=color.white)
plotshape(show_ma2 and showLabels1 and Hlv1 == -1 and Hlv1[1] == 1, title="Sell Label", text="Sell", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=Color1, textcolor=color.white)

fill(highLine1, lowLine1, color = fillColor1)

Hlv2 = float(na)
Hlv2 := (wicks ? high : close) > ma3 ? 1 : (wicks ? low : close) < ma4 ? -1 : Hlv2[1]
sslUp2   = Hlv2 < 0 ? ma4 : ma3
sslDown2 = Hlv2 < 0 ? ma3 : ma4

Color2 = Hlv2 == 1 ? ma3_color : ma4_color
fillColor2 = highlightState ? (color.new(Color2, 90)) : na

highLine2 = plot(show_ma3 ? sslUp2 : na, title="UP", linewidth=2, color = Color2)
lowLine2 = plot(show_ma4 ? sslDown2 : na, title="DOWN", linewidth=2, color = Color2)

plotshape(show_ma3 and showLabels2 and Hlv2 == 1 and Hlv2[1] == -1, title="Buy Label", text="Buy", location=location.belowbar, style=shape.labelup, size=size.tiny, color=Color2, textcolor=color.white)
plotshape(show_ma4 and showLabels2 and Hlv2 == -1 and Hlv2[1] == 1, title="Sell Label", text="Sell", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=Color2, textcolor=color.white)

fill(highLine2, lowLine2, color = fillColor2)

// Alerts
alertcondition(Hlv1 == 1 and Hlv1[1] == -1, title="SSL Channel (1) Buy Alert", message = "SSL Channel (1): BUY")
alertcondition(Hlv1 == -1 and Hlv1[1] == 1, title="SSL Channel (1) Sell Alert", message = "SSL Channel (1): SELL")
alertcondition(Hlv2 == 1 and Hlv2[1] == -1, title="SSL Channel (2) Buy Alert", message = "SSL Channel (2): BUY")
alertcondition(Hlv2 == -1 and Hlv2[1] == 1, title="SSL Channel (2) Sell Alert", message = "SSL Channel (2): SELL")

//stoch rsi
//@version=5
indicator(title="Stochastic RSI", shorttitle="Stoch RSI", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
smoothK = input.int(3, "K", minval=1)
smoothD = input.int(3, "D", minval=1)
lengthRSI = input.int(14, "RSI Length", minval=1)
lengthStoch = input.int(14, "Stochastic Length", minval=1)
src = input(close, title="RSI Source")
rsi1 = ta.rsi(src, lengthRSI)
k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = ta.sma(k, smoothD)
plot(k, "K", color=#2962FF)
plot(d, "D", color=#FF6D00)
h0 = hline(80, "Upper Band", color=#787B86)
hline(50, "Middle Band", color=color.new(#787B86, 50))
h1 = hline(20, "Lower Band", color=#787B86)
fill(h0, h1, color=color.rgb(33, 150, 243, 90), title="Background")

BASEMONEY = input(20, 'Open position quantity')
prof = input(10000, 'take profit')
los = input(10000,'stop loss')
if (Hlv1 == 1 and Hlv1[1] == -1) or (Hlv2 == 1 and Hlv2[1] == -1)  and k < 20 and d <20
    strategy.entry("Enter Long", strategy.long, BASEMONEY)
strategy.exit("exit",  profit = prof, loss = los )
if (Hlv1 == -1 and Hlv1[1] == 1) or (Hlv2 == -1 and Hlv2[1] == 1)  and k > 80 and d >80
    strategy.entry("Enter Short", strategy.short, BASEMONEY)
strategy.exit("exit",  profit = prof, loss = los)

Published by luqi0212 on the FMZ strategy square · last modified 2022-11-24. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/SSL-CHANNEL-STOCH-RSI.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open