Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Tale Indicators Strategy

A Pine Script v4 strategy built on EMA (close, 3), Crossover (fastMA, slowMALEn) and Crossunder (fastMA, slowMASEn). It has 6 order rules, 4 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays 0.1% commission. 19 settings; defaults include FAST EMA 3, Source for Fast close and SLOW EMA 15.

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 Tale Indicators Strategy repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did Tale Indicators Strategy 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 Tale Indicators Strategy 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 Tale Indicators Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Tale Indicators Strategy run in Zeal Terminal?
Yes
It compiles in 32 ms and runs 1,000 bars in 116 ms, in the browser.

BTCUSDT · 1D · default settings

  • Slow EMA
  • Fast EMA
  • Fast EMA Ex
  • Plot Enter Points
  • Plot Bull Exit
  • Plot Bear Exit
  • Plot Bull ReEnter
  • Plot Bear ReEnter
  • 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 (19)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$20,000$40,505Equity from $20,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
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, $20,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

    “Show Date Range” is declared but never read.

  • Check

    No stop loss

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

  • 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 81, 82, 83, 84, 85, 86. The upgraded version below moves each call inside an if block.

  • Note

    Uses iff(), which v5 removed line 30

    iff() on line 30, 30. v5 writes it as the ternary c ? a : b.

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, crossunder → ta.crossunder.
  • 6 strategy calls use the when = argument (line 81, 82, 83, 84, 85, 86). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

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 8: ema → ta.ema
  • Line 12: ema → ta.ema
  • Line 16: ema → ta.ema
  • Line 19: ema → ta.ema
  • Line 21: ema → ta.ema
15 more edits
  • Line 23: ema → ta.ema
  • Line 25: ema → ta.ema
  • Line 26: crossover → ta.crossover
  • Line 27: crossunder → ta.crossunder
  • Line 28: crossunder → ta.crossunder
  • Line 29: crossover → ta.crossover
  • Line 30: iff(c, a, b) → (c ? a : b)
  • Line 30: iff(c, a, b) → (c ? a : b)
  • Line 53: input(type = input.integer) → input.int()
  • Line 54: input(type = input.integer) → input.int()
  • Line 55: input(type = input.integer) → input.int()
  • Line 56: input(type = input.integer) → input.int()
  • Line 57: input(type = input.integer) → input.int()
  • Line 58: input(type = input.integer) → input.int()
  • Line 60: input(type = input.bool) → input.bool()
⋯// © ehaarjee, ECHKAY, JackBauer007-//@version=4+//@version=5//study(title="Tale_indicators", overlay=true)⋯src_fast = input(close, title="Source for Fast")-fastMA = ema(src_fast, len_fast)+fastMA = ta.ema(src_fast, len_fast)plot(fastMA, title="Slow EMA", color=color.orange)⋯src_slow = input(close, title="Source for Slow")-slowMA = ema(src_slow, len_slow)+slowMA = ta.ema(src_slow, len_slow)plot(slowMA, title="Fast EMA", color=color.blue)⋯src_fast_exit = input(close, title="Source for Fast Exit")-fastMAE = ema(src_fast_exit, len_fast_exit)+fastMAE = ta.ema(src_fast_exit, len_fast_exit)plot(fastMAE, title="Fast EMA Ex", color=color.red)src_slow_enter_short = input(low, title="Source for Short Entry")-slowMASEn = ema(src_slow_enter_short, len_slow)+slowMASEn = ta.ema(src_slow_enter_short, len_slow)src_slow_enter_long = input(high, title="Source for Long Entry")-slowMALEn = ema(src_slow_enter_long, len_slow)+slowMALEn = ta.ema(src_slow_enter_long, len_slow)src_slow_exit_short = input(high, title="Source for Short Exit")-slowMASEx = ema(src_slow_exit_short, len_slow)+slowMASEx = ta.ema(src_slow_exit_short, len_slow)src_slow_exit_long = input(low, title="Source for Long Exit")-slowMALEx = ema(src_slow_exit_long, len_slow)+slowMALEx = ta.ema(src_slow_exit_long, len_slow)-enter_long = crossover(fastMA, slowMALEn)+enter_long = ta.crossover(fastMA, slowMALEn)-enter_short = crossunder(fastMA, slowMASEn)+enter_short = ta.crossunder(fastMA, slowMASEn)-exit_long = crossunder(fastMAE, slowMALEx)+exit_long = ta.crossunder(fastMAE, slowMALEx)-exit_short = crossover(fastMAE, slowMASEx)+exit_short = ta.crossover(fastMAE, slowMASEx)-out_enter = iff(enter_long == true, 1, iff(enter_short == true, -1, 0))+out_enter = (enter_long == true ? 1 : (enter_short == true ? -1 : 0))plotarrow(out_enter, "Plot Enter Points", colorup=color.green, colordown=color.red, maxheight = 30)⋯// === INPUT BACKTEST RANGE ===-fromMonth = input(defval = 1,    title = "From Month",      type = input.integer, minval = 1, maxval = 12)+fromMonth = input.int(defval = 1,    title = "From Month", minval = 1, maxval = 12)-fromDay   = input(defval = 1,    title = "From Day",        type = input.integer, minval = 1, maxval = 31)+fromDay   = input.int(defval = 1,    title = "From Day", minval = 1, maxval = 31)-fromYear  = input(defval = 2020, title = "From Year",       type = input.integer, minval = 2000)+fromYear  = input.int(defval = 2020, title = "From Year", minval = 2000)-thruMonth = input(defval = 1,    title = "Thru Month",      type = input.integer, minval = 1, maxval = 12)+thruMonth = input.int(defval = 1,    title = "Thru Month", minval = 1, maxval = 12)-thruDay   = input(defval = 1,    title = "Thru Day",        type = input.integer, minval = 1, maxval = 31)+thruDay   = input.int(defval = 1,    title = "Thru Day", minval = 1, maxval = 31)-thruYear  = input(defval = 2100, title = "Thru Year",       type = input.integer, minval = 2000)+thruYear  = input.int(defval = 2100, title = "Thru Year", minval = 2000)// === INPUT SHOW PLOT ===-showDate  = input(defval = true, title = "Show Date Range", type = input.bool)+showDate  = input.bool(defval = true, title = "Show Date Range")// === FUNCTION EXAMPLE ===⋯

Clean v5

Not verified

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

  • Line 6: input() → input.int()
  • Line 7: input() → input.source()
  • Line 10: input() → input.int()
  • Line 11: input() → input.source()
  • Line 14: input() → input.int()
  • Line 15: input() → input.source()
12 more edits
  • Line 18: input() → input.source()
  • Line 20: input() → input.source()
  • Line 22: input() → input.source()
  • Line 24: input() → input.source()
  • Line 36: input() → input.float()
  • Line 51: input() → input.bool()
  • Line 81: when = (window() and enter_long and not(bull_exit)) → if block
  • Line 82: when = (window() and bull_reenter) → if block
  • Line 83: when = (window() and bull_exit) → if block
  • Line 84: when = (window() and enter_short and not(bear_exit)) → if block
  • Line 85: when = (window() and bear_reenter) → if block
  • Line 86: when = (window() and bear_exit) → if block
⋯strategy("Tale Indicators Strategy", overlay=true, precision=8, max_bars_back=200, pyramiding=0, initial_capital=20000, commission_type="percent", commission_value=0.1)-len_fast = input(3, minval=1, title="FAST EMA")+len_fast = input.int(3, minval=1, title="FAST EMA")-src_fast = input(close, title="Source for Fast")+src_fast = input.source(close, title="Source for Fast")fastMA = ta.ema(src_fast, len_fast)plot(fastMA, title="Slow EMA", color=color.orange)-len_slow = input(15, minval=1, title="SLOW EMA")+len_slow = input.int(15, minval=1, title="SLOW EMA")-src_slow = input(close, title="Source for Slow")+src_slow = input.source(close, title="Source for Slow")slowMA = ta.ema(src_slow, len_slow)plot(slowMA, title="Fast EMA", color=color.blue)-len_fast_exit = input(3, minval=1, title="FAST EMA Exit")+len_fast_exit = input.int(3, minval=1, title="FAST EMA Exit")-src_fast_exit = input(close, title="Source for Fast Exit")+src_fast_exit = input.source(close, title="Source for Fast Exit")fastMAE = ta.ema(src_fast_exit, len_fast_exit)plot(fastMAE, title="Fast EMA Ex", color=color.red)-src_slow_enter_short = input(low, title="Source for Short Entry")+src_slow_enter_short = input.source(low, title="Source for Short Entry")slowMASEn = ta.ema(src_slow_enter_short, len_slow)-src_slow_enter_long = input(high, title="Source for Long Entry")+src_slow_enter_long = input.source(high, title="Source for Long Entry")slowMALEn = ta.ema(src_slow_enter_long, len_slow)-src_slow_exit_short = input(high, title="Source for Short Exit")+src_slow_exit_short = input.source(high, title="Source for Short Exit")slowMASEx = ta.ema(src_slow_exit_short, len_slow)-src_slow_exit_long = input(low, title="Source for Long Exit")+src_slow_exit_long = input.source(low, title="Source for Long Exit")slowMALEx = ta.ema(src_slow_exit_long, len_slow)⋯bgcolor(c)-exit_tuner = input(0.005, title="Exit Tuner to touch slowEMA")+exit_tuner = input.float(0.005, title="Exit Tuner to touch slowEMA")bull_exit = (low>(fastMAE*(1+exit_tuner))) or exit_long ⋯plotshape(bear_reenter, "Plot Bear ReEnter", style = shape.arrowdown, color=color.red, size=size.small, text="ReS", location=location.abovebar)-run_strategy = input(false, title="Run Strategy")+run_strategy = input.bool(false, title="Run Strategy")// === INPUT BACKTEST RANGE ===⋯if(run_strategy)-    strategy.entry("LO", strategy.long, when=(window() and enter_long and not(bull_exit)), qty=4)+    if (window() and enter_long and not(bull_exit))+        strategy.entry("LO", strategy.long, qty=4)-    strategy.entry("LO", strategy.long, when=(window() and bull_reenter), qty=1)+    if (window() and bull_reenter)+        strategy.entry("LO", strategy.long, qty=1)-    strategy.close("LO", when=(window() and bull_exit))+    if (window() and bull_exit)+        strategy.close("LO")-    strategy.entry("SO", strategy.short, when=(window() and enter_short and not(bear_exit)), qty=4)+    if (window() and enter_short and not(bear_exit))+        strategy.entry("SO", strategy.short, qty=4)-    strategy.entry("SO", strategy.short, when=(window() and bear_reenter), qty=1)+    if (window() and bear_reenter)+        strategy.entry("SO", strategy.short, qty=1)-    strategy.close("SO", when=(window() and bear_exit))+    if (window() and bear_exit)+        strategy.close("SO")

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.

⋯// © ehaarjee, ECHKAY, JackBauer007-//@version=5+//@version=6//study(title="Tale_indicators", 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
FAST EMA3int · min 1fastMA
Source for FastclosesourcefastMA
SLOW EMA15int · min 1slowMA slowMASEn slowMALEn slowMASEx slowMALEx
Source for SlowclosesourceslowMA
FAST EMA Exit3int · min 1fastMAE
Source for Fast ExitclosesourcefastMAE
Source for Short EntrylowsourceslowMASEn
Source for Long EntryhighsourceslowMALEn
Source for Short ExithighsourceslowMASEx
Source for Long ExitlowsourceslowMALEx
Exit Tuner to touch slowEMA0.005floatbull_exit bear_exit
Run Strategyfalseboolentry LO entry LO close LO entry SO entry SO close SO line 80
From Month1int (written input.integer) · min 1 · max 12start
From Day1int (written input.integer) · min 1 · max 31start
From Year2020int (written input.integer) · min 2000start
Thru Month1int (written input.integer) · min 1 · max 12finish
Thru Day1int (written input.integer) · min 1 · max 31finish
Thru Year2100int (written input.integer) · min 2000finish
Show Date Rangetrueboolunused

What it calculates

  • EMA (ema, ta.ema in v5)Source for Fast (close), FAST EMA (3)fastMA · line 8
  • EMA (ema, ta.ema in v5)Source for Slow (close), SLOW EMA (15)slowMA · line 12
  • EMA (ema, ta.ema in v5)Source for Fast Exit (close), FAST EMA Exit (3)fastMAE · line 16
  • EMA (ema, ta.ema in v5)Source for Short Entry (low), SLOW EMA (15)slowMASEn · line 19
  • EMA (ema, ta.ema in v5)Source for Long Entry (high), SLOW EMA (15)slowMALEn · line 21
  • EMA (ema, ta.ema in v5)Source for Short Exit (high), SLOW EMA (15)slowMASEx · line 23
  • EMA (ema, ta.ema in v5)Source for Long Exit (low), SLOW EMA (15)slowMALEx · line 25
  • Crossover (crossover, ta.crossover in v5)fastMA, slowMALEnenter_long · line 26
  • Crossunder (crossunder, ta.crossunder in v5)fastMA, slowMASEnenter_short · line 27
  • Crossunder (crossunder, ta.crossunder in v5)fastMAE, slowMALExexit_long · line 28
  • Crossover (crossover, ta.crossover in v5)fastMAE, slowMASExexit_short · line 29

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 datalen_fastFAST EMAsetting · 3len_slowSLOW EMAsetting · 15len_fast_exitFAST EMA Exitsetting · 3lowlowprice datahighhighprice datafromYearFrom Yearsetting · 2020fromMonthFrom Monthsetting · 1fromDayFrom Daysetting · 1thruYearThru Yearsetting · 2100thruMonthThru Monthsetting · 1thruDayThru Daysetting · 1exit_tunerExit Tuner to touch slo…setting · 0.005fastMAEMA→ fastMAslowMAEMA→ slowMAfastMAEEMA→ fastMAEslowMASEnEMA→ slowMASEnslowMALEnEMA→ slowMALEnslowMASExEMA→ slowMASExslowMALExEMA→ slowMALExenter_longCrossover→ enter_longenter_shortCrossunder→ enter_shortexit_longCrossunder→ exit_longexit_shortCrossover→ exit_shortstartstartvaluefinishfinishvalueout_enterout_enterconditionbullbullconditionbearbearconditionbull_exitbull_exitconditionbear_exitbear_exitconditionbull_rbull_rconditionbear_rbear_rconditionbull_rebull_reconditionbear_rebear_reconditionbull_reebull_reeconditionbear_reebear_reeconditionbull_reenterbull_reenterconditionbear_reenterbear_reenterconditioncColourcentry:LOOpen LOstrategy.entryclose:LOClose LOstrategy.closeentry:SOOpen SOstrategy.entryclose:SOClose SOstrategy.closeplot:9Slow EMAplotplot:13Fast EMAplotplot:17Fast EMA Explotplotarrow:31plotarrowplotarrowbgcolor:35bgcolorbgcolorplotshape:47plotshapeplotshapeplotshape:48plotshapeplotshapeplotshape:49plotshapeplotshapeplotshape:50plotshapeplotshape

Order rules

OrderFires whenBy defaultLine
Open LO long(window() and enter_long and not(bull_exit))On81
Open LO long(window() and bull_reenter)On82
Close LO(window() and bull_exit)On83
Open SO short(window() and enter_short and not(bear_exit))On84
Open SO short(window() and bear_reenter)On85
Close SO(window() and bear_exit)On86

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
Tale Indicators Strategy 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 32 msYes 1,000 bars in 116 msNot measured
PineTSNo v5 and v6 only—Not 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. 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/// © ehaarjee, ECHKAY, JackBauer007//@version=4//study(title="Tale_indicators", overlay=true)strategy("Tale Indicators Strategy", overlay=true, precision=8, max_bars_back=200, pyramiding=0, initial_capital=20000, commission_type="percent", commission_value=0.1)len_fast = input(3, minval=1, title="FAST EMA")src_fast = input(close, title="Source for Fast")fastMA = ema(src_fast, len_fast)plot(fastMA, title="Slow EMA", color=color.orange)len_slow = input(15, minval=1, title="SLOW EMA")src_slow = input(close, title="Source for Slow")slowMA = ema(src_slow, len_slow)plot(slowMA, title="Fast EMA", color=color.blue)len_fast_exit = input(3, minval=1, title="FAST EMA Exit")src_fast_exit = input(close, title="Source for Fast Exit")fastMAE = ema(src_fast_exit, len_fast_exit)plot(fastMAE, title="Fast EMA Ex", color=color.red)src_slow_enter_short = input(low, title="Source for Short Entry")slowMASEn = ema(src_slow_enter_short, len_slow)src_slow_enter_long = input(high, title="Source for Long Entry")slowMALEn = ema(src_slow_enter_long, len_slow)src_slow_exit_short = input(high, title="Source for Short Exit")slowMASEx = ema(src_slow_exit_short, len_slow)src_slow_exit_long = input(low, title="Source for Long Exit")slowMALEx = ema(src_slow_exit_long, len_slow)enter_long = crossover(fastMA, slowMALEn)enter_short = crossunder(fastMA, slowMASEn)exit_long = crossunder(fastMAE, slowMALEx)exit_short = crossover(fastMAE, slowMASEx)out_enter = iff(enter_long == true, 1, iff(enter_short == true, -1, 0))plotarrow(out_enter, "Plot Enter Points", colorup=color.green, colordown=color.red, maxheight = 30)bull = fastMA > slowMALEnbear = fastMA < slowMASEnc = bull ? color.green : bear ? color.red  : color.whitebgcolor(c)exit_tuner = input(0.005, title="Exit Tuner to touch slowEMA")bull_exit = (low>(fastMAE*(1+exit_tuner))) or exit_long bear_exit = ((fastMAE*(1-exit_tuner))>high) or exit_short bull_r = (bull and ((bull_exit[1]) or (bull_exit[2] and bull_exit[1])) and (low<=fastMAE))bear_r = (bear and ((bear_exit[1]) or (bull_exit[2] and bull_exit[1])) and (fastMAE<=high))bull_re = (bull and (low<slowMALEn)) and not(enter_long)bear_re = (bear and (high>slowMASEn)) and not(enter_short)bull_ree = (bull and ((low<slowMALEn) and not(bull_re[1] or enter_long[1]))) bear_ree = (bear and ((high>slowMASEn) and not(bear_re[1] or enter_short[1])))bull_reenter =  (bull_r or bull_ree) and not(enter_long)bear_reenter =  (bear_r or bear_ree) and not(enter_short)plotshape(bull_exit, "Plot Bull Exit", style = shape.arrowdown, color=color.green, size=size.small, text="ExL", location=location.abovebar)plotshape(bear_exit, "Plot Bear Exit", style = shape.arrowup, color=color.red, size=size.small, text="ExS", location=location.belowbar)plotshape(bull_reenter, "Plot Bull ReEnter", style = shape.arrowup, color=color.green, size=size.small, text="ReL", location=location.belowbar)plotshape(bear_reenter, "Plot Bear ReEnter", style = shape.arrowdown, color=color.red, size=size.small, text="ReS", location=location.abovebar)run_strategy = input(false, title="Run Strategy")// === INPUT BACKTEST RANGE ===fromMonth = input(defval = 1,    title = "From Month",      type = input.integer, minval = 1, maxval = 12)fromDay   = input(defval = 1,    title = "From Day",        type = input.integer, minval = 1, maxval = 31)fromYear  = input(defval = 2020, title = "From Year",       type = input.integer, minval = 2000)thruMonth = input(defval = 1,    title = "Thru Month",      type = input.integer, minval = 1, maxval = 12)thruDay   = input(defval = 1,    title = "Thru Day",        type = input.integer, minval = 1, maxval = 31)thruYear  = input(defval = 2100, title = "Thru Year",       type = input.integer, minval = 2000)// === INPUT SHOW PLOT ===showDate  = input(defval = true, title = "Show Date Range", type = input.bool)// === FUNCTION EXAMPLE ===start     = timestamp(fromYear, fromMonth, fromDay, 00, 00)        // backtest start windowfinish    = timestamp(thruYear, thruMonth, thruDay, 23, 59)        // backtest finish windowwindow()  => time >= start and time <= finish ? true : false       // create function "within window of time"var long_position_open = falsevar short_position_open = falseif (enter_long and not(bull_exit) and not(long_position_open))    long_position_open := trueif (bull_reenter and not(long_position_open))      long_position_open := trueif (bull_exit and long_position_open)    long_position_open := false    if (enter_short and not(bear_exit) and not(short_position_open))    short_position_open := trueif (bear_reenter and not(short_position_open))      short_position_open := trueif (bear_exit and short_position_open)    short_position_open := falseif(run_strategy)    strategy.entry("LO", strategy.long, when=(window() and enter_long and not(bull_exit)), qty=4)    strategy.entry("LO", strategy.long, when=(window() and bull_reenter), qty=1)    strategy.close("LO", when=(window() and bull_exit))    strategy.entry("SO", strategy.short, when=(window() and enter_short and not(bear_exit)), qty=4)    strategy.entry("SO", strategy.short, when=(window() and bear_reenter), qty=1)    strategy.close("SO", when=(window() and bear_exit))