Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Strategy Myth-Busting #7 - MACDBB+SSL+VSF - [MYN]

A Pine Script v5 strategy built on EMA (close, 12), Stdev (macd, 10) and SMA (macd, 10). It has 9 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a profit target and no stop loss. Each trade commits 1.0% of equity and pays 0.075 commission. 51 settings; defaults include BB Periods 10, Fast Length 12 and Slow Length 26.

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 Strategy Myth-Busting #7 - MACDBB+SSL+VSF - [MYN] repaint?
Yes
At least one pattern in the source can repaint: intrabar recalculation.
How did Strategy Myth-Busting #7 - MACDBB+SSL+VSF - [MYN] do on BTCUSDT 1D with default settings?
Not measured
It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
What alerts does Strategy Myth-Busting #7 - MACDBB+SSL+VSF - [MYN] have?
10
SSL Cross Alert; SSL2 Cross Alert; Sell Continuation; Buy Continuation; and more.
Does Strategy Myth-Busting #7 - MACDBB+SSL+VSF - [MYN] run in Pine Script v6?
No
The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L308:C88: 'plot' has no 'transp' parameter in Pine Script v6. Use color.new(color, transparency) instead. The v6 version is shown for reference and is not offered as a download.
Does Strategy Myth-Busting #7 - MACDBB+SSL+VSF - [MYN] use a stop loss?
No
Its exits set a profit target but no stop.

BTCUSDT · 1D · default settings

  • MA Baseline
  • 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 (51)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,000$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. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
Table drawn by the script, as it stood on the last bar
Start: NaN
End: NaN
Net Profit: 0%
Percent Per Day NaN%
Percent Profitable: NaN%
Profit Factor: NaN
Total Trades: 0
Max Wins In A Row: 0
Max Losses In A Row: 0
Net profit
0.00%
$0.00
Buy and hold
+102.5%
same period
Closed trades
0
0 won · 0 lost
Profitable
0.0%
of closed trades
Profit factor
—
gross profit ÷ gross loss
Max drawdown
0.00%
$0.00

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.

  • Check

    3 settings do nothing

    “Signal Length”, “Show SSL1”, “Show ATR bands” are declared but never read.

  • Check

    No stop loss

    strategy.exit is used without a stop, loss or trailing stop.

  • Note

    6 settings have no label

    In the settings dialog fastLength (line 45), slowLength (line 46), signalLength (line 47), useTrueRange (line 272), startPeriodTime (line 423), endPeriodTime (line 425) 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.

  • Note

    Uses an argument v6 removed

    when = on line 485, 486, 487. The upgraded version below moves each call inside an if block.

Settings

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

SettingDefaultType and rangeFeeds
AK MACD BB
BB Periods10int · min 1Std Upper Lower arg
Fast Length (no label in the script)12int · min 1fastMA
Slow Length (no label in the script)26int · min 1slowMA
Signal Length (no label in the script)9int · min 1unused
Number Of bars to look back to ensure MACD isn't above/below Zero Line?1intMACDBBENtryShort MACDBBENtryLong
Show SSL1falseboolunused
Show ATR bandstrueboolunused
ATR Period14intatr_slen line 102 line 105 line 108 line 110
ATR Multi1float · step 0.1upper_band lower_band
ATR SmoothingWMAstring · options ['RMA', 'SMA', 'EMA', 'WMA']line 101 line 104 line 107
SSL1 / Baseline TypeEMAstring · options ['SMA', 'EMA', 'DEMA', 'TEMA', 'LSMA', 'WMA', 'MF', 'VAMA', 'TMA', 'HMA', 'JMA', 'Kijun v2', 'EDSMA', 'McGinley']emaHigh emaLow BBMC Keltma
SSL1 / Baseline Length30intema1 ema2 ema3 beta result alpha e mid kijun conversionLine mg stdev emaHigh emaLow BBMC Keltma rangema adxtruerange adxplus adxminus
SSL2 / Continuation TypeJMAstring · options ['SMA', 'EMA', 'DEMA', 'TEMA', 'WMA', 'MF', 'VAMA', 'TMA', 'HMA', 'JMA', 'McGinley']maHigh maLow
SSL 2 Length5intmaHigh maLow
EXIT TypeHMAstring · options ['DEMA', 'TEMA', 'LSMA', 'VAMA', 'TMA', 'HMA', 'JMA', 'Kijun v2', 'McGinley', 'MF']ExitHigh ExitLow
EXIT Length15intExitHigh ExitLow
Sourceclosesourcedev ema1 result a e mid e0 e1 mg zeros edsma Keltma SSLHybridEntryLong1 SSLHybridEntryShort1 ssf
Kijun MOD Divider1int · max 4conversionLine
* Jurik (JMA) Only - Phase3intphaseRatio
* Jurik (JMA) Only - Power1intalpha
* Volatility Adjusted (VAMA) Only - Volatility lookback length10intvol_up vol_down
Modular Filter Only - Feedbackfalseboola
Modular Filter Only - Feedback Weighting0.5float · min 0 · max 1 · step 0.1a
EDSMA - Super Smoother Filter Length20int · min 1ssf
EDSMA - Super Smoother Filter Poles2int · options [2, 3]ssf
Use True Range (no label in the script)trueboolrange_1
Base Channel Multiplier0.2float · step 0.05upperk lowerk
Color Barstrueboolbarcolor
Continuation ATR Criteria0.9float · step 0.1upper_half lower_half
Number Of bars back to look for SSL pullback4intSSLHybridEntryLong2 SSLHybridEntryShort2
SSL Hybrid
Show BaselinetrueboolMA Baseline
ADX
Average Directional Index (ADX)falsebooladxsig isADXEnabledAndAboveThreshold
ADX Smoothing14intadx adxsig
DI Length14intadxplus adxminus adxsig
ADX Threshold25intisADXEnabledAndAboveThreshold
Date Range
Starttrueboolstart
Start Period Time (no label in the script)timestamp('1 Jan 2019')timestart
Endtrueboolend
End Period Time (no label in the script)timestamp('31 Dec 2030')timeend
Trade Direction
Trade DirectionLong and Shortstring · options ['Long and Short', 'Long Only', 'Short Only']entry Long entry Short line 473 line 476
Take Profit
Take Profit 1 - Target %1float · min 0.0 · step 0.5exit TP1
% Of Position100int · min 0exit TP1
Take Profit 2 - Target %100float · min 0.0 · step 0.5exit TP2
% Of Position100int · min 0exit TP2
Take Profit 3 - Target %100float · min 0.0 · step 0.5exit TP3
% Of Position100int · min 0exit TP3
Take Profit 4 - Target %100float · min 0.0 · step 0.5exit TP4
Stop Loss
Stop Loss (%)2float · min 0.01slLongClose slShortClose
Leverage
Leverage1float · step .5contracts
ProfitView Alert Syntax
Alert Syntax PrefixCRYPTANEX_99FTX_Strategy-Name-HerestringalertSyntaxBase
Dashboard
Show Dashboardtrueboolline 496

What it calculates

  • EMAclose, Fast Length (12)fastMA · line 48
  • EMAclose, Slow Length (26)slowMA · line 49
  • Stdevmacd, BB Periods (10)Std · line 52
  • SMAmacd, BB Periods (10)Upper · line 53
  • SMAmacd, BB Periods (10)Lower · line 54
  • TRtrueatr_slen · line 111
  • EMASource (close), SSL1 / Baseline Length (30)ema1 · line 126
  • EMAema1, SSL1 / Baseline Length (30)ema2 · line 127
  • EMAema2, SSL1 / Baseline Length (30)ema3 · line 128
  • SMA / Linreg / EMA / WMAta.sma(src, math.ceil(len / 2)), math.floor(len / 2) + 1result · line 170
  • EMASource (close), SSL1 / Baseline Length (30)e · line 204
  • EMASource (close), SSL1 / Baseline Length (30)mid · line 212
  • Highestdev, * Volatility Adjusted (VAMA) Only - Volatility lookback length (10)vol_up · line 214
  • Lowestdev, * Volatility Adjusted (VAMA) Only - Volatility lookback length (10)vol_down · line 215
  • Lowest / HighestSSL1 / Baseline Length (30)kijun · line 238
  • Lowest / Highestlen / kidivconversionLine · line 239
  • EMASource (close), SSL1 / Baseline Length (30)mg · line 245
  • Stdevssf, SSL1 / Baseline Length (30)stdev · line 254
  • TRrange_1 · line 275
  • EMArange_1, SSL1 / Baseline Length (30)rangema · line 276
  • Crossoverclose, sslExitbase_cross_Long · line 299
  • CrossoversslExit, closebase_cross_Short · line 300
  • ValuewhenT1, bar_index, 0Z1 · line 359
  • Changehighadxup · line 406
  • Changelowadxdown · line 407
  • RMAta.tr, SSL1 / Baseline Length (30)adxtruerange · line 410
  • RMAmath.abs(adxplus - adxminus) / (adxsum == 0 ? 1 : adxsum), ADX Smoothing (14)adx · line 417

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 178 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Open Long longlongConditionCalc and tradeDirection != 'Short Only' and isInLongPosition == falseOn474
Open Short shortshortConditionCalc and tradeDirection != 'Long Only' and isInShortPosition == falseOn477
Exit TP1 limitcalcPeriodOn481
Exit TP2 limitcalcPeriodOn482
Exit TP3 limitcalcPeriodOn483
Exit TP4 limitcalcPeriodOn484
Close LongslLongCloseclose < strategy.position_avg_price * (1 - stoplossPercent)On485
Close ShortslShortCloseclose > strategy.position_avg_price * (1 + stoplossPercent)On486
Close closeLongCondition or closeShortConditionOn487

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

Alerts

AlertCallMessageLine
SSL Cross AlertalertconditionSSL1 has crossed.329
SSL2 Cross AlertalertconditionSSL2 has crossed.330
Sell ContinuationalertconditionSell Continuation.331
Buy ContinuationalertconditionBuy Continuation.332
Exit SellalertconditionExit Sell Alert.333
Exit BuyalertconditionExit Buy Alert.334
Baseline Buy EntryalertconditionBase Buy Alert.335
Baseline Sell EntryalertconditionBase Sell Alert.336
(no title)alertalertSyntaxBase + 'side:long'475
(no title)alertalertSyntaxBase + 'side:short'478

Does it repaint?

Yes

At least one pattern in the source can repaint; it is marked Check below.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • CheckIntrabar recalculationuses varip. Live values can differ from history.
  • 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 1D0.0%+102.5%00%—0.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%+8.4%00%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%+21.5%00%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h0.0%+17.1%00%—0.0%8 May 2026 – 21 Oct 2026

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

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
Strategy Myth-Busting #7 - MACDBB+SSL+VSF - [MYN] this page—v5 strategy0.0%00.0%
BTC 15 min by RafaelZionisma ema wma linreg stdev highest lowestv4 strategy−25.7%11938.9%
Ruckard TradingLatino by ruckardlinreg rma sma stdev ema highest lowestv4 strategy+64.6%24015.3%
Multi Trend Cross Strategy Template by TradeAutomationema linreg rma sma wma stdev highest lowestv5 strategy+33.0%37.3%
Bollinger Bands + ADX Strategy by tweakerIDrma sma stdev lowest highest valuewhenv4 strategy−9.9%1933.0%
MACD Willy Strategy by PtGamblerrma sma ema highest lowest wmav5 strategyNo trades on this market

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.

  • 3 strategy calls use the when = argument (line 485, 486, 487). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • 19 settings use the untyped input() (line 68, 93, 94, 95, 97, 117, 119, 122, 123, 131, 132, 133, 136, 272, 303, 341, 402, 403, 404). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 68: input() → input.int()
  • Line 93: input() → input.bool()
  • Line 94: input() → input.bool()
  • Line 95: input() → input.bool()
  • Line 97: input() → input.int()
  • Line 117: input() → input.int()
16 more edits
  • Line 119: input() → input.int()
  • Line 122: input() → input.int()
  • Line 123: input() → input.source()
  • Line 131: input() → input.int()
  • Line 132: input() → input.int()
  • Line 133: input() → input.int()
  • Line 136: input() → input.bool()
  • Line 272: input() → input.bool()
  • Line 303: input() → input.bool()
  • Line 341: input() → input.int()
  • Line 402: input() → input.int()
  • Line 403: input() → input.int()
  • Line 404: input() → input.int()
  • Line 485: when = slLongClose → if block
  • Line 486: when = slShortClose → if block
  • Line 487: when = closeLongCondition or closeShortCondition → if block
⋯//needs improvments -MACDBBNumBarsBackToLookForMACDToBelowZero = input(1, title="Number Of bars to look back to ensure MACD isn't above/below Zero Line?")+MACDBBNumBarsBackToLookForMACDToBelowZero = input.int(1, title="Number Of bars to look back to ensure MACD isn't above/below Zero Line?")// Sell when MACD to issue a new continuation short signal.  A new red circle must appear on the indicator and these circles should not be touching accross the zero level while they were previously green ⋯//indicator('SSL Hybrid', overlay=true)-show_Baseline = input(title='Show Baseline', defval=true, group="SSL Hybrid")+show_Baseline = input.bool(title='Show Baseline', defval=true, group="SSL Hybrid")-show_SSL1 = input(title='Show SSL1', defval=false)+show_SSL1 = input.bool(title='Show SSL1', defval=false)-show_atr = input(title='Show ATR bands', defval=true)+show_atr = input.bool(title='Show ATR bands', defval=true)//ATR-atrlen = input(14, 'ATR Period')+atrlen = input.int(14, 'ATR Period')mult = input.float(1, 'ATR Multi', step=0.1)⋯maType = input.string(title='SSL1 / Baseline Type', defval='EMA', options=['SMA', 'EMA', 'DEMA', 'TEMA', 'LSMA', 'WMA', 'MF', 'VAMA', 'TMA', 'HMA', 'JMA', 'Kijun v2', 'EDSMA', 'McGinley'])-len = input(title='SSL1 / Baseline Length', defval=30)+len = input.int(title='SSL1 / Baseline Length', defval=30)SSL2Type = input.string(title='SSL2 / Continuation Type', defval='JMA', options=['SMA', 'EMA', 'DEMA', 'TEMA', 'WMA', 'MF', 'VAMA', 'TMA', 'HMA', 'JMA', 'McGinley'])-len2 = input(title='SSL 2 Length', defval=5)+len2 = input.int(title='SSL 2 Length', defval=5)//SSL3Type = input.string(title='EXIT Type', defval='HMA', options=['DEMA', 'TEMA', 'LSMA', 'VAMA', 'TMA', 'HMA', 'JMA', 'Kijun v2', 'McGinley', 'MF'])-len3 = input(title='EXIT Length', defval=15)+len3 = input.int(title='EXIT Length', defval=15)-src = input(title='Source', defval=close)+src = input.source(title='Source', defval=close)//⋯kidiv = input.int(defval=1, maxval=4, title='Kijun MOD Divider')-jurik_phase = input(title='* Jurik (JMA) Only - Phase', defval=3)+jurik_phase = input.int(title='* Jurik (JMA) Only - Phase', defval=3)-jurik_power = input(title='* Jurik (JMA) Only - Power', defval=1)+jurik_power = input.int(title='* Jurik (JMA) Only - Power', defval=1)-volatility_lookback = input(10, title='* Volatility Adjusted (VAMA) Only - Volatility lookback length')+volatility_lookback = input.int(10, title='* Volatility Adjusted (VAMA) Only - Volatility lookback length')//MFbeta = input.float(0.8, minval=0, maxval=1, step=0.1, title='Modular Filter, General Filter Only - Beta')-feedback = input(false, title='Modular Filter Only - Feedback')+feedback = input.bool(false, title='Modular Filter Only - Feedback')z = input.float(0.5, title='Modular Filter Only - Feedback Weighting', step=0.1, minval=0, maxval=1)⋯BBMC = ma(maType, close, len)-useTrueRange = input(true)+useTrueRange = input.bool(true)multy = input.float(0.2, step=0.05, title='Base Channel Multiplier')⋯//COLORS-show_color_bar = input(title='Color Bars', defval=true)+show_color_bar = input.bool(title='Color Bars', defval=true)color_bar = close > upperk ? #00c3ff : close < lowerk ? #ff0062 : color.gray⋯SSLHybridEntryShort1 = src < BBMC and color_bar == #ff0062-sslHybridNumBarsBackToLookForPullBack = input(4, title="Number Of bars back to look for SSL pullback")+sslHybridNumBarsBackToLookForPullBack = input.int(4, title="Number Of bars back to look for SSL pullback")// Buy when Price action must be moving above the EMA and then it has to create a pullback .  The pullback is confirmed when the color changes from blue to gray or from blue  to red.⋯adxEnabled = input.bool(defval = false , title = "Average Directional Index (ADX)", tooltip = "", group ="ADX" ) -adxlen = input(14, title="ADX Smoothing", group="ADX")+adxlen = input.int(14, title="ADX Smoothing", group="ADX")-adxdilen = input(14, title="DI Length", group="ADX")+adxdilen = input.int(14, title="DI Length", group="ADX")-adxabove = input(25, title="ADX Threshold", group="ADX")+adxabove = input.int(25, title="ADX Threshold", group="ADX")adxdirmov(len) =>⋯    strategy.exit('TP4', profit=per(tp4))-    strategy.close('Long', qty_percent=100, comment='SL Long', when=slLongClose)+    if slLongClose+        strategy.close('Long', qty_percent=100, comment='SL Long')-    strategy.close('Short', qty_percent=100, comment='SL Short', when=slShortClose)+    if slShortClose+        strategy.close('Short', qty_percent=100, comment='SL Short')-    strategy.close_all(when=closeLongCondition or closeShortCondition, comment='Close Postion')+    if closeLongCondition or closeShortCondition+        strategy.close_all(comment='Close Postion')/// Dashboard⋯

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L308:C88: 'plot' has no 'transp' parameter in Pine Script v6. Use color.new(color, transparency) instead. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © myn-//@version=5+//@version=6strategy('Strategy Myth-Busting #7 - MACDBB+SSL+VSF - [MYN]', max_bars_back=5000, overlay=true, pyramiding=0, initial_capital=1000, currency='USD', default_qty_type=strategy.percent_of_equity, default_qty_value=1.0, commission_value=0.075, use_bar_magnifier = false)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 174 msWith a workaround 1,000 bars in 298 msNot measured
PineTSNot testedNot testedNot measured

The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.

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/// © myn//@version=5strategy('Strategy Myth-Busting #7 - MACDBB+SSL+VSF - [MYN]', max_bars_back=5000, overlay=true, pyramiding=0, initial_capital=1000, currency='USD', default_qty_type=strategy.percent_of_equity, default_qty_value=1.0, commission_value=0.075, use_bar_magnifier = false)///////////////////////////////////////* Put your strategy logic below */////////////////////////////////////////nwVqTuPe6yo//5 min//ak MACD BB by AlgoKid//Disable bar colors in style//SSL hybrid by mihkel00// Style disable all but bar colors and ma baseline// Change SSL1 baseline length from 60 to 30 // Change SSL1 baseline type from HMA to EMA//volume strength Finder by Saravanan// Get rid of bar colors on style// Trading Rules// SSL Hybrid.  // Buy only when price action is closed above the EMA and the line is blue color.// Sell priace action must be closed below the EMA and the line is red color// Volume Indicator// Buy when Buyers strength / volume is higher than sellers volume// Opposite// General trading rules// Short// Price action must be moving below the EMA and then it has to create a pullback .  The pullback is confirmed when the color changes from red to gray or from red  to blue.// If the price action is touching the EMA but the line does not change the color, the pullback is not confirmed. // Once we have this pullback we're going to be waiting for the MACD to issue a new continuation short signal.  A red circle must appear on the indicator and these circles should not be touching accross the zero level while they are being greeen // Sellers strength above 50% at the time the MACD indiactor issues a new short signal.// Stop Loss at EMA line 1:1.5 risk ratio.// Functions universal to strategy    f_priorBarsSatisfied(_objectToEval, _numOfBarsToLookBack) =>     returnVal = false    for i = 0 to _numOfBarsToLookBack        if (_objectToEval[i] == true)            returnVal = true// AK MACD BB v 1.00 by Algokid//░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░//indicator('AK MACD BB v 1.00')length = input.int(10, minval=1, title='BB Periods',group="AK MACD BB")dev = input.float(1, minval=0.0001, title='Deviations')//MACDfastLength = input.int(12, minval=1)slowLength = input.int(26, minval=1)signalLength = input.int(9, minval=1)fastMA = ta.ema(close, fastLength)slowMA = ta.ema(close, slowLength)macd = fastMA - slowMA//BollingerBandsStd = ta.stdev(macd, length)Upper = Std * dev + ta.sma(macd, length)Lower = ta.sma(macd, length) - Std * dev//Band1 = plot(Upper, color=color.new(color.gray, 0), style=plot.style_line, linewidth=2, title='Upper Band')//Band2 = plot(Lower, color=color.new(color.gray, 0), style=plot.style_line, linewidth=2, title='lower Band')//fill(Band1, Band2, color=color.new(color.blue, 75), title='Fill')mc = macd >= Upper ? color.lime : color.red// Indicator//plot(macd, color=mc, style=plot.style_circles, linewidth=3)zeroline = 0//plot(zeroline, color=color.new(color.orange, 0), linewidth=2, title='Zeroline')//buy//barcolor(macd > Upper ? color.yellow : na)//short//barcolor(macd < Lower ? color.aqua : na)//needs improvments MACDBBNumBarsBackToLookForMACDToBelowZero = input(1, title="Number Of bars to look back to ensure MACD isn't above/below Zero Line?")// Sell when MACD to issue a new continuation short signal.  A new red circle must appear on the indicator and these circles should not be touching accross the zero level while they were previously green MACDBBENtryShort = mc == color.red and macd < zeroline and f_priorBarsSatisfied(macd < zeroline and mc == color.lime, MACDBBNumBarsBackToLookForMACDToBelowZero)// Buy when MACD to issue a new continuation long signal.  A new green circle must appear on the indicator and these circles should not be touching accross the zero level while they were previously redMACDBBENtryLong = mc == color.lime and macd > zeroline and f_priorBarsSatisfied(macd > zeroline and mc == color.red, MACDBBNumBarsBackToLookForMACDToBelowZero)// SSL Hybrid by Mihkel00//░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░//@version=5//AK MACD BB //created by Algokid , February 24,2015//@version=5//By Mihkel00// This script is designed for the NNFX Method, so it is recommended for Daily charts only. // Tried to implement a few VP NNFX Rules// This script has a SSL / Baseline (you can choose between the SSL or MA), a secondary SSL for continiuation trades and a third SSL for exit trades.// Alerts added for Baseline entries, SSL2 continuations, Exits.// Baseline has a Keltner Channel setting for "in zone" Gray Candles// Added "Candle Size > 1 ATR" Diamonds from my old script with the criteria of being within Baseline ATR range.// Credits// Strategy causecelebre https://www.tradingview.com/u/causecelebre/// SSL Channel ErwinBeckers https://www.tradingview.com/u/ErwinBeckers/// Moving Averages jiehonglim https://www.tradingview.com/u/jiehonglim/// Moving Averages  everget https://www.tradingview.com/u/everget/// "Many Moving Averages" script  Fractured https://www.tradingview.com/u/Fractured///indicator('SSL Hybrid', overlay=true)show_Baseline = input(title='Show Baseline', defval=true, group="SSL Hybrid")show_SSL1 = input(title='Show SSL1', defval=false)show_atr = input(title='Show ATR bands', defval=true)//ATRatrlen = input(14, 'ATR Period')mult = input.float(1, 'ATR Multi', step=0.1)smoothing = input.string(title='ATR Smoothing', defval='WMA', options=['RMA', 'SMA', 'EMA', 'WMA'])ma_function(source, atrlen) =>    if smoothing == 'RMA'        ta.rma(source, atrlen)    else        if smoothing == 'SMA'            ta.sma(source, atrlen)        else            if smoothing == 'EMA'                ta.ema(source, atrlen)            else                ta.wma(source, atrlen)atr_slen = ma_function(ta.tr(true), atrlen)////ATR Up/Low Bandsupper_band = atr_slen * mult + closelower_band = close - atr_slen * mult////BASELINE / SSL1 / SSL2 / EXIT MOVING AVERAGE VALUESmaType = input.string(title='SSL1 / Baseline Type', defval='EMA', options=['SMA', 'EMA', 'DEMA', 'TEMA', 'LSMA', 'WMA', 'MF', 'VAMA', 'TMA', 'HMA', 'JMA', 'Kijun v2', 'EDSMA', 'McGinley'])len = input(title='SSL1 / Baseline Length', defval=30)SSL2Type = input.string(title='SSL2 / Continuation Type', defval='JMA', options=['SMA', 'EMA', 'DEMA', 'TEMA', 'WMA', 'MF', 'VAMA', 'TMA', 'HMA', 'JMA', 'McGinley'])len2 = input(title='SSL 2 Length', defval=5)//SSL3Type = input.string(title='EXIT Type', defval='HMA', options=['DEMA', 'TEMA', 'LSMA', 'VAMA', 'TMA', 'HMA', 'JMA', 'Kijun v2', 'McGinley', 'MF'])len3 = input(title='EXIT Length', defval=15)src = input(title='Source', defval=close)//tema(src, len) =>    ema1 = ta.ema(src, len)    ema2 = ta.ema(ema1, len)    ema3 = ta.ema(ema2, len)    3 * ema1 - 3 * ema2 + ema3kidiv = input.int(defval=1, maxval=4, title='Kijun MOD Divider')jurik_phase = input(title='* Jurik (JMA) Only - Phase', defval=3)jurik_power = input(title='* Jurik (JMA) Only - Power', defval=1)volatility_lookback = input(10, title='* Volatility Adjusted (VAMA) Only - Volatility lookback length')//MFbeta = input.float(0.8, minval=0, maxval=1, step=0.1, title='Modular Filter, General Filter Only - Beta')feedback = input(false, title='Modular Filter Only - Feedback')z = input.float(0.5, title='Modular Filter Only - Feedback Weighting', step=0.1, minval=0, maxval=1)//EDSMAssfLength = input.int(title='EDSMA - Super Smoother Filter Length', minval=1, defval=20)ssfPoles = input.int(title='EDSMA - Super Smoother Filter Poles', defval=2, options=[2, 3])//----//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///SSL 1 and SSL2emaHigh = ma(maType, high, len)emaLow = ma(maType, low, len)maHigh = ma(SSL2Type, high, len2)maLow = ma(SSL2Type, low, len2)///EXITExitHigh = ma(SSL3Type, high, len3)ExitLow = ma(SSL3Type, low, len3)///Keltner Baseline ChannelBBMC = ma(maType, close, len)useTrueRange = input(true)multy = input.float(0.2, step=0.05, title='Base Channel Multiplier')Keltma = ma(maType, src, len)range_1 = useTrueRange ? ta.tr : high - lowrangema = ta.ema(range_1, len)upperk = Keltma + rangema * multylowerk = Keltma - rangema * multy//Baseline Violation Candleopen_pos = open * 1close_pos = close * 1difference = math.abs(close_pos - open_pos)atr_violation = difference > atr_slenInRange = upper_band > BBMC and lower_band < BBMCcandlesize_violation = atr_violation and InRange//plotshape(candlesize_violation, color=color.new(color.white, 0), size=size.tiny, style=shape.diamond, location=location.top, title='Candle Size > 1xATR')//SSL1 VALUESHlv = int(na)Hlv := close > emaHigh ? 1 : close < emaLow ? -1 : Hlv[1]sslDown = Hlv < 0 ? emaHigh : emaLow//SSL2 VALUESHlv2 = int(na)Hlv2 := close > maHigh ? 1 : close < maLow ? -1 : Hlv2[1]sslDown2 = Hlv2 < 0 ? maHigh : maLow//EXIT VALUESHlv3 = int(na)Hlv3 := close > ExitHigh ? 1 : close < ExitLow ? -1 : Hlv3[1]sslExit = Hlv3 < 0 ? ExitHigh : ExitLowbase_cross_Long = ta.crossover(close, sslExit)base_cross_Short = ta.crossover(sslExit, close)codiff = base_cross_Long ? 1 : base_cross_Short ? -1 : na//COLORSshow_color_bar = input(title='Color Bars', defval=true)color_bar = close > upperk ? #00c3ff : close < lowerk ? #ff0062 : color.graycolor_ssl1 = close > sslDown ? #00c3ff : close < sslDown ? #ff0062 : na//PLOTS//plotarrow(codiff, colorup=color.new(#00c3ff, 20), colordown=color.new(#ff0062, 20), title='Exit Arrows', maxheight=20, offset=0)p1 = plot(show_Baseline ? BBMC : na, color=color_bar, linewidth=4, title='MA Baseline', transp=0)//DownPlot = plot(show_SSL1 ? sslDown : na, title='SSL1', linewidth=3, color=color_ssl1, transp=10)barcolor(show_color_bar ? color_bar : na)//up_channel = plot(show_Baseline ? upperk : na, color=color_bar, title='Baseline Upper Channel')//low_channel = plot(show_Baseline ? lowerk : na, color=color_bar, title='Basiline Lower Channel')//fill(up_channel, low_channel, color=color_bar, transp=90)////SSL2 Continiuation from ATRatr_crit = input.float(0.9, step=0.1, title='Continuation ATR Criteria')upper_half = atr_slen * atr_crit + closelower_half = close - atr_slen * atr_critbuy_inatr = lower_half < sslDown2sell_inatr = upper_half > sslDown2sell_cont = close < BBMC and close < sslDown2buy_cont = close > BBMC and close > sslDown2sell_atr = sell_inatr and sell_contbuy_atr = buy_inatr and buy_contatr_fill = buy_atr ? color.green : sell_atr ? color.purple : color.white//LongPlot = plot(sslDown2, title='SSL2', linewidth=2, color=atr_fill, style=plot.style_circles, transp=0)//u = plot(show_atr ? upper_band : na, '+ATR', color=color.new(color.white, 80))//l = plot(show_atr ? lower_band : na, '-ATR', color=color.new(color.white, 80))//ALERTSalertcondition(ta.crossover(close, sslDown), title='SSL Cross Alert', message='SSL1 has crossed.')alertcondition(ta.crossover(close, sslDown2), title='SSL2 Cross Alert', message='SSL2 has crossed.')alertcondition(sell_atr, title='Sell Continuation', message='Sell Continuation.')alertcondition(buy_atr, title='Buy Continuation', message='Buy Continuation.')alertcondition(ta.crossover(close, sslExit), title='Exit Sell', message='Exit Sell Alert.')alertcondition(ta.crossover(sslExit, close), title='Exit Buy', message='Exit Buy Alert.')alertcondition(ta.crossover(close, upperk), title='Baseline Buy Entry', message='Base Buy Alert.')alertcondition(ta.crossover(lowerk, close), title='Baseline Sell Entry', message='Base Sell Alert.')// Buy only when price action is closed above the EMA and the line is blue color.SSLHybridEntryLong1 = src > BBMC and color_bar == #00c3ff// Sell only when action must be closed below the EMA and the line is red colorSSLHybridEntryShort1 = src < BBMC and color_bar == #ff0062sslHybridNumBarsBackToLookForPullBack = input(4, title="Number Of bars back to look for SSL pullback")// Buy when Price action must be moving above the EMA and then it has to create a pullback .  The pullback is confirmed when the color changes from blue to gray or from blue  to red.SSLHybridEntryLong2 = color_bar == #00c3ff  and (f_priorBarsSatisfied(color_bar == #ff0062,sslHybridNumBarsBackToLookForPullBack) or f_priorBarsSatisfied(color_bar == color.gray, sslHybridNumBarsBackToLookForPullBack))// Sell when Price action must be moving below the EMA and then it has to create a pullback .  The pullback is confirmed when the color changes from red to gray or from red  to blue.SSLHybridEntryShort2 = color_bar == #ff0062  and (f_priorBarsSatisfied(color_bar == #00c3ff,sslHybridNumBarsBackToLookForPullBack) or f_priorBarsSatisfied(color_bar == color.gray, sslHybridNumBarsBackToLookForPullBack))SSLHybridEntryLong = SSLHybridEntryLong1 and SSLHybridEntryLong2 SSLHybridEntryShort = SSLHybridEntryShort1 and SSLHybridEntryShort2 // Price action must be moving below the EMA and then it has to create a pullback .  The pullback is confirmed when the color changes from red to gray or from red  to blue.// If the price action is touching the EMA but the line does not change the color, the pullback is not confirmed. // Volume Strength Finder by Saravanan_Ragavan//░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © Saravanan_Ragavan//@version=5//indicator('Volume Strength Finder', 'VSF', overlay=true)T1 = time(timeframe.period, '0915-0916:23456')T2 = time(timeframe.period, '0915-1530:23456')Y = bar_indexZ1 = ta.valuewhen(T1, bar_index, 0)L = Y - Z1 + 1SSPV = 0.00SSNV = 0.00pdw = 0.00ndw = 0.00total_w = 0.00for i = 1 to L - 1 by 1    total_w := high[i] - low[i]    positive = close[i] - low[i]    negative = high[i] - close[i]    pdw := positive / total_w * 100    ndw := negative / total_w * 100    SSPV := volume[i] * pdw / 100 + SSPV    SSNV := volume[i] * ndw / 100 + SSNV    SSNVtotal_v = SSPV + SSNVPos = SSPV / total_v * 100Neg = SSNV / total_v * 100bgc = SSPV > SSNV ? color.green : SSPV < SSNV ? color.red : color.white//barcolor(bgc)var table sDisplay = table.new(position.top_right, 1, 5, bgcolor=color.aqua, frame_width=2, frame_color=color.black)if barstate.islast    table.cell(sDisplay, 0, 0, 'Today\'s Volume : ' + str.tostring(total_v), text_color=color.white, text_size=size.large, bgcolor=color.aqua)    table.cell(sDisplay, 0, 1, 'Buyers Volume: ' + str.tostring(math.round(SSPV)), text_color=color.white, text_size=size.large, bgcolor=color.green)    table.cell(sDisplay, 0, 2, 'Sellers Volume: ' + str.tostring(math.round(SSNV)), text_color=color.white, text_size=size.large, bgcolor=color.red)    table.cell(sDisplay, 0, 3, 'Buyers Strength: ' + str.tostring(math.round(Pos)) + '%', text_color=color.white, text_size=size.large, bgcolor=color.green)    table.cell(sDisplay, 0, 4, 'Sellers Strength: ' + str.tostring(math.round(Neg)) + '%', text_color=color.white, text_size=size.large, bgcolor=color.red)// Sellers strength above 50% at the time the MACD indiactor issues a new short signal.VSFShortEntry = math.round(Neg) > 50// Buyers strength above 50% at the time the MACD indiactor issues a new long signal.VSFLongEntry = math.round(Pos) > 50////////////////////////////////////////* Put your strategy rules below *///////////////////////////////////////longCondition = SSLHybridEntryLong and VSFLongEntry and MACDBBENtryLongshortCondition =SSLHybridEntryShort and VSFShortEntry and MACDBBENtryShort//define as 0 if do not want to usecloseLongCondition = 0closeShortCondition = 0// ADX//░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░adxEnabled = input.bool(defval = false , title = "Average Directional Index (ADX)", tooltip = "", group ="ADX" ) adxlen = input(14, title="ADX Smoothing", group="ADX")adxdilen = input(14, title="DI Length", group="ADX")adxabove = input(25, title="ADX Threshold", group="ADX")adxdirmov(len) =>    adxup = ta.change(high)    adxdown = -ta.change(low)    adxplusDM = na(adxup) ? na : (adxup > adxdown and adxup > 0 ? adxup : 0)    adxminusDM = na(adxdown) ? na : (adxdown > adxup and adxdown > 0 ? adxdown : 0)    adxtruerange = ta.rma(ta.tr, len)    adxplus = fixnan(100 * ta.rma(adxplusDM, len) / adxtruerange)    adxminus = fixnan(100 * ta.rma(adxminusDM, len) / adxtruerange)    [adxplus, adxminus]adx(adxdilen, adxlen) =>    [adxplus, adxminus] = adxdirmov(adxdilen)    adxsum = adxplus + adxminus    adx = 100 * ta.rma(math.abs(adxplus - adxminus) / (adxsum == 0 ? 1 : adxsum), adxlen)adxsig = adxEnabled ? adx(adxdilen, adxlen) : naisADXEnabledAndAboveThreshold = adxEnabled ? (adxsig > adxabove) : true//Backtesting Time Period (Input.time not working as expected as of 03/30/2021.  Giving odd start/end dates//░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░useStartPeriodTime = input.bool(true, 'Start', group='Date Range', inline='Start Period')startPeriodTime = input.time(timestamp('1 Jan 2019'), '', group='Date Range', inline='Start Period')useEndPeriodTime = input.bool(true, 'End', group='Date Range', inline='End Period')endPeriodTime = input.time(timestamp('31 Dec 2030'), '', group='Date Range', inline='End Period')start = useStartPeriodTime ? startPeriodTime >= time : falseend = useEndPeriodTime ? endPeriodTime <= time : falsecalcPeriod = not start and not end// Trade Direction // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░tradeDirection = input.string('Long and Short', title='Trade Direction', options=['Long and Short', 'Long Only', 'Short Only'], group='Trade Direction')// Percent as Points// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░per(pcnt) =>    strategy.position_size != 0 ? math.round(pcnt / 100 * strategy.position_avg_price / syminfo.mintick) : float(na)// Take profit 1// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░tp1 = input.float(title='Take Profit 1 - Target %', defval=1, minval=0.0, step=0.5, group='Take Profit', inline='Take Profit 1')q1 = input.int(title='% Of Position', defval=100, minval=0, group='Take Profit', inline='Take Profit 1')// Take profit 2// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░tp2 = input.float(title='Take Profit 2 - Target %', defval=100, minval=0.0, step=0.5, group='Take Profit', inline='Take Profit 2')q2 = input.int(title='% Of Position', defval=100, minval=0, group='Take Profit', inline='Take Profit 2')// Take profit 3// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░tp3 = input.float(title='Take Profit 3 - Target %', defval=100, minval=0.0, step=0.5, group='Take Profit', inline='Take Profit 3')q3 = input.int(title='% Of Position', defval=100, minval=0, group='Take Profit', inline='Take Profit 3')// Take profit 4// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░tp4 = input.float(title='Take Profit 4 - Target %', defval=100, minval=0.0, step=0.5, group='Take Profit')/// Stop Loss// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░stoplossPercent = input.float(title='Stop Loss (%)', defval=2, minval=0.01, group='Stop Loss') * 0.01slLongClose = close < strategy.position_avg_price * (1 - stoplossPercent)slShortClose = close > strategy.position_avg_price * (1 + stoplossPercent)/// Leverage// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░leverage = input.float(1, 'Leverage', step=.5, group='Leverage')contracts = math.min(math.max(.000001, strategy.equity / close * leverage), 1000000000)/// Trade State Management// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░isInLongPosition = strategy.position_size > 0isInShortPosition = strategy.position_size < 0/// ProfitView Alert Syntax String Generation// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░alertSyntaxPrefix = input.string(defval='CRYPTANEX_99FTX_Strategy-Name-Here', title='Alert Syntax Prefix', group='ProfitView Alert Syntax')alertSyntaxBase = alertSyntaxPrefix + '\n#' + str.tostring(open) + ',' + str.tostring(high) + ',' + str.tostring(low) + ',' + str.tostring(close) + ',' + str.tostring(volume) + ','/// Trade Execution// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░longConditionCalc = (longCondition and isADXEnabledAndAboveThreshold)shortConditionCalc = (shortCondition and isADXEnabledAndAboveThreshold)if calcPeriod    if longConditionCalc and tradeDirection != 'Short Only' and isInLongPosition == false        strategy.entry('Long', strategy.long, qty=contracts)        alert(message=alertSyntaxBase + 'side:long', freq=alert.freq_once_per_bar_close)    if shortConditionCalc and tradeDirection != 'Long Only' and isInShortPosition == false        strategy.entry('Short', strategy.short, qty=contracts)        alert(message=alertSyntaxBase + 'side:short', freq=alert.freq_once_per_bar_close)        //Inspired from Multiple %% profit exits example by adolgo https://www.tradingview.com/script/kHhCik9f-Multiple-profit-exits-example/    strategy.exit('TP1', qty_percent=q1, profit=per(tp1))    strategy.exit('TP2', qty_percent=q2, profit=per(tp2))    strategy.exit('TP3', qty_percent=q3, profit=per(tp3))    strategy.exit('TP4', profit=per(tp4))    strategy.close('Long', qty_percent=100, comment='SL Long', when=slLongClose)    strategy.close('Short', qty_percent=100, comment='SL Short', when=slShortClose)    strategy.close_all(when=closeLongCondition or closeShortCondition, comment='Close Postion')/// Dashboard// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░// Inspired by https://www.tradingview.com/script/uWqKX6A2/ - Thanks VertMTshowDashboard = input.bool(group="Dashboard", title="Show Dashboard", defval=true)f_fillCell(_table, _column, _row, _title, _value, _bgcolor, _txtcolor) =>    _cellText = _title + "\n" + _value    table.cell(_table, _column, _row, _cellText, bgcolor=_bgcolor, text_color=_txtcolor, text_size=size.auto)// Draw dashboard tableif showDashboard    var bgcolor = color.new(color.black,0)        // Keep track of Wins/Losses streaks    newWin  = (strategy.wintrades  > strategy.wintrades[1]) and (strategy.losstrades == strategy.losstrades[1]) and (strategy.eventrades == strategy.eventrades[1])    newLoss = (strategy.wintrades == strategy.wintrades[1]) and (strategy.losstrades  > strategy.losstrades[1]) and (strategy.eventrades == strategy.eventrades[1])    varip int winRow     = 0    varip int lossRow    = 0    varip int maxWinRow  = 0    varip int maxLossRow = 0    if newWin        lossRow := 0        winRow := winRow + 1    if winRow > maxWinRow        maxWinRow := winRow            if newLoss        winRow := 0        lossRow := lossRow + 1    if lossRow > maxLossRow        maxLossRow := lossRow    // Prepare stats table    var table dashTable = table.new(position.bottom_right, 1, 15, border_width=1)           if barstate.islastconfirmedhistory        // Update table        dollarReturn = strategy.netprofit        f_fillCell(dashTable, 0, 0, "Start:", str.format("{0,date,long}", strategy.closedtrades.entry_time(0)) , bgcolor, color.white) // + str.format(" {0,time,HH:mm}", strategy.closedtrades.entry_time(0))         f_fillCell(dashTable, 0, 1, "End:", str.format("{0,date,long}", strategy.opentrades.entry_time(0)) , bgcolor, color.white) // + str.format(" {0,time,HH:mm}", strategy.opentrades.entry_time(0))        _profit = (strategy.netprofit / strategy.initial_capital) * 100        f_fillCell(dashTable, 0, 2, "Net Profit:", str.tostring(_profit, '##.##') + "%", _profit > 0 ? color.green : color.red, color.white)        _numOfDaysInStrategy = (strategy.opentrades.entry_time(0) - strategy.closedtrades.entry_time(0)) / (1000 * 3600 * 24)        f_fillCell(dashTable, 0, 3, "Percent Per Day", str.tostring(_profit / _numOfDaysInStrategy, '#########################.#####')+"%", _profit > 0 ? color.green : color.red, color.white)        _winRate = ( strategy.wintrades / strategy.closedtrades ) * 100        f_fillCell(dashTable, 0, 4, "Percent Profitable:", str.tostring(_winRate, '##.##') + "%", _winRate < 50 ? color.red : _winRate < 75 ? #999900 : color.green, color.white)        f_fillCell(dashTable, 0, 5, "Profit Factor:", str.tostring(strategy.grossprofit / strategy.grossloss,  '##.###'), strategy.grossprofit > strategy.grossloss ? color.green : color.red, color.white)        f_fillCell(dashTable, 0, 6, "Total Trades:", str.tostring(strategy.closedtrades), bgcolor, color.white)        f_fillCell(dashTable, 0, 8, "Max Wins In A Row:", str.tostring(maxWinRow, '######') , bgcolor, color.white)        f_fillCell(dashTable, 0, 9, "Max Losses In A Row:", str.tostring(maxLossRow, '######') , bgcolor, color.white)