Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Strategy - Trend Chaser - PSe

A Pine Script v5 strategy built on TR (true), ATR (atrLength) and MACD (close, 12). 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 is one contract and pays no commission. 14 settings; defaults include Start Day 1, Start Month 1 and Start Year 2008.

Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.

Does Strategy - Trend Chaser - PSe repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did Strategy - Trend Chaser - PSe 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.
Does Strategy - Trend Chaser - PSe 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.
Does Strategy - Trend Chaser - PSe use a stop loss?
Yes
strategy.exit sets a stop on line 198, 199.
Does Strategy - Trend Chaser - PSe run in Zeal Terminal?
Yes
It compiles in 43 ms and runs 1,000 bars in 97 ms, in the browser.

BTCUSDT · 1D · default settings

  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$25,000$50,632Equity from $25,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference. Zeal Terminal's engine currently reads an order side written as direction = strategy.long, direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 161, 163) so the engine trades the way the script says. The live re-run is not offered here: the script requests USDUSD D, GBPUSD D, AUDUSD D, NZDUSD D, CADUSD D, CHFUSD D, EURUSD D, JPYUSD D, PHPUSD D, which this page cannot load in your browser.

Needs USDUSD D data, not available: USDUSD is not on Binance Needs GBPUSD D data, not available: GBPUSD is not on Binance Needs AUDUSD D data, not available: AUDUSD is not on Binance Needs NZDUSD D data, not available: NZDUSD is not on Binance Needs CADUSD D data, not available: CADUSD is not on Binance Needs CHFUSD D data, not available: CHFUSD is not on Binance Needs EURUSD D data, not available: EURUSD is not on Binance Needs JPYUSD D data, not available: JPYUSD is not on Binance Needs PHPUSD D data, not available: PHPUSD is not on Binance Values that depend on it are empty on this chart.

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, $25,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

    No commission

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

  • 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 201, 202. The upgraded version below moves each call inside an if block.

Settings

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

SettingDefaultType and rangeFeeds
Start Day1int · min 1 · max 31startDate
Start Month1int · min 1 · max 12startDate
Start Year2008int · min 1970startDate
End Day1int · min 1 · max 31endDate
End Month12int · min 1 · max 12endDate
End Year2022int · min 1970endDate
Risk Per Trade0.02float · min 0.001 · max 1riskMoney
Atr Loss Multiple1.25floatposSize nLoss
Trailing Stop Multiple1.25floatts_loss
Sensitivity150intt1
FastEMA Length20intfastMA t1
SlowEMA Length40intslowMA t1
BB Channel Length20inte1
BB Stdev Multiplier2.0floatdev e1

What it calculates

  • TRtruecr_multi · line 48
  • ATRatrLengthatr · line 81
  • MACDclose, 12, 26, 9macdLine · line 107
  • MACDclose, 12, 26, 9signalLine · line 107
  • MACDclose, 12, 26, 9histLine · line 107
  • RMA / TRta.tr(true), 100DEAD_ZONE · line 126
  • EMAsource, FastEMA Length (20)fastMA · line 128
  • EMAsource, SlowEMA Length (40)slowMA · line 129
  • SMAsource, lengthbasis · line 136
  • Stdevsource, lengthdev · line 137

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.

high · low · closehigh · low · closeprice dataclosecloseprice datafastLengthFastEMA Lengthsetting · 20slowLengthSlowEMA Lengthsetting · 40multBB Stdev Multipliersetting · 2.0startYearStart Yearsetting · 2008startMonthStart Monthsetting · 1startDayStart Daysetting · 1endYearEnd Yearsetting · 2022endMonthEnd Monthsetting · 12endDayEnd Daysetting · 1timetimeprice datapercentRiskRisk Per Tradesetting · 0.02atrMulti_LossAtr Loss Multiplesetting · 1.25sensitivitySensitivitysetting · 150channelLengthBB Channel Lengthsetting · 20tsMultiTrailing Stop Multiplesetting · 1.25cr_multiTR→ cr_multiatrATR→ atrmacdLineMACD→ macdLinesignalLineMACD→ signalLinehistLineMACD→ histLineDEAD_ZONERMA / TR→ DEAD_ZONEfastMAEMA→ fastMAslowMAEMA→ slowMAbasisSMA→ basisdevStdev→ devquoteCurrency, factorquoteCurrency · factor2 valuesusdUSDrate, gbpUSDrate, audUSDrate, nzdUSDrate, cadUSDrate, chfUSDrate, eurUSDrate, jpyUSDrate, phpUSDrateusdUSDrate · gbpUSDrate…9 valuesstartDatestartDatevalueendDateendDatevalueEURCHFCrashDateEURCHFCrashDatevalueriskMoneyriskMoneyvalueposSizeposSizevaluet1t1valuee1e1valuetrendUp, trendDowntrendUp · trendDown2 valuesentry_atrentry_atrvalueentry_priceentry_pricevaluenLossnLossvaluenProfitnProfitvaluets_lossts_lossvaluelong_profit_level, short_stop_levellong_profit_level · sho…2 valueslong_stop_levellong_stop_levelvalueshort_profit_levelshort_profit_levelvalueInd_1_LInd_1_Lconditionentry_longentry_longconditionentry_shortentry_shortconditionInd_2_LInd_2_Lconditionentry:Long Entry 1Open Long Entry 1strategy.entryentry:Short Entry 1Open Short Entry 1strategy.entryexit:TP/SL 1exit TP/SL 1strategy.exitclose:Long Entry 1Close Long Entry 1strategy.closeclose:Short Entry 1Close Short Entry 1strategy.closeplotshape:152plotshapeplotshapeplotshape:153plotshapeplotshapeplot:189plotplotplot:190plotplotplot:191plotplotplot:192plotplot

Order rules

OrderFires whenBy defaultLine
Open Long Entry 1 longentry_longOn161
Open Short Entry 1 shortentry_shortOn163
Exit TP/SL 1 stopevery barOn198
Exit TP/SL 1 stopevery barOn199
Close Long Entry 1Ind_1_SOn201
Close Short Entry 1Ind_1_Lta.crossover(histLine, 0) and macdLine > 0On202

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 data9 request.security call(s), none with lookahead on.
  • 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

Not run on other markets: the script requests USDUSD D, GBPUSD D, AUDUSD D, NZDUSD D, CADUSD D, CHFUSD D, EURUSD D, JPYUSD D, PHPUSD D, and that data is not available here (USDUSD is not on Binance; GBPUSD is not on Binance; AUDUSD is not on Binance; NZDUSD is not on Binance; CADUSD is not on Binance; CHFUSD is not on Binance; EURUSD is not on Binance; JPYUSD is not on Binance; PHPUSD is not on Binance). Its results would rest on empty values.

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
Strategy - Trend Chaser - PSe this page—v5 strategy0.0%00.0%
888 BOT #backtest by UnknownUnicorn2151907sma ema rma stdev macd atrv4 strategy+3.0%120.9%
Athena Momentum Squeeze - Short, Lean, and Mean by jrandolph1046ema sma stdev tr atrv5 strategy+3.7%100.6%
Contrarian Scalping Counter Trend Bb Envelope Adx and Stochastic by exlux99sma stdev ema rmav5 strategy+1.9%153.2%
Trend Following with Bollinger Bands by Robrecht99sma stdev ema atrv5 strategy+2.5%71.7%
Best TradingView Strategy - For NASDAQ and DOW30 and other Index by The_Bigger_Bullsma stdev rma emav5 strategy+2.2%173.4%

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.

  • 2 strategy calls use the when = argument (line 201, 202). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • 7 settings use the untyped input() (line 75, 76, 121, 122, 123, 124, 125). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

Not verified

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

  • Line 75: input() → input.float()
  • Line 76: input() → input.float()
  • Line 121: input() → input.int()
  • Line 122: input() → input.int()
  • Line 123: input() → input.int()
  • Line 124: input() → input.int()
3 more edits
  • Line 125: input() → input.float()
  • Line 201: when = Ind_1_S → if block
  • Line 202: when = Ind_1_L → if block
⋯atrLength = 14 -atrMulti_Loss = input(title='Atr Loss Multiple', defval=1.25)+atrMulti_Loss = input.float(title='Atr Loss Multiple', defval=1.25)-tsMulti = input(title='Trailing Stop Multiple', defval=1.25)+tsMulti = input.float(title='Trailing Stop Multiple', defval=1.25)//ATR function⋯// Modified for Crypto Market by ShayanKM-sensitivity = input(150, title='Sensitivity')+sensitivity = input.int(150, title='Sensitivity')-fastLength = input(20, title='FastEMA Length')+fastLength = input.int(20, title='FastEMA Length')-slowLength = input(40, title='SlowEMA Length')+slowLength = input.int(40, title='SlowEMA Length')-channelLength = input(20, title='BB Channel Length')+channelLength = input.int(20, title='BB Channel Length')-mult = input(2.0, title='BB Stdev Multiplier')+mult = input.float(2.0, title='BB Stdev Multiplier')DEAD_ZONE = nz(ta.rma(ta.tr(true), 100)) * 3.7⋯//Submit exit orders on exit indicator - Exit 1-strategy.close(id='Long Entry 1', comment='Exit 1 L1', when=Ind_1_S)+if Ind_1_S+    strategy.close(id='Long Entry 1', comment='Exit 1 L1')-strategy.close(id='Short Entry 1', comment='Exit 1 S1', when=Ind_1_L)+if Ind_1_L+    strategy.close(id='Short Entry 1', comment='Exit 1 S1')//==============================================================================⋯

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.

⋯// © Dillon_Grech / Elvin Latayan-//@version=5+//@version=6strategy('Strategy - Trend Chaser - PSe', overlay=true, currency=currency.USD, pyramiding=1, initial_capital=25000)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 43 msWith a workaround 1,000 bars in 97 msNot measured
PineTSNot testedNot testedNot measured

Zeal Terminal's engine currently reads an order side written as direction = strategy.long, direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 161, 163) 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.

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/// © Dillon_Grech / Elvin Latayan//@version=5strategy('Strategy - Trend Chaser - PSe', overlay=true, currency=currency.USD, pyramiding=1, initial_capital=25000)//==============================================================================//FOREX EXCHANGE - Currency Conversion//==============================================================================//Select quote currencyquoteCurrency = syminfo.currency  //gets quote currency automatically by looking using syminfo function - thank you Rodenwild//Get currency pair rate quoted against USD (base currency)usdUSDrate = request.security('USDUSD', 'D', close[1])gbpUSDrate = request.security('GBPUSD', 'D', close[1])audUSDrate = request.security('AUDUSD', 'D', close[1])nzdUSDrate = request.security('NZDUSD', 'D', close[1])cadUSDrate = request.security('CADUSD', 'D', close[1])chfUSDrate = request.security('CHFUSD', 'D', close[1])eurUSDrate = request.security('EURUSD', 'D', close[1])jpyUSDrate = request.security('JPYUSD', 'D', close[1])phpUSDrate = request.security('PHPUSD', 'D', close[1])//Fuction to get currency rate into variable cr_function(source) =>    if quoteCurrency == 'USD'        1    else        if quoteCurrency == 'GBP'            gbpUSDrate        else            if quoteCurrency == 'AUD'                audUSDrate            else                if quoteCurrency == 'NZD'                    nzdUSDrate                else                    if quoteCurrency == 'CAD'                        cadUSDrate                    else                        if quoteCurrency == 'CHF'                            chfUSDrate                        else                            if quoteCurrency == 'EUR'                                eurUSDrate                            else                                if quoteCurrency == 'PHP'                                    phpUSDrate                                else                                    jpyUSDrate//Put currency rate function into variablecr_multi = cr_function(ta.tr(true))//==============================================================================//==============================================================================//BACKTEST DATE RANGE - Select Dates//==============================================================================//Input for date windowstartDay = input.int(defval=1, title='Start Day', minval=1, maxval=31)startMonth = input.int(defval=1, title='Start Month', minval=1, maxval=12)startYear = input.int(defval=2008, title='Start Year', minval=1970)endDay = input.int(defval=1, title='End Day', minval=1, maxval=31)endMonth = input.int(defval=12, title='End Month', minval=1, maxval=12)endYear = input.int(defval=2022, title='End Year', minval=1970)//Submit date windowstartDate = timestamp(startYear, startMonth, startDay, 00, 00, 00)  // backtest start dateendDate = timestamp(endYear, endMonth, endDay, 23, 59, 59)  // backtest end datedateRange() =>  // specify where date range is true    time >= startDate and time <= endDate ? true : false// Remove EurChf from testingEURCHFCrashDate = syminfo.currency == 'CHF' or syminfo.basecurrency == 'CHF' ? time >= timestamp(2015, 01, 01) and time <= timestamp(2015, 01, 18) ? false : true : true//==============================================================================//==============================================================================//MONEY MANAGEMENT - ATR//==============================================================================//Entrer intial capital and percentage risk inputspercentRisk = input.float(title='Risk Per Trade', defval=0.02, minval=0.001, maxval=1)//Enter ATR inputsatrLength = 14 atrMulti_Loss = input(title='Atr Loss Multiple', defval=1.25)tsMulti = input(title='Trailing Stop Multiple', defval=1.25)//ATR functiontruncate(number, decimals) =>    factor = math.pow(10, decimals)    int(number * factor) / factoratr = truncate(ta.atr(atrLength), 5)//Fuction for pse lot sizepse_lotsize(tickSize) =>    if tickSize == 0.0001        10000    else        if tickSize >= 0.001 and tickSize <= 0.005            1000        else            if tickSize >= 0.01 and tickSize <= 0.05                100            else                if tickSize >= 0.10 and tickSize <= 0.50                    10                else                    if tickSize >= 1 and tickSize <= 5                        1//Get position size//posSize = round((((strategy.initial_capital/100) * percentRisk) / (atrMulti_Loss * atr))/ syminfo.mintick)riskMoney = strategy.initial_capital / pse_lotsize(syminfo.mintick) * percentRiskposSize = math.round(riskMoney / (atrMulti_Loss * atr * syminfo.pointvalue) / syminfo.mintick)//==============================================================================//==============================================================================//INDICATOR 1 - Trigger//==============================================================================//Indicator Name[macdLine, signalLine, histLine] = ta.macd(close, 12, 26, 9)Ind_1_L = ta.crossover(histLine, 0) and macdLine > 0Ind_1_S = false//==============================================================================//==============================================================================//INDICATOR 2//==============================================================================//Indicator Name//// @author LazyBear // List of all my indicators: // https://docs.google.com/document/d/15AGCufJZ8CIUvwFJ9W-IKns88gkWOKBCvByMEvm5MLo/edit?usp=sharing//// Modified for Crypto Market by ShayanKMsensitivity = input(150, title='Sensitivity')fastLength = input(20, title='FastEMA Length')slowLength = input(40, title='SlowEMA Length')channelLength = input(20, title='BB Channel Length')mult = input(2.0, title='BB Stdev Multiplier')DEAD_ZONE = nz(ta.rma(ta.tr(true), 100)) * 3.7calc_macd(source, fastLength, slowLength) =>    fastMA = ta.ema(source, fastLength)    slowMA = ta.ema(source, slowLength)    fastMA - slowMAcalc_BBUpper(source, length, mult) =>    basis = ta.sma(source, length)    dev = mult * ta.stdev(source, length)    basis + devcalc_BBLower(source, length, mult) =>    basis = ta.sma(source, length)    dev = mult * ta.stdev(source, length)    basis - devt1 = (calc_macd(close, fastLength, slowLength) - calc_macd(close[1], fastLength, slowLength)) * sensitivitye1 = calc_BBUpper(close, channelLength, mult) - calc_BBLower(close, channelLength, mult)trendUp = t1 >= 0 ? t1 : 0trendDown = t1 < 0 ? -1 * t1 : 0//Long and Short Orders (Confirmation Conditions)Ind_2_L = trendUp > e1Ind_2_S = false//==============================================================================//ENTRY CONDITIONS - Submit Orders//==============================================================================//Long and short strategy conditionsentry_long = strategy.position_size <= 0 and dateRange() and EURCHFCrashDate and Ind_1_L and Ind_2_Lentry_short = strategy.position_size >= 0 and dateRange() and EURCHFCrashDate and Ind_1_S and Ind_2_Splotshape(entry_long, color=color.new(color.lime, 0), style=shape.arrowup, location=location.belowbar, text='Buy')plotshape(entry_short, color=color.new(color.red, 0), style=shape.arrowdown, location=location.abovebar, text='Sell')//Store ATR and Price upon entry of trade.entry_atr = float(0.0)  //set floatentry_price = float(0.0)  //set floatentry_atr := strategy.position_size == 0 or entry_long or entry_short ? atr : entry_atr[1]entry_price := strategy.position_size == 0 or entry_long or entry_short ? close : entry_price[1]//Submit long and short orders based on entry conditionsif entry_long    strategy.entry(id='Long Entry 1', direction=strategy.long, qty=posSize)if entry_short    strategy.entry(id='Short Entry 1', direction=strategy.short, qty=posSize)//==============================================================================//==============================================================================//TAKE PROFIT & STOP LOSS VALUES//==============================================================================//Calculate stop loss and take profit distance (in price)nLoss = entry_atr * atrMulti_LossnProfit = entry_atrts_loss = entry_atr  * tsMulti//Find long take profit and stop loss levelslong_profit_level = float(0.0)  //set floatlong_stop_level = float(0.0)  //set floatlong_profit_level := entry_price + nLosslong_stop_level := entry_price - nLossif math.max(close, close[1]) > long_profit_level    long_stop_level := entry_price    long_stop_levelif long_stop_level < math.max(close - (ts_loss + ts_loss), nz(long_stop_level[1], 0))    long_stop_level := math.max(close - (ts_loss + ts_loss), nz(long_stop_level[1], 0), strategy.position_avg_price)    long_stop_level//Find short take profit and stop loss levelsshort_profit_level = float(0.0)  //set floatshort_stop_level = float(0.0)  //set floatshort_profit_level := entry_price - nProfitshort_stop_level := entry_price + nLoss//Plot stop loss and profit level on graph; hide levels when no tradeplot(strategy.position_size <= 0 or entry_long or entry_short ? na : long_stop_level, color=color.new(color.red, 0), style=plot.style_linebr, linewidth=2)plot(strategy.position_size <= 0 or entry_long or entry_short ? na : long_profit_level, color=color.new(color.green, 0), style=plot.style_linebr, linewidth=2)plot(strategy.position_size >= 0 or entry_long or entry_short ? na : short_stop_level, color=color.new(color.red, 0), style=plot.style_linebr, linewidth=2)plot(strategy.position_size >= 0 or entry_long or entry_short ? na : short_profit_level, color=color.new(color.green, 0), style=plot.style_linebr, linewidth=2)//==============================================================================//==============================================================================//EXIT CONDITIONS - Submit Orders//==============================================================================//Submit exit orders on static profit and lossstrategy.exit('TP/SL 1', 'Long Entry 1', stop=long_stop_level)strategy.exit('TP/SL 1', 'Short Entry 1', stop=short_stop_level)//Submit exit orders on exit indicator - Exit 1strategy.close(id='Long Entry 1', comment='Exit 1 L1', when=Ind_1_S)strategy.close(id='Short Entry 1', comment='Exit 1 S1', when=Ind_1_L)//==============================================================================if entry_long    label.new(bar_index, na, "•ENTRY•\nPosition Size = " + str.tostring(posSize) + "\n Potential Stop Loss = " + str.tostring(close - nLoss) + "\n Actual Stop Loss = " + str.tostring(long_stop_level), yloc = yloc.abovebar, style = label.style_none, textcolor = color.black, size = size.normal)