Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

EMA crossover - BTC-USD 4hr

A Pine Script v4 strategy built on EMA (close, 11) and Crossover (ema_long_open_fast, ema_long_open_slow). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss. Each trade commits 75% of equity and pays 0.075% commission. 18 settings; defaults include Start Date 1, Start Month 1 and Start Year 2020.

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 EMA crossover - BTC-USD 4hr repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did EMA crossover - BTC-USD 4hr 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.
Can EMA crossover - BTC-USD 4hr be converted to Pine Script v5?
Not tested
The steps are shown below, but neither version placed a trade on any market tested, so there was nothing to compare and no download is offered.
Does EMA crossover - BTC-USD 4hr use a stop loss?
Yes
strategy.exit sets a stop on line 82, 89.
Does EMA crossover - BTC-USD 4hr run in Zeal Terminal?
Yes
It compiles in 22 ms and runs 1,000 bars in 73 ms, in the browser.

BTCUSDT · 1D · default settings

  • Long EMA open lower
  • Long EMA close upper
  • Long close lower
  • Long close upper
  • Short open fast
  • Short open slow
  • Short close fast
  • Short close slow
  • Long-term trend - Longs
  • Long-term trend - Shorts
  • 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 (18)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,000$2,025Equity from $1,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots. Zeal Terminal's engine currently reads an order side written as long = true, long = false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 78, 85) so the engine trades the way the script says.
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.

  • Note

    No slippage

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

  • Note

    Uses long =, which v5 renamed line 78

    long = on line 78, 85. v5 writes it as direction = strategy.long or strategy.short.

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, crossover → ta.crossover.

v4 → v5

Not verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 6: input(type = input.integer) → input.int()
  • Line 8: input(type = input.integer) → input.int()
  • Line 10: input(type = input.integer) → input.int()
  • Line 12: input(type = input.integer) → input.int()
  • Line 14: input(type = input.integer) → input.int()
19 more edits
  • Line 16: input(type = input.integer) → input.int()
  • Line 28: ema → ta.ema
  • Line 29: ema → ta.ema
  • Line 30: ema → ta.ema
  • Line 31: ema → ta.ema
  • Line 38: ema → ta.ema
  • Line 39: ema → ta.ema
  • Line 40: ema → ta.ema
  • Line 41: ema → ta.ema
  • Line 44: crossover → ta.crossover
  • Line 45: crossover → ta.crossover
  • Line 47: input(type = input.float) → input.float()
  • Line 50: crossover → ta.crossover
  • Line 51: crossover → ta.crossover
  • Line 53: input(type = input.float) → input.float()
  • Line 69: ema → ta.ema
  • Line 73: ema → ta.ema
  • Line 78: long = true → direction = strategy.long
  • Line 85: long = false → direction = strategy.short
⋯// © str1nger-//@version=4+//@version=5strategy(title="BTC - 4hr - Long/Short", shorttitle="BTC - 4hr - Long/Short", overlay=true, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=75,commission_type=strategy.commission.percent, commission_value=0.075)//////<---Uses a percentage of starting equity//DATE RANGE//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////-startDate = input(title="Start Date", type=input.integer,+startDate = input.int(title="Start Date",     defval=1, minval=1, maxval=31)-startMonth = input(title="Start Month", type=input.integer,+startMonth = input.int(title="Start Month",     defval=1, minval=1, maxval=12)-startYear = input(title="Start Year", type=input.integer,+startYear = input.int(title="Start Year",     defval=2020, minval=2000, maxval=2100)-endDate = input(title="End Date", type=input.integer,+endDate = input.int(title="End Date",     defval=1, minval=1, maxval=31)-endMonth = input(title="End Month", type=input.integer,+endMonth = input.int(title="End Month",     defval=12, minval=1, maxval=12)-endYear = input(title="End Year", type=input.integer,+endYear = input.int(title="End Year",     defval=2021, minval=2000, maxval=2100)⋯lcs= input(40, title="Long Close - Slow", step=1)-ema_long_open_fast = ema(close, lof)+ema_long_open_fast = ta.ema(close, lof)-ema_long_open_slow = ema(close, los)+ema_long_open_slow = ta.ema(close, los)-ema_long_close_fast= ema(close, lcf)+ema_long_close_fast= ta.ema(close, lcf)-ema_long_close_slow = ema(close, lcs)+ema_long_close_slow = ta.ema(close, lcs)//SHORT⋯scs= input(7, title="Short Close - Slow", step=1)-ema_short_open_fast = ema(close, sof)+ema_short_open_fast = ta.ema(close, sof)-ema_short_open_slow = ema(close, sos)+ema_short_open_slow = ta.ema(close, sos)-ema_short_close_fast = ema(close, scf)+ema_short_close_fast = ta.ema(close, scf)-ema_short_close_slow = ema(close, scs)+ema_short_close_slow = ta.ema(close, scs)//CONDITIONS/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////LONG-openlong = crossover(ema_long_open_fast, ema_long_open_slow)+openlong = ta.crossover(ema_long_open_fast, ema_long_open_slow)-closelong = crossover(ema_long_close_slow, ema_long_close_fast)+closelong = ta.crossover(ema_long_close_slow, ema_long_close_fast)//1.7%-long_loss_percent = input(title="Long Stop Loss (%)", type=input.float, minval=0.0, step=0.1, defval=1.7) * 0.01+long_loss_percent = input.float(title="Long Stop Loss (%)", minval=0.0, step=0.1, defval=1.7) * 0.01long_stop_price = strategy.position_avg_price * (1 - long_loss_percent)//SHORT-openshort = crossover(ema_short_open_slow, ema_short_open_fast)+openshort = ta.crossover(ema_short_open_slow, ema_short_open_fast)-closeshort = crossover(ema_short_close_fast, ema_short_close_slow)+closeshort = ta.crossover(ema_short_close_fast, ema_short_close_slow)//0.4%-short_loss_percent = input(title="Short Stop Loss (%)", type=input.float, minval=0.0, step=0.1, defval=0.4) * 0.01+short_loss_percent = input.float(title="Short Stop Loss (%)", minval=0.0, step=0.1, defval=0.4) * 0.01short_stop_price = strategy.position_avg_price * (1 + short_loss_percent)⋯long_term_trend_longs= input(144, title="Long-term trend - Longs", step=1)-lttl= ema(close, long_term_trend_longs)+lttl= ta.ema(close, long_term_trend_longs)plot(lttl, "Long-term trend - Longs", linewidth=2, color=color.blue)⋯long_term_trend_shorts= input(89, title="Long-term trend - Shorts", step=1)-ltts = ema(close, long_term_trend_shorts)+ltts = ta.ema(close, long_term_trend_shorts)plot(ltts, "Long-term trend - Shorts", linewidth=2, color=color.blue)⋯if (inDateRange and openlong and (close > lttl))-    strategy.entry("OL", long=true, comment="##insert open long comment here##")+    strategy.entry("OL", direction = strategy.long, comment="##insert open long comment here##")if (inDateRange and closelong)⋯if (inDateRange and openshort and (close < ltts))-    strategy.entry("OS", long=false, comment="##insert open short comment here##")+    strategy.entry("OS", direction = strategy.short, comment="##insert open short comment here##")if (inDateRange and closeshort)⋯

Clean v5

Not verified

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

  • Line 24: input() → input.int()
  • Line 25: input() → input.int()
  • Line 26: input() → input.int()
  • Line 27: input() → input.int()
  • Line 34: input() → input.int()
  • Line 35: input() → input.int()
4 more edits
  • Line 36: input() → input.int()
  • Line 37: input() → input.int()
  • Line 68: input() → input.int()
  • Line 72: input() → input.int()
⋯//11,33,3,40-lof= input(11, title="Long Open - Fast", step=1)+lof= input.int(11, title="Long Open - Fast", step=1)-los= input(33, title="Long Open - Slow", step=1)+los= input.int(33, title="Long Open - Slow", step=1)-lcf= input(3, title="Long Close - Fast", step=1)+lcf= input.int(3, title="Long Close - Fast", step=1)-lcs= input(40, title="Long Close - Slow", step=1)+lcs= input.int(40, title="Long Close - Slow", step=1)ema_long_open_fast = ta.ema(close, lof)⋯//5,11,4,7-sof= input(5, title="Short Open - Fast", step=1)+sof= input.int(5, title="Short Open - Fast", step=1)-sos= input(11, title="Short Open - Slow", step=1)+sos= input.int(11, title="Short Open - Slow", step=1)-scf= input(4, title="Short Close - Fast", step=1)+scf= input.int(4, title="Short Close - Fast", step=1)-scs= input(7, title="Short Close - Slow", step=1)+scs= input.int(7, title="Short Close - Slow", step=1)ema_short_open_fast = ta.ema(close, sof)⋯//LONG 144-long_term_trend_longs= input(144, title="Long-term trend - Longs", step=1)+long_term_trend_longs= input.int(144, title="Long-term trend - Longs", step=1)lttl= ta.ema(close, long_term_trend_longs)⋯//SHORT 89-long_term_trend_shorts= input(89, title="Long-term trend - Shorts", step=1)+long_term_trend_shorts= input.int(89, title="Long-term trend - Shorts", step=1)ltts = ta.ema(close, long_term_trend_shorts)⋯

Does it run in Pine Script v6?

Not tested

Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © str1nger-//@version=5+//@version=6strategy(title="BTC - 4hr - Long/Short", shorttitle="BTC - 4hr - Long/Short", overlay=true, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=75,commission_type=strategy.commission.percent, commission_value=0.075)//////<---Uses a percentage of starting equity⋯

Settings

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

SettingDefaultType and rangeFeeds
Start Date1int (written input.integer) · min 1 · max 31inDateRange
Start Month1int (written input.integer) · min 1 · max 12inDateRange
Start Year2020int (written input.integer) · min 2000 · max 2100inDateRange
End Date1int (written input.integer) · min 1 · max 31inDateRange
End Month12int (written input.integer) · min 1 · max 12inDateRange
End Year2021int (written input.integer) · min 2000 · max 2100inDateRange
Long Open - Fast11int · step 1ema_long_open_fast
Long Open - Slow33int · step 1ema_long_open_slow
Long Close - Fast3int · step 1ema_long_close_fast
Long Close - Slow40int · step 1ema_long_close_slow
Short Open - Fast5int · step 1ema_short_open_fast
Short Open - Slow11int · step 1ema_short_open_slow
Short Close - Fast4int · step 1ema_short_close_fast
Short Close - Slow7int · step 1ema_short_close_slow
Long Stop Loss (%)1.7float · min 0.0 · step 0.1long_stop_price
Short Stop Loss (%)0.4float · min 0.0 · step 0.1short_stop_price
Long-term trend - Longs144int · step 1lttl
Long-term trend - Shorts89int · step 1ltts

What it calculates

  • EMA (ema, ta.ema in v5)close, Long Open - Fast (11)ema_long_open_fast · line 28
  • EMA (ema, ta.ema in v5)close, Long Open - Slow (33)ema_long_open_slow · line 29
  • EMA (ema, ta.ema in v5)close, Long Close - Fast (3)ema_long_close_fast · line 30
  • EMA (ema, ta.ema in v5)close, Long Close - Slow (40)ema_long_close_slow · line 31
  • EMA (ema, ta.ema in v5)close, Short Open - Fast (5)ema_short_open_fast · line 38
  • EMA (ema, ta.ema in v5)close, Short Open - Slow (11)ema_short_open_slow · line 39
  • EMA (ema, ta.ema in v5)close, Short Close - Fast (4)ema_short_close_fast · line 40
  • EMA (ema, ta.ema in v5)close, Short Close - Slow (7)ema_short_close_slow · line 41
  • Crossover (crossover, ta.crossover in v5)ema_long_open_fast, ema_long_open_slowopenlong · line 44
  • Crossover (crossover, ta.crossover in v5)ema_long_close_slow, ema_long_close_fastcloselong · line 45
  • Crossover (crossover, ta.crossover in v5)ema_short_open_slow, ema_short_open_fastopenshort · line 50
  • Crossover (crossover, ta.crossover in v5)ema_short_close_fast, ema_short_close_slowcloseshort · line 51
  • EMA (ema, ta.ema in v5)close, Long-term trend - Longs (144)lttl · line 69
  • EMA (ema, ta.ema in v5)close, Long-term trend - Shorts (89)ltts · line 73

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 datalofLong Open - Fastsetting · 11losLong Open - Slowsetting · 33lcfLong Close - Fastsetting · 3lcsLong Close - Slowsetting · 40sofShort Open - Fastsetting · 5sosShort Open - Slowsetting · 11scfShort Close - Fastsetting · 4scsShort Close - Slowsetting · 7long_term_trend_longsLong-term trend - Longssetting · 144long_term_trend_shortsLong-term trend - Shortssetting · 89long_loss_percentLong Stop Loss (%)setting · 1.7short_loss_percentShort Stop Loss (%)setting · 0.4timetimeprice datastartYearStart Yearsetting · 2020startMonthStart Monthsetting · 1startDateStart Datesetting · 1endYearEnd Yearsetting · 2021endMonthEnd Monthsetting · 12endDateEnd Datesetting · 1ema_long_open_fastEMA→ ema_long_open_fastema_long_open_slowEMA→ ema_long_open_slowema_long_close_fastEMA→ ema_long_close_fastema_long_close_slowEMA→ ema_long_close_slowema_short_open_fastEMA→ ema_short_open_fastema_short_open_slowEMA→ ema_short_open_slowema_short_close_fastEMA→ ema_short_close_fastema_short_close_slowEMA→ ema_short_close_slowopenlongCrossover→ openlongcloselongCrossover→ closelongopenshortCrossover→ openshortcloseshortCrossover→ closeshortlttlEMA→ lttllttsEMA→ lttslong_stop_pricelong_stop_pricevalueshort_stop_priceshort_stop_pricevalueinDateRangeinDateRangeconditionentry:OLOpen OLstrategy.entryclose:OLClose OLstrategy.closeexit:L-SLexit L-SLstrategy.exitentry:OSOpen OSstrategy.entryclose:OSClose OSstrategy.closeexit:S-SLexit S-SLstrategy.exitplot:57Long EMA open lowerplotplot:58Long EMA close upperplotplot:59Long close lowerplotplot:60Long close upperplotplot:62Short open fastplotplot:63Short open slowplotplot:64Short close fastplotplot:65Short close slowplotplot:70Long-term trend - Longsplotplot:74Long-term trend - Shortsplot

Order rules

OrderFires whenBy defaultLine
Open OL long(inDateRange and openlong and (close > lttl))On78
Close OL(inDateRange and closelong)On80
Exit L-SL stopstrategy.position_size > 0On82
Open OS short(inDateRange and openshort and (close < ltts))On85
Close OS(inDateRange and closeshort)On87
Exit S-SL stopstrategy.position_size < 0On89

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.

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

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

Similar scripts

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

ScriptSharesTypeNetTradesMax drawdown
EMA crossover - BTC-USD 4hr this page—v4 strategy0.0%00.0%
EMA Slope AyE by fajardoarelysemav4 strategyNo trades on this market
ROoT by realisticDove62527emav5 strategy−4.7%2259.4%
sachin5986 by mohitesachin78emav4 strategy+32.1%3517.6%
sonu1997 by Sonu1997emav4 strategy+960.7%21,103.8%
Moving Average Crossover by Muh4mm4demav4 strategy+19,990.1%301,274.2%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 22 msWith a workaround 1,000 bars in 73 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as long = true, long = false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 78, 85) so the engine trades the way the script says.

“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/// © str1nger//@version=4strategy(title="BTC - 4hr - Long/Short", shorttitle="BTC - 4hr - Long/Short", overlay=true, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=75,commission_type=strategy.commission.percent, commission_value=0.075)//////<---Uses a percentage of starting equity//DATE RANGE//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////startDate = input(title="Start Date", type=input.integer,     defval=1, minval=1, maxval=31)startMonth = input(title="Start Month", type=input.integer,     defval=1, minval=1, maxval=12)startYear = input(title="Start Year", type=input.integer,     defval=2020, minval=2000, maxval=2100)endDate = input(title="End Date", type=input.integer,     defval=1, minval=1, maxval=31)endMonth = input(title="End Month", type=input.integer,     defval=12, minval=1, maxval=12)endYear = input(title="End Year", type=input.integer,     defval=2021, minval=2000, maxval=2100)inDateRange = (time >= timestamp("Europe/London", startYear,         startMonth, startDate, 0, 0)) and     (time < timestamp("Europe/London", endYear, endMonth, endDate, 0, 0))//EMAs////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////LONG//11,33,3,40lof= input(11, title="Long Open - Fast", step=1)los= input(33, title="Long Open - Slow", step=1)lcf= input(3, title="Long Close - Fast", step=1)lcs= input(40, title="Long Close - Slow", step=1)ema_long_open_fast = ema(close, lof)ema_long_open_slow = ema(close, los)ema_long_close_fast= ema(close, lcf)ema_long_close_slow = ema(close, lcs)//SHORT//5,11,4,7sof= input(5, title="Short Open - Fast", step=1)sos= input(11, title="Short Open - Slow", step=1)scf= input(4, title="Short Close - Fast", step=1)scs= input(7, title="Short Close - Slow", step=1)ema_short_open_fast = ema(close, sof)ema_short_open_slow = ema(close, sos)ema_short_close_fast = ema(close, scf)ema_short_close_slow = ema(close, scs)//CONDITIONS/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////LONGopenlong = crossover(ema_long_open_fast, ema_long_open_slow)closelong = crossover(ema_long_close_slow, ema_long_close_fast)//1.7%long_loss_percent = input(title="Long Stop Loss (%)", type=input.float, minval=0.0, step=0.1, defval=1.7) * 0.01long_stop_price = strategy.position_avg_price * (1 - long_loss_percent)//SHORTopenshort = crossover(ema_short_open_slow, ema_short_open_fast)closeshort = crossover(ema_short_close_fast, ema_short_close_slow)//0.4%short_loss_percent = input(title="Short Stop Loss (%)", type=input.float, minval=0.0, step=0.1, defval=0.4) * 0.01short_stop_price = strategy.position_avg_price * (1 + short_loss_percent)//PLOT EMAs//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////LONGplot(ema_long_open_fast, "Long EMA open lower", linewidth=1, color=color.green)plot(ema_long_open_slow, "Long EMA close upper", linewidth=1, color=color.green)plot(ema_long_close_fast, "Long close lower", linewidth=1, color=color.red)plot(ema_long_close_slow, "Long close upper", linewidth=1, color=color.red)//SHORTplot(ema_short_open_fast, "Short open fast", linewidth=1, color=color.green)plot(ema_short_open_slow, "Short open slow", linewidth=1, color=color.green)plot(ema_short_close_fast, "Short close fast", linewidth=1, color=color.red)plot(ema_short_close_slow, "Short close slow", linewidth=1, color=color.red)//LONG-TERM TRENDS//LONG 144long_term_trend_longs= input(144, title="Long-term trend - Longs", step=1)lttl= ema(close, long_term_trend_longs)plot(lttl, "Long-term trend - Longs", linewidth=2, color=color.blue)//SHORT 89long_term_trend_shorts= input(89, title="Long-term trend - Shorts", step=1)ltts = ema(close, long_term_trend_shorts)plot(ltts, "Long-term trend - Shorts", linewidth=2, color=color.blue)//STRATEGY////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////LONGif (inDateRange and openlong and (close > lttl))    strategy.entry("OL", long=true, comment="##insert open long comment here##")if (inDateRange and closelong)    strategy.close("OL", comment="##insert close long comment here##")if strategy.position_size > 0    strategy.exit("L-SL", stop=long_stop_price, comment="##insert long stop-loss comment here##")//SHORT  if (inDateRange and openshort and (close < ltts))    strategy.entry("OS", long=false, comment="##insert open short comment here##")if (inDateRange and closeshort)    strategy.close("OS", comment="##insert close short comment here##")if strategy.position_size < 0    strategy.exit("S-SL", stop=short_stop_price, comment="##inster short stop-loss comment here##")