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
| 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| AK MACD BB | |||
| BB Periods | 10 | int · min 1 | Std Upper Lower arg |
| Fast Length (no label in the script) | 12 | int · min 1 | fastMA |
| Slow Length (no label in the script) | 26 | int · min 1 | slowMA |
| Signal Length (no label in the script) | 9 | int · min 1 | unused |
| Number Of bars to look back to ensure MACD isn't above/below Zero Line? | 1 | int | MACDBBENtryShort MACDBBENtryLong |
| Show SSL1 | false | bool | unused |
| Show ATR bands | true | bool | unused |
| ATR Period | 14 | int | atr_slen line 102 line 105 line 108 line 110 |
| ATR Multi | 1 | float · step 0.1 | upper_band lower_band |
| ATR Smoothing | WMA | string · options ['RMA', 'SMA', 'EMA', 'WMA'] | line 101 line 104 line 107 |
| SSL1 / Baseline Type | EMA | string · options ['SMA', 'EMA', 'DEMA', 'TEMA', 'LSMA', 'WMA', 'MF', 'VAMA', 'TMA', 'HMA', 'JMA', 'Kijun v2', 'EDSMA', 'McGinley'] | emaHigh emaLow BBMC Keltma |
| SSL1 / Baseline Length | 30 | int | ema1 ema2 ema3 beta result alpha e mid kijun conversionLine mg stdev emaHigh emaLow BBMC Keltma rangema adxtruerange adxplus adxminus |
| SSL2 / Continuation Type | JMA | string · options ['SMA', 'EMA', 'DEMA', 'TEMA', 'WMA', 'MF', 'VAMA', 'TMA', 'HMA', 'JMA', 'McGinley'] | maHigh maLow |
| SSL 2 Length | 5 | int | maHigh maLow |
| EXIT Type | HMA | string · options ['DEMA', 'TEMA', 'LSMA', 'VAMA', 'TMA', 'HMA', 'JMA', 'Kijun v2', 'McGinley', 'MF'] | ExitHigh ExitLow |
| EXIT Length | 15 | int | ExitHigh ExitLow |
| Source | close | source | dev ema1 result a e mid e0 e1 mg zeros edsma Keltma SSLHybridEntryLong1 SSLHybridEntryShort1 ssf |
| Kijun MOD Divider | 1 | int · max 4 | conversionLine |
| * Jurik (JMA) Only - Phase | 3 | int | phaseRatio |
| * Jurik (JMA) Only - Power | 1 | int | alpha |
| * Volatility Adjusted (VAMA) Only - Volatility lookback length | 10 | int | vol_up vol_down |
| Modular Filter Only - Feedback | false | bool | a |
| Modular Filter Only - Feedback Weighting | 0.5 | float · min 0 · max 1 · step 0.1 | a |
| EDSMA - Super Smoother Filter Length | 20 | int · min 1 | ssf |
| EDSMA - Super Smoother Filter Poles | 2 | int · options [2, 3] | ssf |
| Use True Range (no label in the script) | true | bool | range_1 |
| Base Channel Multiplier | 0.2 | float · step 0.05 | upperk lowerk |
| Color Bars | true | bool | barcolor |
| Continuation ATR Criteria | 0.9 | float · step 0.1 | upper_half lower_half |
| Number Of bars back to look for SSL pullback | 4 | int | SSLHybridEntryLong2 SSLHybridEntryShort2 |
| SSL Hybrid | |||
| Show Baseline | true | bool | MA Baseline |
| ADX | |||
| Average Directional Index (ADX) | false | bool | adxsig isADXEnabledAndAboveThreshold |
| ADX Smoothing | 14 | int | adx adxsig |
| DI Length | 14 | int | adxplus adxminus adxsig |
| ADX Threshold | 25 | int | isADXEnabledAndAboveThreshold |
| Date Range | |||
| Start | true | bool | start |
| Start Period Time (no label in the script) | timestamp('1 Jan 2019') | time | start |
| End | true | bool | end |
| End Period Time (no label in the script) | timestamp('31 Dec 2030') | time | end |
| Trade Direction | |||
| Trade Direction | Long and Short | string · options ['Long and Short', 'Long Only', 'Short Only'] | entry Long entry Short line 473 line 476 |
| Take Profit | |||
| Take Profit 1 - Target % | 1 | float · min 0.0 · step 0.5 | exit TP1 |
| % Of Position | 100 | int · min 0 | exit TP1 |
| Take Profit 2 - Target % | 100 | float · min 0.0 · step 0.5 | exit TP2 |
| % Of Position | 100 | int · min 0 | exit TP2 |
| Take Profit 3 - Target % | 100 | float · min 0.0 · step 0.5 | exit TP3 |
| % Of Position | 100 | int · min 0 | exit TP3 |
| Take Profit 4 - Target % | 100 | float · min 0.0 · step 0.5 | exit TP4 |
| Stop Loss | |||
| Stop Loss (%) | 2 | float · min 0.01 | slLongClose slShortClose |
| Leverage | |||
| Leverage | 1 | float · step .5 | contracts |
| ProfitView Alert Syntax | |||
| Alert Syntax Prefix | CRYPTANEX_99FTX_Strategy-Name-Here | string | alertSyntaxBase |
| Dashboard | |||
| Show Dashboard | true | bool | line 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 - TRtrue
atr_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) + 1
result · 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 / kidiv
conversionLine · line 239 - EMASource (close), SSL1 / Baseline Length (30)
mg · line 245 - Stdevssf, SSL1 / Baseline Length (30)
stdev · line 254 - TR
range_1 · line 275 - EMArange_1, SSL1 / Baseline Length (30)
rangema · line 276 - Crossoverclose, sslExit
base_cross_Long · line 299 - CrossoversslExit, close
base_cross_Short · line 300 - ValuewhenT1, bar_index, 0
Z1 · line 359 - Changehigh
adxup · line 406 - Changelow
adxdown · 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
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Long long | longConditionCalc and tradeDirection != 'Short Only' and isInLongPosition == false | On | 474 |
| Open Short short | shortConditionCalc and tradeDirection != 'Long Only' and isInShortPosition == false | On | 477 |
| Exit TP1 limit | calcPeriod | On | 481 |
| Exit TP2 limit | calcPeriod | On | 482 |
| Exit TP3 limit | calcPeriod | On | 483 |
| Exit TP4 limit | calcPeriod | On | 484 |
| Close Long | slLongCloseclose < strategy.position_avg_price * (1 - stoplossPercent) | On | 485 |
| Close Short | slShortCloseclose > strategy.position_avg_price * (1 + stoplossPercent) | On | 486 |
| Close | closeLongCondition or closeShortCondition | On | 487 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Alerts
| Alert | Call | Message | Line |
|---|---|---|---|
| SSL Cross Alert | alertcondition | SSL1 has crossed. | 329 |
| SSL2 Cross Alert | alertcondition | SSL2 has crossed. | 330 |
| Sell Continuation | alertcondition | Sell Continuation. | 331 |
| Buy Continuation | alertcondition | Buy Continuation. | 332 |
| Exit Sell | alertcondition | Exit Sell Alert. | 333 |
| Exit Buy | alertcondition | Exit Buy Alert. | 334 |
| Baseline Buy Entry | alertcondition | Base Buy Alert. | 335 |
| Baseline Sell Entry | alertcondition | Base Sell Alert. | 336 |
| (no title) | alert | alertSyntaxBase + 'side:long' | 475 |
| (no title) | alert | alertSyntaxBase + 'side:short' | 478 |
Does it repaint?
Yes
At least one pattern in the source can repaint; it is marked Check below.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | 0.0% | +102.5% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | 0.0% | +9.8% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | 0.0% | +8.4% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | 0.0% | +16.7% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | 0.0% | +21.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | 0.0% | +148.3% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | 0.0% | +17.1% | 0 | 0% | — | 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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Strategy Myth-Busting #7 - MACDBB+SSL+VSF - [MYN] this page | — | v5 strategy | 0.0% | 0 | 0.0% |
| BTC 15 min by RafaelZioni | sma ema wma linreg stdev highest lowest | v4 strategy | −25.7% | 119 | 38.9% |
| Ruckard TradingLatino by ruckard | linreg rma sma stdev ema highest lowest | v4 strategy | +64.6% | 240 | 15.3% |
| Multi Trend Cross Strategy Template by TradeAutomation | ema linreg rma sma wma stdev highest lowest | v5 strategy | +33.0% | 3 | 7.3% |
| Bollinger Bands + ADX Strategy by tweakerID | rma sma stdev lowest highest valuewhen | v4 strategy | −9.9% | 19 | 33.0% |
| MACD Willy Strategy by PtGambler | rma sma ema highest lowest wma | v5 strategy | No 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 verifiedNeither 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
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 174 ms | With a workaround 1,000 bars in 298 ms | Not measured |
| PineTS | Not tested | Not tested | Not 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)