Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Daytrade strategy RSI CCI EMA 4-8

A Pine Script v4 strategy built on EMA (close, 4), RMA or Change or EMA (14) and CCI (source, 6). It has 4 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. 13 settings; defaults include Length_MA4 4, Source close and Offset 0.

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 Daytrade strategy RSI CCI EMA 4-8 repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 6 of 6 trades.
How did Daytrade strategy RSI CCI EMA 4-8 do on BTCUSDT 1D with default settings?
+0.00%
From 26 Jan 2024 to 21 Oct 2026, over 26 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Daytrade strategy RSI CCI EMA 4-8 be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
Does Daytrade strategy RSI CCI EMA 4-8 use a stop loss?
Yes
strategy.exit sets a stop on line 93, 94.
Does Daytrade strategy RSI CCI EMA 4-8 run in Zeal Terminal?
Yes
It compiles in 20 ms and runs 1,000 bars in 48 ms, in the browser.

BTCUSDT · 1D · default settings

  • EMA
  • EMA
  • 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 (13)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$100,003$202,527Equity from $100,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.
Net profit
+0.00%
$3.12
Buy and hold
+102.5%
same period
Closed trades
26
13 won · 13 lost
Profitable
50.0%
of closed trades
Profit factor
1.25
gross profit ÷ gross loss
Max drawdown
0.00%
−$3.36

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

Review

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

  • Likely bug

    ema(rsi, 21) ignores the settings line 25

    Line 25 hard-codes 21 where line 8 uses “Length_MA4”. Changing those settings moves one band but not this one.

    ema(rsi, 21)ema(rsi, len4)
  • Check

    No commission

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

  • Note

    4 settings have no label

    In the settings dialog a (line 38), b (line 39), tp (line 84), sl (line 85) 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 87, 89. The upgraded version below moves each call inside an if block.

Upgrade and export

Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.

  • Upgrading to v5 renames ema → ta.ema, rma → ta.rma, max → math.max, change → ta.change, min → math.min, cci → ta.cci, crossover → ta.crossover, crossunder → ta.crossunder.
  • 2 strategy calls use the when = argument (line 87, 89). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 7: input(type = input.integer) → input.int()
  • Line 8: ema → ta.ema
  • Line 12: input(type = input.integer) → input.int()
  • Line 13: ema → ta.ema
  • Line 17: rma → ta.rma
14 more edits
  • Line 17: max → math.max
  • Line 17: change → ta.change
  • Line 17: ema → ta.ema
  • Line 18: rma → ta.rma
  • Line 18: min → math.min
  • Line 18: change → ta.change
  • Line 18: ema → ta.ema
  • Line 25: ema → ta.ema
  • Line 28: input(type = input.integer) → input.int()
  • Line 29: input(type = input.integer) → input.int()
  • Line 31: cci → ta.cci
  • Line 32: cci → ta.cci
  • Line 42: crossover → ta.crossover
  • Line 43: crossunder → ta.crossunder
⋯// © SoftKill21-//@version=4+//@version=5strategy(title="Moving Average Exponential", shorttitle="EMA", overlay=true)⋯src4 = input(close, title="Source")-offset4 = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500)+offset4 = input.int(title="Offset", defval=0, minval=-500, maxval=500)-out4 = ema(src4, len4)+out4 = ta.ema(src4, len4)plot(out4, title="EMA", color=color.blue, offset=offset4)⋯src8 = input(close, title="Source")-offset8 = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500)+offset8 = input.int(title="Offset", defval=0, minval=-500, maxval=500)-out8 = ema(src8, len8)+out8 = ta.ema(src8, len8)plot(out8, title="EMA", color=color.blue, offset=offset8)⋯src = close, len = input(14, minval=1, title="Length")-up = rma(max(change(ema(src, len)), 0), len)+up = ta.rma(math.max(ta.change(ta.ema(src, len)), 0), len)-down = rma(-min(change(ema(src, len)), 0), len)+down = ta.rma(-math.min(ta.change(ta.ema(src, len)), 0), len)rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))⋯//hline(50, color=color.gray, linestyle=plot.style_line)-sig = ema(rsi, 21)+sig = ta.ema(rsi, 21)//plot(sig, color=color.purple)//woodie-cciTurboLength = input(title="CCI Turbo Length", type=input.integer, defval=6, minval=3, maxval=14)+cciTurboLength = input.int(title="CCI Turbo Length", defval=6, minval=3, maxval=14)-cci14Length = input(title="CCI 14 Length", type=input.integer, defval=14, minval=7, maxval=20)+cci14Length = input.int(title="CCI 14 Length", defval=14, minval=7, maxval=20)source = close-cciTurbo = cci(source, cciTurboLength)+cciTurbo = ta.cci(source, cciTurboLength)-cci14 = cci(source, cci14Length)+cci14 = ta.cci(source, cci14Length)last5IsDown = cci14[5] < 0 and cci14[4] < 0 and cci14[3] < 0 and cci14[2] < 0 and cci14[1] < 0⋯d = b*syminfo.mintick-longCondition = crossover(out4, out8) and (rsi >= 65 and cci14>=0)+longCondition = ta.crossover(out4, out8) and (rsi >= 65 and cci14>=0)-shortCondition = crossunder(out4, out8) and (rsi <=35 and cci14<=0)+shortCondition = ta.crossunder(out4, out8) and (rsi <=35 and cci14<=0)long_stop_level     = float(na)⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 5: input() → input.int()
  • Line 6: input() → input.source()
  • Line 10: input() → input.int()
  • Line 11: input() → input.source()
  • Line 16: input() → input.int()
  • Line 38: input() → input.int()
5 more edits
  • Line 39: input() → input.int()
  • Line 84: input() → input.int()
  • Line 85: input() → input.int()
  • Line 87: when = longCondition → if block
  • Line 89: when = shortCondition → if block
⋯strategy(title="Moving Average Exponential", shorttitle="EMA", overlay=true)-len4 = input(4, minval=1, title="Length_MA4")+len4 = input.int(4, minval=1, title="Length_MA4")-src4 = input(close, title="Source")+src4 = input.source(close, title="Source")offset4 = input.int(title="Offset", defval=0, minval=-500, maxval=500)⋯plot(out4, title="EMA", color=color.blue, offset=offset4)-len8 = input(8, minval=1, title="Length_MA8")+len8 = input.int(8, minval=1, title="Length_MA8")-src8 = input(close, title="Source")+src8 = input.source(close, title="Source")offset8 = input.int(title="Offset", defval=0, minval=-500, maxval=500)⋯//rsioma-src = close, len = input(14, minval=1, title="Length")+src = close, len = input.int(14, minval=1, title="Length")up = ta.rma(math.max(ta.change(ta.ema(src, len)), 0), len)⋯// Exit Condition-a = input(12)*10+a = input.int(12)*10-b = input(15)*10+b = input.int(15)*10c = a*syminfo.mintick⋯//plotcandle(o2, h2, l2, c2, title="HA Smoothed", color=ha_col)-tp=input(120)+tp=input.int(120)-sl=input(96)+sl=input.int(96)    -strategy.entry("long", strategy.long, when = longCondition)+if longCondition+    strategy.entry("long", strategy.long)//strategy.close("long", when = o2>c2 , comment="ha_long")-strategy.entry("short", strategy.short , when =shortCondition )+if shortCondition+    strategy.entry("short", strategy.short  )//strategy.close("short", when = o2<=c2 , comment = "ha_short" )⋯

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: 26 before, 20 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.

⋯// © SoftKill21-//@version=5+//@version=6strategy(title="Moving Average Exponential", shorttitle="EMA", overlay=true)⋯

Settings

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

SettingDefaultType and rangeFeeds
Length_MA44int · min 1out4
Sourceclosesourceout4
Offset0int (written input.integer) · min -500 · max 500EMA
Length_MA88int · min 1out8
Sourceclosesourceout8
Offset0int (written input.integer) · min -500 · max 500EMA
Length14int · min 1up down
CCI Turbo Length6int (written input.integer) · min 3 · max 14cciTurbo
CCI 14 Length14int (written input.integer) · min 7 · max 20cci14
A (no label in the script)12intc
B (no label in the script)15intd
Tp (no label in the script)120intexit x_long exit x_short
Sl (no label in the script)96intexit x_long exit x_short

What it calculates

  • EMA (ema, ta.ema in v5)Source (close), Length_MA4 (4)out4 · line 8
  • EMA (ema, ta.ema in v5)Source (close), Length_MA8 (8)out8 · line 13
  • RMA / Change / EMA (rma, ta.rma in v5)max(change(ema(src, len)), 0), Length (14)up · line 17
  • RMA / Change / EMA (rma, ta.rma in v5)-min(change(ema(src, len)), 0), Length (14)down · line 18
  • EMA (ema, ta.ema in v5)rsi, 21sig · line 25
  • CCI (cci, ta.cci in v5)source, CCI Turbo Length (6)cciTurbo · line 31
  • CCI (cci, ta.cci in v5)source, CCI 14 Length (14)cci14 · line 32

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.

closecloseprice datalen4Length_MA4setting · 4len8Length_MA8setting · 8lenLengthsetting · 14cciTurboLengthCCI Turbo Lengthsetting · 6cci14LengthCCI 14 Lengthsetting · 14aAsetting · 12bBsetting · 15out4EMA→ out4out8EMA→ out8upRMA / Change / EMA→ updownRMA / Change / EMA→ downsigEMA→ sigcciTurboCCI→ cciTurbocci14CCI→ cci14src, sourcesrc · source2 valuesrsirsivalueccvalueddvaluelong_stop_levellong_stop_levelvaluelong_profit_level1long_profit_level1valuelong_profit_level2, long_even_level, short_profit_level2, short_even_levellong_profit_level2 · lo…4 valuesshort_stop_levelshort_stop_levelvalueshort_profit_level1short_profit_level1valuelongConditionlongConditionconditionshortConditionshortConditionconditionlast5IsDown, last5IsUplast5IsDown · last5IsUp2 conditionshistogramColorColourhistogramColorentry:longOpen longstrategy.entryentry:shortOpen shortstrategy.entryexit:x_longexit x_longstrategy.exitexit:x_shortexit x_shortstrategy.exitplot:9EMAplotplot:14EMAplot

Order rules

OrderFires whenBy defaultLine
Open long longlongConditioncrossover(out4, out8) and (rsi >= 65 and cci14>=0)On87
Open short shortshortConditioncrossunder(out4, out8) and (rsi <=35 and cci14<=0)On89
Exit x_long stop and limitevery barOn93
Exit x_short stop and limitevery barOn94

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.

6/6trades 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+0.0%+102.5%2650%1.250.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+0.0%+5.5%2255%1.500.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−0.0%+9.8%3030%0.540.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.0%+8.4%3165%2.270.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.0%+16.7%2552%1.350.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−0.0%+21.5%2030%0.540.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.0%+148.3%2646%1.070.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.0%+17.1%2343%0.960.0%8 May 2026 – 21 Oct 2026

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

Settings heatmap

Two settings that feed the entry signal, moved around their defaults. The best in-sample pair (Length_MA4 2, Length_MA8 4) made +0.0% before 26 Dec 2025 and −0.0% after it, worse than the defaults' +0.0% after. Tuning on the past did not carry forward. 48% of the 48 combinations made money in-sample and 65% out-of-sample.

Before 26 Dec 2025 · in-sample
Length_MA8 ↓ · Length_MA4 →234567
4+0%+0%0%+0%+0%+0%
5+0%+0%+0%0%−0%−0%
6+0%+0%+0%+0%0%0%
7+0%+0%+0%+0%+0%0%
8+0%0%+0%+0%+0%−0%
10−0%−0%+0%−0%−0%−0%
11−0%−0%−0%−0%−0%−0%
14−0%−0%−0%−0%+0%−0%
From 26 Dec 2025 · out-of-sample
Length_MA8 ↓ · Length_MA4 →234567
4−0%−0%0%−0%−0%+0%
5−0%−0%−0%0%0%0%
6−0%+0%+0%+0%0%0%
7−0%+0%+0%+0%+0%0%
8+0%+0%+0%+0%+0%+0%
10+0%+0%+0%+0%+0%+0%
11+0%+0%+0%+0%+0%+0%
14+0%−0%+0%+0%+0%+0%

Net P&L of trades opened in each period, as a share of starting capital. marks the defaults and the best in-sample cell. Hover a cell for its trade count. Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market1040%−$0.96
Sideways market1050%$1.20
Falling market667%$2.88

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

How bad could the drawdown be?

0.0%

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

0%1%
All 26 trades
SideEntryExitBarsP&L
long26 Mar 2024 69,880.0026 Mar 2024 69,879.000−$0.96
long8 Apr 2024 69,360.408 Apr 2024 69,359.400−$0.96
short9 May 2024 61,193.009 May 2024 61,191.800$1.20
short11 May 2024 60,800.0011 May 2024 60,798.800$1.20
short15 May 2024 61,577.5015 May 2024 61,576.300$1.20
long4 Jun 2024 68,809.904 Jun 2024 68,808.900−$0.96
short12 Aug 2024 58,712.6012 Aug 2024 58,711.400$1.20
short15 Aug 2024 58,683.4015 Aug 2024 58,684.300−$0.96
long7 Nov 2024 75,572.007 Nov 2024 75,571.000−$0.96
long12 Dec 2024 101,125.0012 Dec 2024 101,126.000$1.20
long30 Jan 2025 103,733.0030 Jan 2025 103,732.000−$0.96
short22 Feb 2025 96,182.0022 Feb 2025 96,180.800$1.20
short8 Mar 2025 86,801.708 Mar 2025 86,802.700−$0.96
short30 Mar 2025 82,648.5030 Mar 2025 82,649.500−$0.96
long9 Jun 2025 105,734.009 Jun 2025 105,733.000−$0.96
short31 Oct 2025 108,323.0031 Oct 2025 108,322.000$1.20
short2 Dec 2025 86,286.002 Dec 2025 86,284.800$1.20
short7 Dec 2025 89,236.807 Dec 2025 89,235.600$1.20
short14 Dec 2025 90,240.0014 Dec 2025 90,241.000−$0.96
short24 Dec 2025 87,486.0024 Dec 2025 87,487.000−$0.96
short9 Mar 2026 65,971.209 Mar 2026 65,970.000$1.20
long2 May 2026 78,231.102 May 2026 78,230.200−$0.96
long15 May 2026 81,090.0015 May 2026 81,091.200$1.20
short19 Jun 2026 62,958.0019 Jun 2026 62,956.800$1.20
long27 Jul 2026 65,400.0027 Jul 2026 65,401.200$1.20
long19 Sep 2026 80,883.9019 Sep 2026 80,882.900−$0.96

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
Daytrade strategy RSI CCI EMA 4-8 this page—v4 strategy+0.0%260.0%
DCA After Downtrend v2 (by BHD_Trade_Bot) by BHD_Trade_Botema rmav5 strategyNo trades on this market
Williams Fractals Strategy by B_L_A_C_K_S_C_O_R_P_I_O_Nema rmav4 strategyNo trades on this market
Strategy Myth-Busting #10 - InsideBar+EMA - [MYN] by myncryptoema rmav5 strategyNo trades on this market
Optimized Keltner Channels SL-TP Strategy for BTC by chanu_lev10kema rmav4 strategy−19.4%3670.0%
Take Profit On Trend v2 (by BHD_Trade_Bot) by BHD_Trade_Botema rmav5 strategy+9.4%624.0%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 20 msWith a workaround 1,000 bars in 48 msNot measured
PineTSNo v5 and v6 only—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.

“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. PineTS runs Pine Script v5 and v6 only.

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/// © SoftKill21//@version=4strategy(title="Moving Average Exponential", shorttitle="EMA", overlay=true)len4 = input(4, minval=1, title="Length_MA4")src4 = input(close, title="Source")offset4 = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500)out4 = ema(src4, len4)plot(out4, title="EMA", color=color.blue, offset=offset4)len8 = input(8, minval=1, title="Length_MA8")src8 = input(close, title="Source")offset8 = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500)out8 = ema(src8, len8)plot(out8, title="EMA", color=color.blue, offset=offset8)//rsiomasrc = close, len = input(14, minval=1, title="Length")up = rma(max(change(ema(src, len)), 0), len)down = rma(-min(change(ema(src, len)), 0), len)rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))//plot(rsi, color=color.blue)//band1 = hline(80)//band0 = hline(20)//fill(band1, band0, color=color.purple, transp=90)//hline(50, color=color.gray, linestyle=plot.style_line)sig = ema(rsi, 21)//plot(sig, color=color.purple)//woodiecciTurboLength = input(title="CCI Turbo Length", type=input.integer, defval=6, minval=3, maxval=14)cci14Length = input(title="CCI 14 Length", type=input.integer, defval=14, minval=7, maxval=20)source = closecciTurbo = cci(source, cciTurboLength)cci14 = cci(source, cci14Length)last5IsDown = cci14[5] < 0 and cci14[4] < 0 and cci14[3] < 0 and cci14[2] < 0 and cci14[1] < 0last5IsUp = cci14[5] > 0 and cci14[4] > 0 and cci14[3] > 0 and cci14[2] > 0 and cci14[1] > 0histogramColor = last5IsUp ? color.green : last5IsDown ? color.red : cci14 < 0 ? color.green : color.red// Exit Condition// Exit Conditiona = input(12)*10b = input(15)*10c = a*syminfo.mintickd = b*syminfo.minticklongCondition = crossover(out4, out8) and (rsi >= 65 and cci14>=0)shortCondition = crossunder(out4, out8) and (rsi <=35 and cci14<=0)long_stop_level     = float(na)long_profit_level1  = float(na)long_profit_level2  = float(na)long_even_level     = float(na)short_stop_level    = float(na)short_profit_level1 = float(na)short_profit_level2 = float(na)short_even_level    = float(na)long_stop_level     := longCondition  ? close - c : long_stop_level     [1]long_profit_level1  := longCondition  ? close + d : long_profit_level1  [1]//long_profit_level2  := longCondition  ? close + d : long_profit_level2  [1]//long_even_level     := longCondition  ? close + 0 : long_even_level     [1]short_stop_level    := shortCondition ? close + c : short_stop_level    [1]short_profit_level1 := shortCondition ? close - d : short_profit_level1 [1]//short_profit_level2 := shortCondition ? close - d : short_profit_level2 [1]//short_even_level    := shortCondition ? close + 0 : short_even_level    [1] //ha// === Input ===//ma1_len = input(1, title="MA 01")//ma2_len = input(40, title="MA 02")// === MA 01 Filter ===//o=ema(open,ma1_len)//cc=ema(close,ma1_len)//h=ema(high,ma1_len)//l=ema(low,ma1_len)// === HA calculator ===//ha_t = heikinashi(syminfo.tickerid)//ha_o = security(ha_t, timeframe.period, o)//ha_c = security(ha_t, timeframe.period, cc)//ha_h = security(ha_t, timeframe.period, h)//ha_l = security(ha_t, timeframe.period, l)// === MA 02 Filter ===//o2=ema(ha_o, ma2_len)//c2=ema(ha_c, ma2_len)//h2=ema(ha_h, ma2_len)//l2=ema(ha_l, ma2_len)// === Color def ===//ha_col=o2>c2 ? color.red : color.lime// ===  PLOTITING===//plotcandle(o2, h2, l2, c2, title="HA Smoothed", color=ha_col)tp=input(120)sl=input(96)    strategy.entry("long", strategy.long, when = longCondition)//strategy.close("long", when = o2>c2 , comment="ha_long")strategy.entry("short", strategy.short , when =shortCondition )//strategy.close("short", when = o2<=c2 , comment = "ha_short" )//strategy.close("long",when=long_profit_level1 or long_stop_level  , comment="tp/sl")//strategy.close("short",when=short_profit_level1 or short_stop_level , comment="tp/sl")strategy.exit("x_long","long",profit = tp, loss = sl) //when = o2>c2)strategy.exit("x_short","short",profit = tp, loss = sl) //when = o2<c2)