Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Athena Momentum Squeeze - Short, Lean, and Mean

A Pine Script v5 strategy built on EMA (src, len), SMA (sqz_source, 20) and Stdev (sqz_source, 20). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 30 settings; defaults include Broker tradovate, Pair: MSFT and Qty: 1.

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 Athena Momentum Squeeze - Short, Lean, and Mean repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 3 of 3 trades.
How did Athena Momentum Squeeze - Short, Lean, and Mean do on BTCUSDT 1D with default settings?
+3.73%
From 26 Jan 2024 to 21 Oct 2026, over 10 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Athena Momentum Squeeze - Short, Lean, and Mean run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 10 before, 8 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does Athena Momentum Squeeze - Short, Lean, and Mean use a stop loss?
Yes
strategy.exit sets a stop on line 213, 215.
Does Athena Momentum Squeeze - Short, Lean, and Mean run in Zeal Terminal?
Yes
It compiles in 95 ms and runs 1,000 bars in 109 ms, in the browser.

BTCUSDT · 1D · default settings

  • Dark blue dot count
  • Moving Average
  • Entry Price
  • Stop Loss
  • 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 (26)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,037,290$2,025,273Equity from $1,000,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.
Net profit
+3.73%
$37,285.30
Buy and hold
+102.5%
same period
Closed trades
10
7 won · 3 lost
Profitable
70.0%
of closed trades
Profit factor
5.34
gross profit ÷ gross loss
Max drawdown
0.60%
−$6,033.02

One run with the author's default settings, $1,000,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

    1 setting does nothing

    “BB MultFactor” is declared but never read.

  • Check

    No commission

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

  • Note

    1 setting has no label

    In the settings dialog in_ma_w (line 58) shows an empty name. The labels on this page come from the variable names.

  • Note

    No slippage

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

Settings

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

SettingDefaultType and rangeFeeds
AutoView
Brokertradovate/tradovatesimtradovatestringlo_mess sh_mess exl_mess exs_mess
Pair:ZNH2/MSFT/ESH2MSFTstringlo_mess sh_mess exl_mess exs_mess
Qty:q=10% (% of accountsize) \n q=50(Qty)1stringlo_mess sh_mess
Entry
Long entryentry_long_light_greenstringentry_long_sel_light_green entry_long_sel_dark_green
Short entryentry_short_light_redstringentry_short_sel_light_red entry_short_sel_dark_red
Enable squeeze filter?Checks number of dark blue dots before entering a positiontrueboolsqz_filter_cnt_cond
Squeeze dot count6intsqz_filter_cnt_cond
Exit
Long closeexit_long_dark_greenstringexit_long_sel_light_green exit_long_sel_dark_green exit_long_sel_light_red exit_long_sel_dark_red
Short closeexit_short_dark_redstringexit_short_sel_light_green exit_short_sel_dark_green exit_short_sel_light_red exit_short_sel_dark_red
Close only in profitfalseboolstrat_profit_cond_close
Take profit typeexit_type_none_tpstringstrat_tp_price_long strat_tp_price_short
Take profit valuePercantage: Percentage value\nATR: ATR multiplier\nRisk/Reward: R:R ratio2.0float · step 0.1strat_tp_price_long strat_tp_price_short
Stop loss typeexit_type_atr_slstringstrat_sl_price_long strat_sl_price_short
Stop loss valuePercantage: Percentage value\nATR: ATR multiplier2.0float · step 0.1strat_sl_price_long strat_sl_price_short
ATR length14intatr_val
Squeeze Momentum
BB Length20intsqz_basis sqz_dev
BB MultFactor2.0floatunused
KC Length20intsqz_ma sqz_rangema sqz_val
KC MultFactor1.5floatsqz_dev sqz_upperKC sqz_lowerKC
Use TrueRange (KC)trueboolsqz_range_1
Moving Average
Enable moving average filter?trueboolma_cond_long ma_cond_short Moving Average
Typema_type_smastringma_val
Sourceclosesourcema_val
Length200intma_val
Plot?trueboolMoving Average
In ma col (no label in the script)color.yellowcolorMoving Average
In ma w (no label in the script)2intMoving Average
Display
Entry Pricecolor.graycolorEntry Price
Take Profitcolor.greencolorTake Profit Take Profit Fill
Stop Losscolor.redcolorStop Loss Stop Loss Fill

What it calculates

  • EMAsrc, lene1 · line 98
  • EMAe1, lene2 · line 99
  • EMAsrc, lenema1 · line 102
  • EMAema1, lenema2 · line 103
  • EMAema2, lenema3 · line 104
  • SMAsqz_source, BB Length (20)sqz_basis · line 117
  • Stdevsqz_source, BB Length (20)sqz_dev · line 118
  • SMAsqz_source, KC Length (20)sqz_ma · line 122
  • TRsqz_range_1 · line 123
  • SMAsqz_range_1, KC Length (20)sqz_rangema · line 124
  • Linreg / Highest / Lowest / SMAsqz_source - math.avg(math.avg(ta.highest(high, in_sqz_lengthKC), ta.lowest(low, in_sqz_lengthKC)), ta.sma(close, in_sqz_lengthKC)), KC Length (20), 0sqz_val · line 130
  • ATRATR length (14)atr_val · line 155

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

Order rules

OrderFires whenBy defaultLine
Open Long long(strat_long_cond)On162
Open Short short(strat_short_cond)On164
Close Long(strat_is_long and sqz_close_cond_long and strat_profit_cond_close)On167
Close Short(strat_is_short and sqz_close_cond_short and strat_profit_cond_close)On169
Exit LE stop and limit(strat_is_long)On213
Exit SE stop and limit(strat_is_short)On215

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

Does it repaint?

No

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

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

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

Other markets

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

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+3.7%+102.5%1070%5.340.6%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−0.6%+5.5%1323%0.150.7%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.0%+9.8%1145%1.370.1%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.0%+8.4%825%2.660.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.0%+16.7%1136%1.720.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%1136%1.160.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.0%+148.3%1833%1.100.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.0%+17.1%1331%1.880.0%8 May 2026 – 21 Oct 2026

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

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market2100%$23,562.60
Sideways market771%$17,395.70
Falling market10%−$3,673.02

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

How bad could the drawdown be?

0.8%

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

0%1%
All 10 trades
SideEntryExitBarsP&L
short7 Sep 2024 53,963.0011 Sep 2024 57,636.004−$3,673.02
long17 Oct 2024 67,620.0024 Oct 2024 66,668.607−$951.35
long8 Nov 2024 75,857.9024 Nov 2024 97,672.4016$21,814.50
long24 Apr 2025 93,691.1029 Apr 2025 95,011.205$1,320.11
long11 Jul 2025 116,010.0016 Jul 2025 117,758.005$1,748.07
long16 Sep 2025 115,350.0020 Sep 2025 115,632.004$282.68
short9 Nov 2025 102,313.0024 Nov 2025 86,830.0015$15,482.90
short28 May 2026 74,449.3031 May 2026 73,884.403$564.93
short1 Jul 2026 58,624.704 Jul 2026 62,583.303−$3,958.55
long21 Aug 2026 73,027.0031 Aug 2026 77,682.0010$4,654.98

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
Athena Momentum Squeeze - Short, Lean, and Mean this page—v5 strategy+3.7%100.6%
[fpemehd] SSL Baseline Strategy by DuDu95ema sma highest lowest stdev tr atrv5 strategy+2.3%713.7%
SSL + Wave Trend Strategy by kevinmck100ema sma highest lowest stdev tr atrv5 strategy−1.0%11.0%
CHOP Zone Entry Strategy + DMI-PSAR Exit by IronCasperatr highest lowest sma linreg emav4 strategy+17.1%820.0%
Investments-swing trading strategy for different assets by StrategiesForEveryonesma stdev tr linreg ema atrv5 strategy+4.2%1717.6%
ATR GOD Strategy by TradeSmart (PineConnector-compatible) by TradeSmart22atr tr lowest highest sma stdevv5 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.

  • 5 settings use the untyped input() (line 43, 44, 45, 46, 47). 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

VerifiedDownload the v5 script

Same 10 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 43: input() → input.int()
  • Line 44: input() → input.float()
  • Line 45: input() → input.int()
  • Line 46: input() → input.float()
  • Line 47: input() → input.bool()
⋯sqz_gr_name = "Squeeze Momentum"-in_sqz_length = input(20, title='BB Length', group=sqz_gr_name)+in_sqz_length = input.int(20, title='BB Length', group=sqz_gr_name)-in_sqz_mult = input(2.0, title='BB MultFactor', group=sqz_gr_name)+in_sqz_mult = input.float(2.0, title='BB MultFactor', group=sqz_gr_name)-in_sqz_lengthKC = input(20, title='KC Length', group=sqz_gr_name)+in_sqz_lengthKC = input.int(20, title='KC Length', group=sqz_gr_name)-in_sqz_multKC = input(1.5, title='KC MultFactor', group=sqz_gr_name)+in_sqz_multKC = input.float(1.5, title='KC MultFactor', group=sqz_gr_name)-in_sqz_useTrueRange = input(true, title='Use TrueRange (KC)', group=sqz_gr_name)+in_sqz_useTrueRange = input.bool(true, title='Use TrueRange (KC)', group=sqz_gr_name)//}⋯

Does it run in Pine Script v6?

No

The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 10 before, 8 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © vitruvius-//@version=5+//@version=6strategy("Athena Momentum Squeeze - Autoview", overlay=true)⋯

Where it runs

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

“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/// © vitruvius//@version=5strategy("Athena Momentum Squeeze - Autoview", overlay=true)// Inputs {// -- Automate broker = input.string("tradovate","Broker",group="AutoView",tooltip = "tradovate/tradovatesim")pair0 = input.string("MSFT","Pair:",group="AutoView",tooltip = "ZNH2/MSFT/ESH2")qty = input.string("1","Qty:",group="AutoView",tooltip = "q=10% (% of accountsize) \n q=50(Qty)")lo_mess =  "e="+str.tostring(broker)       +" s="+str.tostring(pair0)  +" b=long"     +" q="+str.tostring(qty)      + " t=market delay=1"sh_mess =  "e="+str.tostring(broker)       +" s="+str.tostring(pair0)  +" b=short"    +" q="+str.tostring(qty)      + " t=market delay=1"exl_mess =  "e="+str.tostring(broker)       +" s="+str.tostring(pair0)  +"b=long c=position t=market"exs_mess =  "e="+str.tostring(broker)       +" s="+str.tostring(pair0)  +"b=short c=position t=market"// Entry {entry_gr_name = "Entry"entry_tt_sqz_filter = "Checks number of dark blue dots before entering a position"entry_long_light_green = "Light green", entry_long_dark_green = "Dark green", entry_long_none = "None"entry_short_light_red = "Light red", entry_short_dark_red = "Dark red", entry_short_none = "None"in_entry_sqz_bar_type_long = input.string(entry_long_light_green, "Long entry", [entry_long_light_green, entry_long_dark_green, entry_long_none], group=entry_gr_name)in_entry_sqz_bar_type_short = input.string(entry_short_light_red, "Short entry", [entry_short_light_red, entry_short_dark_red, entry_short_none], group=entry_gr_name)in_entry_sqz_filter_en = input.bool(true, "Enable squeeze filter?", tooltip=entry_tt_sqz_filter, group=entry_gr_name)in_entry_sqz_filter_cnt = input.int(6, "Squeeze dot count", group=entry_gr_name)//}// Exit {exit_gr_name = "Exit"exit_long_light_green = "Light green", exit_long_dark_green = "Dark green", exit_long_light_red = "Light red", exit_long_dark_red = "Dark red", exit_long_none = "None"exit_short_light_green = "Light green", exit_short_dark_green = "Dark green", exit_short_light_red = "Light red", exit_short_dark_red = "Dark red", exit_short_none = "None"exit_type_per_tp = "Percentage", exit_type_atr_tp = "ATR", exit_type_rr_tp = "Risk/Reward", exit_type_none_tp = "None"exit_type_per_sl = "Percentage", exit_type_atr_sl = "ATR", exit_type_none_sl = "None"exit_tt_val_tp = "Percantage: Percentage value\nATR: ATR multiplier\nRisk/Reward: R:R ratio"exit_tt_val_sl = "Percantage: Percentage value\nATR: ATR multiplier"in_exit_sqz_bar_type_long = input.string(exit_long_dark_green, "Long close", [exit_long_light_green, exit_long_dark_green, exit_long_light_red, exit_long_dark_red, exit_long_none], group=exit_gr_name)in_exit_sqz_bar_type_short = input.string(exit_short_dark_red, "Short close", [exit_short_light_green, exit_short_dark_green, exit_short_light_red, exit_short_dark_red, exit_short_none], group=exit_gr_name)in_exit_sqz_bar_close_in_profit = input.bool(false, "Close only in profit", group=exit_gr_name)in_exit_type_tp = input.string(exit_type_none_tp, "Take profit type", [exit_type_per_tp, exit_type_atr_tp, exit_type_rr_tp, exit_type_none_tp], group=exit_gr_name)in_exit_val_tp = input.float(2.0, "Take profit value", step=0.1, tooltip=exit_tt_val_tp, group=exit_gr_name)in_exit_type_sl = input.string(exit_type_atr_sl, "Stop loss type", [exit_type_per_sl, exit_type_atr_sl, exit_type_none_sl], group=exit_gr_name)in_exit_val_sl = input.float(2.0, "Stop loss value", step=0.1, tooltip=exit_tt_val_sl, group=exit_gr_name)in_exit_atr_len = input.int(14, "ATR length", group=exit_gr_name)//}// Squeeze Momentum {sqz_gr_name = "Squeeze Momentum"in_sqz_length = input(20, title='BB Length', group=sqz_gr_name)in_sqz_mult = input(2.0, title='BB MultFactor', group=sqz_gr_name)in_sqz_lengthKC = input(20, title='KC Length', group=sqz_gr_name)in_sqz_multKC = input(1.5, title='KC MultFactor', group=sqz_gr_name)in_sqz_useTrueRange = input(true, title='Use TrueRange (KC)', group=sqz_gr_name)//}// Moving Average {ma_gr_name = "Moving Average"ma_type_rma = "RMA", ma_type_sma = "SMA", ma_type_ema = "EMA", ma_type_wma = "WMA", ma_type_hma = "HMA", ma_type_vwma = "VWMA", ma_type_dema = "DEMA", ma_type_tema = "TEMA"in_ma_en = input.bool(true, "Enable moving average filter?", group=ma_gr_name)in_ma_type = input.string(ma_type_sma, "Type", [ma_type_rma, ma_type_sma, ma_type_ema, ma_type_dema, ma_type_tema, ma_type_wma, ma_type_hma, ma_type_vwma], group=ma_gr_name)in_ma_src = input.source(close, "Source", group=ma_gr_name)in_ma_len = input.int(200, "Length", group=ma_gr_name)in_ma_show = input.bool(true, "Plot?", inline="ma_plot", group=ma_gr_name)in_ma_col = input.color(color.yellow, "", inline="ma_plot", group=ma_gr_name)in_ma_w = input.int(2, "", inline="ma_plot", group=ma_gr_name)//}// Display {disp_gr_name = "Display"in_disp_ep_col = input.color(color.gray, "Entry Price", group=disp_gr_name)in_disp_tp_col = input.color(color.green, "Take Profit", group=disp_gr_name)in_disp_sl_col = input.color(color.red, "Stop Loss", group=disp_gr_name)//}//}// Variables {// Entry {entry_long_sel_light_green = (in_entry_sqz_bar_type_long == entry_long_light_green)entry_long_sel_dark_green = (in_entry_sqz_bar_type_long == entry_long_dark_green)entry_short_sel_light_red = (in_entry_sqz_bar_type_short == entry_short_light_red)entry_short_sel_dark_red = (in_entry_sqz_bar_type_short == entry_short_dark_red)//}// Exit {exit_long_sel_light_green = (in_exit_sqz_bar_type_long == exit_long_light_green)exit_long_sel_dark_green = (in_exit_sqz_bar_type_long == exit_long_dark_green)exit_long_sel_light_red = (in_exit_sqz_bar_type_long == exit_long_light_red)exit_long_sel_dark_red = (in_exit_sqz_bar_type_long == exit_long_dark_red)exit_short_sel_light_green = (in_exit_sqz_bar_type_short == exit_short_light_green)exit_short_sel_dark_green = (in_exit_sqz_bar_type_short == exit_short_dark_green)exit_short_sel_light_red = (in_exit_sqz_bar_type_short == exit_short_light_red)exit_short_sel_dark_red = (in_exit_sqz_bar_type_short == exit_short_dark_red)//}// Strategy {strat_is_long = strategy.position_size > 0strat_is_short = strategy.position_size < 0strat_is_new_pos = (strategy.position_size[1] == 0 and strategy.position_size != 0) or ((strategy.position_size[1] * strategy.position_size) < 0)//}//}// Functions {// Moving Average {f_ma(type, src, len) =>    switch type        ma_type_rma => ta.rma(src, len)        ma_type_sma => ta.sma(src, len)        ma_type_ema => ta.ema(src, len)        ma_type_dema =>             e1 = ta.ema(src, len)            e2 = ta.ema(e1, len)            dema = 2 * e1 - e2        ma_type_tema =>            ema1 = ta.ema(src, len)            ema2 = ta.ema(ema1, len)            ema3 = ta.ema(ema2, len)            out = 3 * (ema1 - ema2) + ema3        ma_type_wma => ta.wma(src, len)        ma_type_hma => ta.hma(src, len)        ma_type_vwma => ta.vwma(src, len)        => ta.ema(src, len)//}//}// Indicator {// Squeeze Momentum {var sqz_dark_blue_dot_cnt = 0// Calculate BBsqz_source = closesqz_basis = ta.sma(sqz_source, in_sqz_length)sqz_dev = in_sqz_multKC * ta.stdev(sqz_source, in_sqz_length)sqz_upperBB = sqz_basis + sqz_devsqz_lowerBB = sqz_basis - sqz_dev// Calculate KCsqz_ma = ta.sma(sqz_source, in_sqz_lengthKC)sqz_range_1 = in_sqz_useTrueRange ? ta.tr : high - lowsqz_rangema = ta.sma(sqz_range_1, in_sqz_lengthKC)sqz_upperKC = sqz_ma + sqz_rangema * in_sqz_multKCsqz_lowerKC = sqz_ma - sqz_rangema * in_sqz_multKCsqz_sqzOn = sqz_lowerBB > sqz_lowerKC and sqz_upperBB < sqz_upperKCsqz_sqzOff = sqz_lowerBB < sqz_lowerKC and sqz_upperBB > sqz_upperKCsqz_noSqz = sqz_sqzOn == false and sqz_sqzOff == falsesqz_val = ta.linreg(sqz_source - math.avg(math.avg(ta.highest(high, in_sqz_lengthKC), ta.lowest(low, in_sqz_lengthKC)), ta.sma(close, in_sqz_lengthKC)), in_sqz_lengthKC, 0)sqz_bar_light_green = (sqz_val > 0) and (sqz_val > nz(sqz_val[1]))sqz_bar_dark_green = (sqz_val > 0) and not (sqz_val > nz(sqz_val[1]))sqz_bar_light_red = not (sqz_val > 0) and (sqz_val < nz(sqz_val[1]))sqz_bar_dark_red = not (sqz_val > 0) and not (sqz_val < nz(sqz_val[1]))sqz_circle_dark_blue = sqz_noSqz or (not sqz_noSqz and sqz_sqzOn)sqz_circle_light_blue = (not sqz_noSqz and not sqz_sqzOn)sqz_bar_cond_long = entry_long_sel_light_green ? sqz_bar_light_green : entry_long_sel_dark_green ? sqz_bar_dark_green : falsesqz_bar_cond_short = entry_short_sel_light_red ? sqz_bar_light_red : entry_short_sel_dark_red ? sqz_bar_dark_red : falsesqz_bar_cond_long := sqz_bar_cond_long and sqz_circle_light_bluesqz_bar_cond_short := sqz_bar_cond_short and sqz_circle_light_bluesqz_close_cond_long = exit_long_sel_light_green ? sqz_bar_light_green : exit_long_sel_dark_green ? sqz_bar_dark_green : exit_long_sel_light_red ? sqz_bar_light_red : exit_long_sel_dark_red ? sqz_bar_dark_red : falsesqz_close_cond_short = exit_short_sel_light_green ? sqz_bar_light_green : exit_short_sel_dark_green ? sqz_bar_dark_green : exit_short_sel_light_red ? sqz_bar_light_red : exit_short_sel_dark_red ? sqz_bar_dark_red : falsesqz_dark_blue_dot_cnt := sqz_circle_dark_blue ? sqz_dark_blue_dot_cnt + 1 : 0sqz_filter_cnt_cond = in_entry_sqz_filter_en ? (sqz_dark_blue_dot_cnt[1] >= in_entry_sqz_filter_cnt) : trueplotchar(sqz_dark_blue_dot_cnt, "Dark blue dot count", "", color=color.blue)//}// Moving Average {ma_val = f_ma(in_ma_type, in_ma_src, in_ma_len)ma_cond_long = in_ma_en ? (close > ma_val) : truema_cond_short = in_ma_en ? (close < ma_val) : trueplot(in_ma_en and in_ma_show ? ma_val : na, "Moving Average", in_ma_col, in_ma_w)//}// ATR {var float atr_at_entry = naatr_val = ta.atr(in_exit_atr_len)atr_at_entry := strat_is_new_pos ? atr_val[1] : atr_at_entry//}// Strategy {strat_long_cond = sqz_bar_cond_long and sqz_filter_cnt_cond and ma_cond_longstrat_short_cond = sqz_bar_cond_short and sqz_filter_cnt_cond and ma_cond_shortif (strat_long_cond)    strategy.entry("Long", strategy.long,alert_message = lo_mess)if (strat_short_cond)    strategy.entry("Short", strategy.short,alert_message = sh_mess)strat_profit_cond_close = in_exit_sqz_bar_close_in_profit ? (strategy.openprofit > 0) : trueif (strat_is_long and sqz_close_cond_long and strat_profit_cond_close)    strategy.close("Long",alert_message = exl_mess)if (strat_is_short and sqz_close_cond_short and strat_profit_cond_close)    strategy.close("Short",alert_message = exs_mess)strat_entry_price = strategy.opentrades.entry_price(strategy.opentrades - 1)// Stop Loss {var float strat_sl_price_long = navar float strat_sl_price_short = nastrat_sl_price_long := if (strat_is_new_pos)    switch in_exit_type_sl        exit_type_per_sl => strategy.position_avg_price * (1 - (in_exit_val_sl * 0.01))        exit_type_atr_sl => strat_entry_price - (in_exit_val_sl * atr_val)        => naelse    strat_sl_price_longstrat_sl_price_short := if (strat_is_new_pos)    switch in_exit_type_sl        exit_type_per_sl => strategy.position_avg_price * (1 + (in_exit_val_sl * 0.01))        exit_type_atr_sl => strat_entry_price + (in_exit_val_sl * atr_val)        => naelse    strat_sl_price_shortfloat strat_sl_price = strat_is_long ? strat_sl_price_long : strat_is_short ? strat_sl_price_short : nastrat_sl_diff = math.abs(strat_entry_price - strat_sl_price)//}// Take Profit {var float strat_tp_price_long = navar float strat_tp_price_short = nastrat_tp_price_long := if (strat_is_new_pos)    switch in_exit_type_tp        exit_type_per_tp => strategy.position_avg_price * (1 + (in_exit_val_tp * 0.01))        exit_type_atr_tp => strat_entry_price + (in_exit_val_tp * atr_val)        exit_type_rr_tp => strat_entry_price + (in_exit_val_tp * strat_sl_diff)        => naelse    strat_tp_price_longstrat_tp_price_short := if (strat_is_new_pos)    switch in_exit_type_tp        exit_type_per_tp => strategy.position_avg_price * (1 - (in_exit_val_tp * 0.01))        exit_type_atr_tp => strat_entry_price - (in_exit_val_tp * atr_val)        exit_type_rr_tp => strat_entry_price - (in_exit_val_tp * strat_sl_diff)        => naelse    strat_tp_price_shortfloat strat_tp_price = strat_is_long ? strat_tp_price_long : strat_is_short ? strat_tp_price_short : na//}if (strat_is_long)    strategy.exit("LE", "Long", stop=strat_sl_price, limit=strat_tp_price, comment_loss="L-SL", comment_profit="L-TP",alert_message = exl_mess)if (strat_is_short)    strategy.exit("SE", "Short", stop=strat_sl_price, limit=strat_tp_price, comment_loss="S-SL", comment_profit="S-TP",alert_message = exs_mess)//}// Display {p_ep = plot(strat_entry_price, "Entry Price", in_disp_ep_col, 1, plot.style_circles)p_tp = plot(strat_tp_price, "Take Profit", in_disp_tp_col, 1, plot.style_circles)p_sl = plot(strat_sl_price, "Stop Loss", in_disp_sl_col, 1, plot.style_circles)fill(p_ep, p_tp, color.new(in_disp_tp_col, 85), title="Take Profit Fill")fill(p_ep, p_sl, color.new(in_disp_sl_col, 85), title="Stop Loss Fill")//}//}