Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

SSL + Wave Trend Strategy

A Pine Script v5 strategy built on EMA (ap, 10), SMA (wt1, 4) and Crossover (wt1, wt2). It has 3 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 1 in cash and pays no commission. 52 settings; defaults include Candle Height Threshold 1.0, Stop Loss ATR Multiplier 1.7 and Risk : Reward 1 : 2.5.

Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.

Does SSL + Wave Trend Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 1 of 1 trades.
How did SSL + Wave Trend Strategy do on BTCUSDT 1D with default settings?
−1.01%
From 26 Jan 2024 to 21 Oct 2026, over 1 closed trade, against +102.5% for buy and hold. A backtest, not investment advice.
What alerts does SSL + Wave Trend Strategy have?
2
BUY Trade Entry Alert; SELL Trade Entry Alert.
Does SSL + Wave Trend Strategy run in Pine Script v6?
No
The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L347:C14: cannot use 'int' as a condition — Pine Script v6 does not cast 'int' or 'float' to 'bool' implicitly. Wrap it in bool(). The v6 version is shown for reference and is not offered as a download.
Does SSL + Wave Trend Strategy use a stop loss?
Yes
strategy.exit sets a stop on line 463.

BTCUSDT · 1D · default settings

  • SSL Channel Down
  • SSL Channel Up
  • MA Baseline
  • EMA Trend Line
  • Upper
  • Lower
  • Long SL
  • Short SL
  • Enter Short
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (52)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$990$2,025Equity from $1,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots. Lines, boxes and labels are the script's own drawings, the most recent ones its limits keep.
Net profit
−1.01%
−$10.11
Buy and hold
+102.5%
same period
Closed trades
1
0 won · 1 lost
Profitable
0.0%
of closed trades
Profit factor
0.00
gross profit ÷ gross loss
Max drawdown
1.01%
−$10.11

One run with the author's default settings, $1,000 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.

Review

What a careful reader of this script would point out, found by checking the source and the backtest.

  • Likely bug

    ta.sma(wt1, 4) ignores the settings line 157

    Line 157 hard-codes 4 where line 166 uses “Period ”. Changing those settings moves one band but not this one.

    ta.sma(wt1, 4)ta.sma(wt1, sslChLen)
  • Check

    5 settings do nothing

    “Over Bought Level 1 ”, “Over Bought Level 2 ”, “Over Sold Level 1 ”, “Over Sold Level 2 ”, “Period ” are declared but never read.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Note

    4 settings have no label

    In the settings dialog startMonth (line 83), startDate (line 84), endMonth (line 86), endDate (line 87) show an empty name. The labels on this page come from the variable names.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Strategy: Entry Conditions
Use SSL Hybrid ConditiontrueboolbullSslHybrid bearSslHybrid
Use Keltner Channel Condition trueboolinsideKeltnerCh
Keltner Channel Include WickstrueboolwithinCh
Target not touch EMA ConditiontrueboolbullTpValid bearTpValid
Use Candle Height ConditiontrueboolcandleHeightValid
Candle Height Threshold Percentage difference between high and low of a candle. Expressed as a decimal. Lowering this value will filter out trades on volatile candles.1.0float · min 0 · step 0.1candleHeightValid
Strategy: Exit Conditions
Stop Loss ATR Multiplier Size of StopLoss is determined by multiplication of ATR value. Take Profit is derived from this also by multiplying the StopLoss value by the Risk:Reward multiplier.1.7float · min 0 · step 0.1nnfxAtr
Strategy: Risk Management
Risk : Reward 1 :Used to determine Take Profit level. Take Profit will be Stop Loss multiplied by this value.2.5float · min 0 · step 0.1tpPercent
Portfolio Risk % Percentage of portfolio you lose if trade hits SL.\n\nYou then stand to gain\n Portfolio Risk % * Risk : Reward\nif trade hits TP.1float · min 0 · step 0.1riskAmt
Strategy: Date Range
Start Date 2022int · min 1900 · max 2100inDateRange
Start Month (no label in the script)1int · options [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]inDateRange
Start Date (no label in the script)1int · options [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]inDateRange
End Date 2100int · min 1900 · max 2100inDateRange
End Month (no label in the script)1int · options [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]inDateRange
End Date (no label in the script)1int · options [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]inDateRange
Strategy: Drawings
Show TP / SL BoxesShow or hide TP and SL position boxes.\n\nNote: TradingView limits the maximum number of boxes that can be displayed to 500 so they may not appear for all price data under test.trueboolline 369 line 377
Show Trade Exit LabelsUseful labels to identify Profit/Loss and cumulative portfolio capital after each trade closes.\n\nAlso note that TradingView limits the max number of 'boxes' that can be displayed on a chart (max 500). This means when you lookback far enough on the chart you will not see the TP/SL boxes. However you can check this option to identify where trades exited.falseboolline 385
Indicators: Drawings
Show SSL HybridtrueboolMA Baseline
Show SSL ChanneltrueboolSSL Channel Down SSL Channel Up
Show EMAtrueboolEMA Trend Line
Show Keltner ChanneltrueboolUpper Lower
Show Wave Trend Flip CandlestrueboolbarColour
Show ATR Stop Loss BandstrueboolLong SL Short SL
Indicators: Wave Trend
Channel Length 10intesa d
Average Length 21inttci
Over Bought Level 1 60intunused
Over Bought Level 2 53intunused
Over Sold Level 1 -60intunused
Over Sold Level 2 -53intunused
Indicators: SSL Channel
Period 10intsmaHigh smaLow
Indicators: SSL Hybrid
Show Color Barsfalseboolbarcolor
Baseline Type HMAstring · options ["SMA", "EMA", "DEMA", "TEMA", "LSMA", "WMA", "MF", "VAMA", "TMA", "HMA", "JMA", "Kijun v2", "EDSMA", "McGinley"]BBMC Keltma
Baseline Length 60intbeta result alpha e mid kijun conversionLine mg stdev BBMC Keltma rangema
Source closesourceresult a e mid dev e0 e1 mg zeros edsma Keltma ssf
Kijun MOD Divider 1int · max 4conversionLine
* Jurik (JMA) Only - Phase 3intphaseRatio
* Jurik (JMA) Only - Power 1intalpha
* Volatility Adjusted (VAMA) Only - Volatility lookback length10intvol_up vol_down
Modular Filter Only - Feedbackfalseboola
Modular Filter Only - Feedback Weighting 0.5float · min 0 · max 1 · step 0.1a
EDSMA - Super Smoother Filter Length 20int · min 1ssf
EDSMA - Super Smoother Filter Poles 2int · options [2, 3]ssf
Use True Range?trueboolrange_1
Base Channel Multiplier 0.2float · step 0.05upperk lowerk
Indicators: EMA
EMA Length 200int · min 1ema
Indicators: Keltner Channel
Length 20int · min 1kcMa
Multiplier 1.5floatKTop2 KBot2
Source closesourcekcMa
ATR Length 10int · min 1KTop2 KBot2
Indicators: Candle Height
Period 20intunused
Indicators: NNFX ATR (Stop Loss Settings)
Length 14int · min 1nnfxAtr longSlAtr shortSlAtr line 333 line 336 line 339 line 341
Smoothing RMAstring · options ["RMA", "SMA", "EMA", "WMA"]line 332 line 335 line 338

What it calculates

  • EMAap, Channel Length (10)esa · line 152
  • EMAmath.abs(ap - esa), Channel Length (10)d · line 153
  • EMAci, Average Length (21)tci · line 155
  • SMAwt1, 4wt2 · line 157
  • Crossoverwt1, wt2wtBreakUp · line 159
  • Crossunderwt1, wt2wtBreakDown · line 160
  • SMAhigh, Period (10)smaHigh · line 166
  • SMAlow, Period (10)smaLow · line 167
  • SMA / Linreg / EMA / WMAta.sma(src, math.ceil(len / 2)), math.floor(len / 2) + 1result · line 205
  • EMASource (close), Baseline Length (60)e · line 239
  • EMASource (close), Baseline Length (60)mid · line 247
  • Highestdev, * Volatility Adjusted (VAMA) Only - Volatility lookback length (10)vol_up · line 249
  • Lowestdev, * Volatility Adjusted (VAMA) Only - Volatility lookback length (10)vol_down · line 250
  • Lowest / HighestBaseline Length (60)kijun · line 273
  • Lowest / Highestlen / kidivconversionLine · line 274
  • EMASource (close), Baseline Length (60)mg · line 280
  • Stdevssf, Baseline Length (60)stdev · line 289
  • TRrange_1 · line 300
  • EMArange_1, Baseline Length (60)rangema · line 301
  • EMAclose, EMA Length (200)ema · line 312
  • EMASource (close), Length (20)kcMa · line 317
  • ATRATR Length (10)KTop2 · line 318
  • ATRATR Length (10)KBot2 · line 319
  • TRtruennfxAtr · line 345
  • CrossoversslChUp, sslChDownbullSslChannel · line 414
  • CrossoversslChDown, sslChUpbearSslChannel · line 415

Signal flow

How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.

The script has 146 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Open Long longopenLongOn443
Open Short shortopenShortOn452
Exit TP/SL stop and limitevery barOn463

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Alerts

AlertCallMessageLine
(no title)alertBUY Trade Entry Alert447
(no title)alertSELL Trade Entry Alert456

Does it repaint?

No

No repainting patterns in the source, and the live replay matched history.

1/1trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
  • ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D−1.0%+102.5%10%0.001.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−5.0%+5.5%50%0.005.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.8%+8.4%633%1.204.6%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+2.6%+21.5%540%2.102.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−2.8%+17.1%425%0.072.8%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market0—$0.00
Sideways market0—$0.00
Falling market10%−$10.11

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

1.0%

The 95th percentile of the worst drawdown when the same 1 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 1.0% to 1.0%; the tick is what actually happened, 1.0%. Order luck alone moves it this much.

0%1%
All 1 trades
SideEntryExitBarsP&L
short12 Aug 2026 63,600.0019 Aug 2026 65,967.207−$10.11

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
SSL + Wave Trend Strategy this page—v5 strategy−1.0%11.0%
[fpemehd] SSL Baseline Strategy by DuDu95ema sma highest lowest stdev tr atrv5 strategy+2.3%713.7%
BTC 15 min by RafaelZionisma ema wma linreg stdev highest lowestv4 strategy−25.7%11938.9%
Athena Momentum Squeeze - Short, Lean, and Mean by jrandolph1046ema sma stdev tr linreg atrv5 strategy+3.7%100.6%
Multi MA Trend Following Strategy Template by TradeAutomationema linreg sma wma stdev atr highest lowestv5 strategy+12.3%326.9%
CHOP Zone Entry Strategy + DMI-PSAR Exit by IronCasperatr highest lowest sma linreg emav4 strategy+17.1%820.0%

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • No v6-only features. v6 is not needed to run this script.

Clean v5

Verified

Nothing to change.

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L347:C14: cannot use 'int' as a condition — Pine Script v6 does not cast 'int' or 'float' to 'bool' implicitly. Wrap it in bool(). The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯//                          Take Profit: Calculated from Stop Loss using R:R ratio-//@version=5+//@version=6INITIAL_CAPITAL = 1000⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 131 msYes 1,000 bars in 198 msNot measured
PineTSNot testedNot testedNot measured

The engine and this page's reading of the source count a different number of settings, so one of them has missed one.

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © kevinmck100// @credits//      - Wave Trend:               Indicator: WaveTrend Oscillator [WT] by @LazyBear//      - SSL Channel:              SSL channel by @ErwinBeckers//      - SSL Hybrid:               SSL Hybrid by @Mihkel00//      - Keltner Channels:         Keltner Channels Bands by @ceyhun//      - Candle Height:            Candle Height in Percentage - Columns by @FreeReveller//      - NNFX ATR:                 NNFX ATR by @sueun123// // Strategy: Based on the YouTube video "This Unique Strategy Made 47% Profit in 2.5 Months [SSL + Wave Trend Strategy Tested 100 Times]" by TradeSmart.// @description//// Strategy incorporates the following features:////      - Risk management:  Configurable X% loss per stop loss//                          Configurable R:R ratio////      - Trade entry:      Based on strategy conditions below////      - Trade exit:       Based on strategy conditions below////      - Backtesting:      Configurable backtesting range by date////      - Chart drawings:   Each entry condition indicator can be turned on and off//                          TP/SL boxes drawn for all trades. Can be turned on and off//                          Trade exit information labels. Can be turned on and off//                          NOTE: Trade drawings will only be applicable when using overlay strategies////      - Alerting:         Alerts on LONG and SHORT trade entries////      - Debugging:        Includes section with useful debugging techniques//// Strategy conditions:////      - Trade entry:      LONG:   C1: SSL Hybrid baseline is BLUE//                                  C2: SSL Channel crosses up (green on top)//                                  C3: Wave Trend crosses up (represented by pink candle body)//                                  C4: Entry candle height is not greater than configured threshold//                                  C5: Entry candle is inside Keltner Channel (wicks or body depending on configuration)//                                  C6: Take Profit target does not touch EMA (represents resistance)////                          SHORT:  C1: SSL Hybrid baseline is RED//                                  C2: SSL Channel crosses down (red on top)//                                  C3: Wave Trend crosses down (represented by orange candle body)//                                  C4: Entry candle height is not greater than configured threshold//                                  C5: Entry candle is inside Keltner Channel (wicks or body depending on configuration)//                                  C6: Take Profit target does not touch EMA (represents support)////      - Trade exit:       Stop Loss: Size configurable with NNFX ATR multiplier//                          Take Profit: Calculated from Stop Loss using R:R ratio//@version=5INITIAL_CAPITAL = 1000DEFAULT_COMMISSION = 0.02MAX_DRAWINGS = 500IS_OVERLAY = truestrategy("SSL + Wave Trend Strategy", overlay = IS_OVERLAY, initial_capital = INITIAL_CAPITAL, currency = currency.NONE, max_labels_count = MAX_DRAWINGS, max_boxes_count = MAX_DRAWINGS, max_lines_count = MAX_DRAWINGS, default_qty_type = strategy.cash, commission_type = strategy.commission.percent, commission_value = DEFAULT_COMMISSION)// =============================================================================// INPUTS// =============================================================================// ----------------------// Trade Entry Conditions// ----------------------useSslHybrid        = input.bool    (true,  "Use SSL Hybrid Condition",                     group = "Strategy: Entry Conditions",   inline = "SC1")useKeltnerCh        = input.bool    (true,  "Use Keltner Channel Condition   ",             group = "Strategy: Entry Conditions",   inline = "SC2")keltnerChWicks      = input.bool    (true,  "Keltner Channel Include Wicks",                group = "Strategy: Entry Conditions",   inline = "SC2")useEma              = input.bool    (true,  "Target not touch EMA Condition",               group = "Strategy: Entry Conditions",   inline = "SC3")useCandleHeight     = input.bool    (true,  "Use Candle Height Condition",                  group = "Strategy: Entry Conditions",   inline = "SC4")candleHeight        = input.float   (1.0,   "Candle Height Threshold     ",                 group = "Strategy: Entry Conditions",   inline = "SC5", minval = 0, step = 0.1, tooltip = "Percentage difference between high and low of a candle. Expressed as a decimal. Lowering this value will filter out trades on volatile candles.")// ---------------------// Trade Exit Conditions// ---------------------slAtrMultiplier     = input.float   (1.7,   "Stop Loss ATR Multiplier     ",                group = "Strategy: Exit Conditions",    inline = "EC1", minval = 0, step = 0.1,     tooltip = "Size of StopLoss is determined by multiplication of ATR value. Take Profit is derived from this also by multiplying the StopLoss value by the Risk:Reward multiplier.")// ---------------// Risk Management// ---------------riskReward          = input.float   (2.5,  "Risk : Reward        1 :",                      group = "Strategy: Risk Management",    inline = "RM1", minval = 0, step = 0.1,     tooltip = "Used to determine Take Profit level. Take Profit will be Stop Loss multiplied by this value.")accountRiskPercent  = input.float   (1,    "Portfolio Risk %         ",                     group = "Strategy: Risk Management",    inline = "RM2", minval = 0, step = 0.1,     tooltip = "Percentage of portfolio you lose if trade hits SL.\n\nYou then stand to gain\n  Portfolio Risk % * Risk : Reward\nif trade hits TP.")// ----------// Date Range// ----------startYear           = input.int     (2022,  "Start Date       ",                            group = "Strategy: Date Range",     inline = "DR1", minval    = 1900, maxval = 2100)startMonth          = input.int     (1,     "",                                             group = "Strategy: Date Range",     inline = "DR1", options   = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])startDate           = input.int     (1,     "",                                             group = "Strategy: Date Range",     inline = "DR1", options   = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])endYear             = input.int     (2100,  "End Date      ",                               group = "Strategy: Date Range",     inline = "DR2", minval    = 1900, maxval = 2100)endMonth            = input.int     (1,     "",                                             group = "Strategy: Date Range",     inline = "DR2", options   = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])endDate             = input.int     (1,     "",                                             group = "Strategy: Date Range",     inline = "DR2", options   = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])// ----------------// Display Settings// ----------------showTpSlBoxes       = input.bool    (true,  "Show TP / SL Boxes",                           group = "Strategy: Drawings",       inline = "D1",  tooltip = "Show or hide TP and SL position boxes.\n\nNote: TradingView limits the maximum number of boxes that can be displayed to 500 so they may not appear for all price data under test.")showLabels          = input.bool    (false, "Show Trade Exit Labels",                       group = "Strategy: Drawings",       inline = "D2",  tooltip = "Useful labels to identify Profit/Loss and cumulative portfolio capital after each trade closes.\n\nAlso note that TradingView limits the max number of 'boxes' that can be displayed on a chart (max 500). This means when you lookback far enough on the chart you will not see the TP/SL boxes. However you can check this option to identify where trades exited.")// ------------------// Indicator Settings// ------------------// Indicator display optionsshowSslHybrid       = input.bool    (true,  "Show SSL Hybrid",                              group = "Indicators: Drawings",     inline = "ID1")showSslChannel      = input.bool    (true,  "Show SSL Channel",                             group = "Indicators: Drawings",     inline = "ID2")showEma             = input.bool    (true,  "Show EMA",                                     group = "Indicators: Drawings",     inline = "ID3")showKeltner         = input.bool    (true,  "Show Keltner Channel",                         group = "Indicators: Drawings",     inline = "ID4")showWaveTrend       = input.bool    (true,  "Show Wave Trend Flip Candles",                 group = "Indicators: Drawings",     inline = "ID5")showAtrSl           = input.bool    (true,  "Show ATR Stop Loss Bands",                     group = "Indicators: Drawings",     inline = "ID6")// Wave Trend Settingsn1                  = input.int     (10,     "Channel Length         ",                     group = "Indicators: Wave Trend",   inline = "WT1")n2                  = input.int     (21,     "Average Length         ",                     group = "Indicators: Wave Trend",   inline = "WT2")obLevel1            = input.int     (60,     "Over Bought Level 1       ",                  group = "Indicators: Wave Trend",   inline = "WT3")obLevel2            = input.int     (53,     "Over Bought Level 2       ",                  group = "Indicators: Wave Trend",   inline = "WT4")osLevel1            = input.int     (-60,    "Over Sold Level 1         ",                  group = "Indicators: Wave Trend",   inline = "WT5")osLevel2            = input.int     (-53,    "Over Sold Level 2         ",                  group = "Indicators: Wave Trend",   inline = "WT6")// SSL Channel SettingssslChLen            = input.int     (10,     "Period             ",                         group = "Indicators: SSL Channel",  inline = "SC1")// SSL Hybrid Settings// Show/hide Inputsshow_color_bar      = input.bool    (false, "Show Color Bars",                              group = "Indicators: SSL Hybrid",   inline = "SH2")// Baseline InputsmaType              = input.string  ("HMA", "Baseline Type                       ",         group = "Indicators: SSL Hybrid",   inline = "SH3", options=["SMA", "EMA", "DEMA", "TEMA", "LSMA", "WMA", "MF", "VAMA", "TMA", "HMA", "JMA", "Kijun v2", "EDSMA", "McGinley"])len                 = input.int     (60,    "Baseline Length                      ",        group = "Indicators: SSL Hybrid",   inline = "SH4")src                 = input.source  (close, "Source                          ",             group = "Indicators: SSL Hybrid",   inline = "SH5")kidiv               = input.int     (1,     "Kijun MOD Divider                     ",       group = "Indicators: SSL Hybrid",   inline = "SH6", maxval=4)jurik_phase         = input.int     (3,     "* Jurik (JMA) Only - Phase                 ",  group = "Indicators: SSL Hybrid",   inline = "SH7")jurik_power         = input.int     (1,     "* Jurik (JMA) Only - Power                 ",  group = "Indicators: SSL Hybrid",   inline = "SH8")volatility_lookback = input.int     (10,    "* Volatility Adjusted (VAMA) Only - Volatility lookback length", group = "Indicators: SSL Hybrid",   inline = "SH9")//Modular Filter Inputsbeta                = input.float   (0.8,   "Modular Filter, General Filter Only - Beta               ",   group = "Indicators: SSL Hybrid",   inline = "SH10", minval=0, maxval=1, step=0.1)feedback            = input.bool    (false, "Modular Filter Only - Feedback",               group = "Indicators: SSL Hybrid",   inline = "SH11")z                   = input.float   (0.5,   "Modular Filter Only - Feedback Weighting               ",     group = "Indicators: SSL Hybrid",   inline = "SH12", step=0.1, minval=0, maxval=1)//EDSMA InputsssfLength           = input.int     (20,    "EDSMA - Super Smoother Filter Length               ",         group = "Indicators: SSL Hybrid",   inline = "SH13", minval=1)ssfPoles            = input.int     (2,     "EDSMA - Super Smoother Filter Poles               ",          group = "Indicators: SSL Hybrid",   inline = "SH14", options=[2, 3])///Keltner Baseline Channel InputsuseTrueRange        = input.bool    (true,  "Use True Range?",                              group = "Indicators: SSL Hybrid",   inline = "SH15")multy               = input.float   (0.2,   "Base Channel Multiplier                   ",   group = "Indicators: SSL Hybrid",   inline = "SH16",    step=0.05)// EMA SettingsemaLength           = input.int     (200,   "EMA Length          ",                         group = "Indicators: EMA",          inline = "E1",      minval = 1)// Keltner Channel SettingskcLength            = input.int     (20,    "Length              ",                         group = "Indicators: Keltner Channel",  inline = "KC1", minval=1)kcMult              = input.float   (1.5,   "Multiplier             ",                      group = "Indicators: Keltner Channel",  inline = "KC2")kcSrc               = input.source  (close, "Source              ",                         group = "Indicators: Keltner Channel",  inline = "KC3")alen                = input.int     (10,    "ATR Length            ",                       group = "Indicators: Keltner Channel",  inline = "KC4", minval=1)// Candle Height in Percentage SettingschPeriod            = input.int     (20,    "Period             ",                          group = "Indicators: Candle Height",    inline = "CH1")// NNFX ATR SettingsnnfxAtrLength       = input.int     (14,    "Length              ",                         group = "Indicators: NNFX ATR (Stop Loss Settings)",    inline = "ATR1", minval = 1)nnfxSmoothing       = input.string  ("RMA", "Smoothing            ",                        group = "Indicators: NNFX ATR (Stop Loss Settings)",    inline = "ATR3", options = ["RMA", "SMA", "EMA", "WMA"])// =============================================================================// INDICATORS// =============================================================================// ----------// Wave Trend// ----------ap          = hlc3esa         = ta.ema(ap, n1)d           = ta.ema(math.abs(ap - esa), n1)ci          = (ap - esa) / (0.015 * d)tci         = ta.ema(ci, n2)wt1         = tciwt2         = ta.sma(wt1, 4)// Show Wave Trend crosses on chart as colour changes (pink bullish, orange bearish)wtBreakUp   = ta.crossover  (wt1, wt2)wtBreakDown = ta.crossunder (wt1, wt2)barColour   = showWaveTrend ? wtBreakUp ? color.fuchsia : wtBreakDown ? color.orange : na : nabarcolor(color = barColour)// -----------// SSL Channel// -----------smaHigh             = ta.sma(high, sslChLen)smaLow              = ta.sma(low, sslChLen)var int sslChHlv    = nasslChHlv           := close > smaHigh ? 1 : close < smaLow ? -1 : sslChHlv[1]sslChDown           = sslChHlv < 0 ? smaHigh : smaLowsslChUp             = sslChHlv < 0 ? smaLow : smaHighplot(showSslChannel ? sslChDown : na, "SSL Channel Down", linewidth=1, color=color.new(color.red, 30))plot(showSslChannel ? sslChUp   : na, "SSL Channel Up",   linewidth=1, color=color.new(color.lime, 30))// ----------// SSL Hybrid// ----------//EDSMAget2PoleSSF(src, length) =>    PI  = 2 * math.asin(1)    arg = math.sqrt(2) * PI / length    a1  = math.exp(-arg)    b1  = 2 * a1 * math.cos(arg)    c2  = b1    c3  = -math.pow(a1, 2)    c1  = 1 - c2 - c3    ssf = 0.0    ssf:= c1 * src + c2 * nz(ssf[1]) + c3 * nz(ssf[2])    ssfget3PoleSSF(src, length) =>    PI      = 2 * math.asin(1)    arg     = PI / length    a1      = math.exp(-arg)    b1      = 2 * a1 * math.cos(1.738 * arg)    c1      = math.pow(a1, 2)    coef2   = b1 + c1    coef3   = -(c1 + b1 * c1)    coef4   = math.pow(c1, 2)    coef1   = 1 - coef2 - coef3 - coef4    ssf     = 0.0    ssf    := coef1 * src + coef2 * nz(ssf[1]) + coef3 * nz(ssf[2]) + coef4 * nz(ssf[3])    ssfma(type, src, len) =>    float result = 0    if type == "TMA"        result := ta.sma(ta.sma(src, math.ceil(len / 2)), math.floor(len / 2) + 1)        result    if type == "MF"        ts      = 0.        b       = 0.        c       = 0.        os      = 0.        //----        alpha   = 2 / (len + 1)        a       = feedback ? z * src + (1 - z) * nz(ts[1], src) : src        //----        b      := a > alpha * a + (1 - alpha) * nz(b[1], a) ? a : alpha * a + (1 - alpha) * nz(b[1], a)        c      := a < alpha * a + (1 - alpha) * nz(c[1], a) ? a : alpha * a + (1 - alpha) * nz(c[1], a)        os     := a == b ? 1 : a == c ? 0 : os[1]        //----        upper   = beta * b + (1 - beta) * c        lower   = beta * c + (1 - beta) * b        ts     := os * upper + (1 - os) * lower        result := ts        result    if type == "LSMA"        result := ta.linreg(src, len, 0)        result    if type == "SMA"  // Simple        result := ta.sma(src, len)        result    if type == "EMA"  // Exponential        result := ta.ema(src, len)        result    if type == "DEMA"  // Double Exponential        e = ta.ema(src, len)        result := 2 * e - ta.ema(e, len)        result    if type == "TEMA"  // Triple Exponential        e = ta.ema(src, len)        result := 3 * (e - ta.ema(e, len)) + ta.ema(ta.ema(e, len), len)        result    if type == "WMA"  // Weighted        result := ta.wma(src, len)        result    if type == "VAMA"  // Volatility Adjusted        /// Copyright © 2019 to present, Joris Duyck (JD)        mid     = ta.ema(src, len)        dev     = src - mid        vol_up  = ta.highest(dev, volatility_lookback)        vol_down= ta.lowest(dev, volatility_lookback)        result := mid + math.avg(vol_up, vol_down)        result    if type == "HMA"  // Hull        result := ta.wma(2 * ta.wma(src, len / 2) - ta.wma(src, len), math.round(math.sqrt(len)))        result    if type == "JMA"  // Jurik        /// Copyright © 2018 Alex Orekhov (everget)        /// Copyright © 2017 Jurik Research and Consulting.        phaseRatio  = jurik_phase < -100 ? 0.5 : jurik_phase > 100 ? 2.5 : jurik_phase / 100 + 1.5        beta        = 0.45 * (len - 1) / (0.45 * (len - 1) + 2)        alpha       = math.pow(beta, jurik_power)        jma         = 0.0        e0          = 0.0        e0         := (1 - alpha) * src + alpha * nz(e0[1])        e1          = 0.0        e1         := (src - e0) * (1 - beta) + beta * nz(e1[1])        e2          = 0.0        e2         := (e0 + phaseRatio * e1 - nz(jma[1])) * math.pow(1 - alpha, 2) + math.pow(alpha, 2) * nz(e2[1])        jma        := e2 + nz(jma[1])        result     := jma        result    if type == "Kijun v2"        kijun           = math.avg(ta.lowest(len), ta.highest(len))  //, (open + close)/2)        conversionLine  = math.avg(ta.lowest(len / kidiv), ta.highest(len / kidiv))        delta           = (kijun + conversionLine) / 2        result         := delta        result    if type == "McGinley"        mg              = 0.0        mg             := na(mg[1]) ? ta.ema(src, len) : mg[1] + (src - mg[1]) / (len * math.pow(src / mg[1], 4))        result         := mg        result    if type == "EDSMA"        zeros       = src - nz(src[2])        avgZeros    = (zeros + zeros[1]) / 2        // Ehlers Super Smoother Filter         ssf         = ssfPoles == 2 ? get2PoleSSF(avgZeros, ssfLength) : get3PoleSSF(avgZeros, ssfLength)        // Rescale filter in terms of Standard Deviations        stdev       = ta.stdev(ssf, len)        scaledFilter= stdev != 0 ? ssf / stdev : 0        alpha       = 5 * math.abs(scaledFilter) / len        edsma       = 0.0        edsma      := alpha * src + (1 - alpha) * nz(edsma[1])        result     := edsma        result    result///Keltner Baseline ChannelBBMC        = ma(maType, close, len)Keltma      = ma(maType, src, len)range_1     = useTrueRange ? ta.tr : high - lowrangema     = ta.ema(range_1, len)upperk      = Keltma + rangema * multylowerk      = Keltma - rangema * multy//COLORScolor_bar   = close > upperk ? #00c3ff : close < lowerk ? #ff0062 : color.gray//PLOTSp1          = plot(showSslHybrid ? BBMC : na, color=color.new(color_bar, 0), linewidth=4, title="MA Baseline")barcolor(show_color_bar ? color_bar : na)// ---// EMA// ---ema         = ta.ema(close, emaLength)plot(showEma ? ema : na, "EMA Trend Line", color.white)// ----------------// Keltner Channels// ----------------kcMa        = ta.ema(kcSrc, kcLength)KTop2       = kcMa + kcMult * ta.atr(alen)KBot2       = kcMa - kcMult * ta.atr(alen)upperPlot   = plot(showKeltner ? KTop2 : na, color=color.new(color.blue, 0), title="Upper", style = plot.style_stepline)lowerPlot   = plot(showKeltner ? KBot2 : na, color=color.new(color.blue, 0), title="Lower", style = plot.style_stepline)// ---------------------------// Candle Height in Percentage// ---------------------------percentHL   = (high - low) / low * 100percentRed  = open > close ? (open - close) / close * 100 : 0percentGreen= open < close ? (close - open) / open * 100 : 0// --------// NNFX ATR// --------function(source, length) =>    if nnfxSmoothing == "RMA"        ta.rma(source, nnfxAtrLength)    else        if nnfxSmoothing == "SMA"            ta.sma(source, nnfxAtrLength)        else            if nnfxSmoothing == "EMA"                ta.ema(source, nnfxAtrLength)            else                ta.wma(source, nnfxAtrLength)formula(number, decimals) =>    factor  = math.pow(10, decimals)    int(number * factor) / factornnfxAtr     = formula(function(ta.tr(true), nnfxAtrLength), 5) * slAtrMultiplier//SelllongSlAtr   = nnfxAtrLength ? close - nnfxAtr : close + nnfxAtrshortSlAtr  = nnfxAtrLength ? close + nnfxAtr : close - nnfxAtrplot(showAtrSl ? longSlAtr : na,     "Long SL",  color = color.new(color.red, 35), linewidth = 1, trackprice = true, editable = true, style = plot.style_stepline)plot(showAtrSl ? shortSlAtr : na,    "Short SL", color = color.new(color.red, 35), linewidth = 1, trackprice = true, editable = true, style = plot.style_stepline)// =============================================================================// FUNCTIONS// =============================================================================percentAsPoints(pcnt) =>    math.round(pcnt / 100 * close / syminfo.mintick)    calcStopLossPrice(pointsOffset, isLong) =>    priceOffset = pointsOffset * syminfo.mintick    if isLong        close - priceOffset    else         close + priceOffsetcalcProfitTrgtPrice(pointsOffset, isLong) =>    calcStopLossPrice(-pointsOffset, isLong)            printLabel(barIndex, msg) => label.new(barIndex, close, msg)printTpSlHitBox(left, right, slHit, tpHit, entryPrice, slPrice, tpPrice) =>     if showTpSlBoxes        box.new (left = left,   top = entryPrice,   right = right,  bottom = slPrice,   bgcolor = slHit ? color.new(color.red, 60)   : color.new(color.gray, 90), border_width = 0)        box.new (left = left,   top = entryPrice,   right = right,  bottom = tpPrice,   bgcolor = tpHit ? color.new(color.green, 60) : color.new(color.gray, 90), border_width = 0)        line.new(x1 = left,     y1 = entryPrice,    x2 = right,     y2 = entryPrice,    color = color.new(color.yellow, 20))        line.new(x1 = left,     y1 = slPrice,       x2 = right,     y2 = slPrice,       color = color.new(color.red, 20))        line.new(x1 = left,     y1 = tpPrice,       x2 = right,     y2 = tpPrice,       color = color.new(color.green, 20))        printTpSlNotHitBox(left, right, entryPrice, slPrice, tpPrice) =>     if showTpSlBoxes        box.new (left = left,   top = entryPrice,   right = right,  bottom = slPrice,   bgcolor = color.new(color.gray, 90), border_width = 0)        box.new (left = left,   top = entryPrice,   right = right,  bottom = tpPrice,   bgcolor = color.new(color.gray, 90), border_width = 0)        line.new(x1 = left,     y1 = entryPrice,    x2 = right,     y2 = entryPrice,    color = color.new(color.yellow, 20))        line.new(x1 = left,     y1 = slPrice,       x2 = right,     y2 = slPrice,       color = color.new(color.red, 20))        line.new(x1 = left,     y1 = tpPrice,       x2 = right,     y2 = tpPrice,       color = color.new(color.green, 20))        printTradeExitLabel(x, y, posSize, entryPrice, pnl) =>     if showLabels        labelStr = "Position Size: " + str.tostring(math.abs(posSize), "#.##") + "\nPNL: " + str.tostring(pnl, "#.##") + "\nCapital: " + str.tostring(strategy.equity, "#.##") + "\nEntry Price: " + str.tostring(entryPrice, "#.##")        label.new(x = x, y = y, text = labelStr, color = pnl > 0 ? color.new(color.green, 60) : color.new(color.red, 60), textcolor = color.white, style = label.style_label_down)// =============================================================================// STRATEGY LOGIC// =============================================================================// See strategy description at top for details on trade entry/exit logis// ----------// CONDITIONS// ----------// Trade entry and exit variablesvar tradeEntryBar   = bar_indexvar profitPoints    = 0.var lossPoints      = 0.var slPrice         = 0.var tpPrice         = 0.var inLong          = falsevar inShort         = false// Exit calculationsslAmount            = nnfxAtrslPercent           = math.abs((1 - (close - slAmount) / close) * 100)tpPercent           = slPercent * riskRewardtpPoints            = percentAsPoints(tpPercent)tpTarget            = calcProfitTrgtPrice(tpPoints, wtBreakUp)inDateRange         = time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0) and time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0)// Condition 1: SSL Hybrid blue for long or red for shortbullSslHybrid       = useSslHybrid ? close > upperk : truebearSslHybrid       = useSslHybrid ? close < lowerk : true// Condition 2: SSL Channel crosses up for long or down for shortbullSslChannel      = ta.crossover(sslChUp, sslChDown)bearSslChannel      = ta.crossover(sslChDown, sslChUp)// Condition 3: Wave Trend crosses up for long or down for shortbullWaveTrend       = wtBreakUpbearWaveTrend       = wtBreakDown// Condition 4: Entry candle heignt <= 0.6 on Candle Height in PercentagecandleHeightValid   = useCandleHeight ? percentGreen <= candleHeight and percentRed <= candleHeight : true// Condition 5: Entry candle is inside Keltner ChannelwithinCh = keltnerChWicks ? high < KTop2 and low > KBot2 : open < KTop2 and close < KTop2 and open > KBot2 and close > KBot2insideKeltnerCh     = useKeltnerCh ? withinCh : true// Condition 6: TP target does not touch 200 EMAbullTpValid         = useEma ? not (close < ema and tpTarget > ema) : truebearTpValid         = useEma ? not (close > ema and tpTarget < ema) : true// Combine all entry conditionsgoLong              = inDateRange and bullSslHybrid and bullSslChannel and bullWaveTrend and candleHeightValid and insideKeltnerCh and bullTpValidgoShort             = inDateRange and bearSslHybrid and bearSslChannel and bearWaveTrend and candleHeightValid and insideKeltnerCh and bearTpValid// Entry decisionsopenLong            = (goLong and not inLong)openShort           = (goShort and not inShort)flippingSides       = (goLong and inShort) or (goShort and inLong)enteringTrade       = openLong or openShortinTrade             = inLong or inShort// Risk calculationsriskAmt             = strategy.equity * accountRiskPercent / 100entryQty            = math.abs(riskAmt / slPercent * 100)  / closeif openLong    if strategy.position_size < 0        printTpSlNotHitBox(tradeEntryBar + 1, bar_index + 1, strategy.position_avg_price, slPrice, tpPrice)        printTradeExitLabel(bar_index + 1, math.max(tpPrice, slPrice), strategy.position_size, strategy.position_avg_price, strategy.openprofit)    strategy.entry("Long", strategy.long, qty = entryQty, alert_message = "Long Entry")    enteringTrade   := true    inLong          := true    inShort         := false    alert(message="BUY Trade Entry Alert", freq=alert.freq_once_per_bar_close)if openShort    if strategy.position_size > 0        printTpSlNotHitBox(tradeEntryBar + 1, bar_index + 1, strategy.position_avg_price, slPrice, tpPrice)        printTradeExitLabel(bar_index + 1, math.max(tpPrice, slPrice), strategy.position_size, strategy.position_avg_price, strategy.openprofit)    strategy.entry("Short", strategy.short, qty = entryQty, alert_message = "Short Entry")    enteringTrade   := true    inShort         := true    inLong          := false    alert(message="SELL Trade Entry Alert", freq=alert.freq_once_per_bar_close)if enteringTrade    profitPoints    := percentAsPoints(tpPercent)    lossPoints      := percentAsPoints(slPercent)    slPrice         := calcStopLossPrice(lossPoints, openLong)    tpPrice         := calcProfitTrgtPrice(profitPoints, openLong)    tradeEntryBar   := bar_indexstrategy.exit("TP/SL", profit = profitPoints, loss = lossPoints, comment_profit = "TP Hit", comment_loss = "SL Hit", alert_profit = "TP Hit Alert", alert_loss = "SL Hit Alert")// =============================================================================// DRAWINGS// =============================================================================// -----------// TP/SL Boxes// -----------slHit           = (inShort and high >= slPrice) or (inLong  and low <= slPrice)tpHit           = (inLong  and high >= tpPrice) or (inShort and low <= tpPrice)exitTriggered   = slHit or tpHitentryPrice      = strategy.closedtrades.entry_price (strategy.closedtrades - 1)pnl             = strategy.closedtrades.profit      (strategy.closedtrades - 1)posSize         = strategy.closedtrades.size        (strategy.closedtrades - 1)// Print boxes for trades closed at profit or lossif (inTrade and exitTriggered)     inShort    := false    inLong     := false     printTpSlHitBox(tradeEntryBar + 1, bar_index, slHit, tpHit, entryPrice, slPrice, tpPrice)    printTradeExitLabel(bar_index, math.max(tpPrice, slPrice), posSize, entryPrice, pnl)// Print TP/SL box for current open tradeif barstate.islastconfirmedhistory and strategy.position_size != 0    printTpSlNotHitBox(tradeEntryBar + 1, bar_index + 1, strategy.position_avg_price, slPrice, tpPrice)    // =============================================================================// DEBUGGING// =============================================================================// Data window plotsplotchar(goLong,  "Enter Long",  "")plotchar(goShort, "Enter Short", "")