Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

PresentTrend - Strategy [presentTrading]

A Pine Script v5 strategy built on SMA (ta.tr, 14), RSI or MFI (hlc3, 14) and Crossover (PresentTrend, PresentTrend[2]). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 10% of equity and pays 0.1% commission. 5 settings; defaults include Source hlc3, Length 14 and Multiplier 1.618.

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 PresentTrend - Strategy [presentTrading] repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 2 of 2 trades.
How did PresentTrend - Strategy [presentTrading] do on BTCUSDT 1D with default settings?
−0.04%
From 26 Jan 2024 to 21 Oct 2026, over 12 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does PresentTrend - Strategy [presentTrading] run in Pine Script v6?
No
The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L7:C25: the argument 'default_qty_type' is specified more than once. The v6 version is shown for reference and is not offered as a download.
Does PresentTrend - Strategy [presentTrading] use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does PresentTrend - Strategy [presentTrading] run in Zeal Terminal?
Yes
It compiles in 28 ms and runs 1,000 bars in 40 ms, in the browser.

BTCUSDT · 1D · default settings

  • PresentTrend
  • Buy Signal
  • Sell Signal
  • 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 (5)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$10,156$20,253Equity from $10,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.04%
−$3.94
Buy and hold
+102.5%
same period
Closed trades
12
4 won · 8 lost
Profitable
33.3%
of closed trades
Profit factor
1.00
gross profit ÷ gross loss
Max drawdown
6.08%
−$608.38

One run with the author's default settings, $10,000 starting capital, commission as the script sets it. A long position was still open at the last bar. 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 stop loss

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

Settings

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

SettingDefaultType and rangeFeeds
PresentTrend
Sourcehlc3sourcePresentTrend
Length14intATR PresentTrend
Multiplier1.618float · step 0.1upperThreshold lowerThreshold
Whether to use RSI or MFIfalseboolPresentTrend
Trade DirectionBothstring · options ["Long", "Short", "Both"]entry Buy entry Sell close Buy close Sell line 36 line 38 line 41 line 43

What it calculates

  • SMAta.tr, Length (14)ATR · line 16
  • RSI / MFISource (hlc3), Length (14)PresentTrend · line 22
  • CrossoverPresentTrend, PresentTrend[2]longSignal · line 24
  • CrossunderPresentTrend, PresentTrend[2]shortSignal · line 25
  • BarssincelongSignalbarsSinceBuy · line 27
  • BarssinceshortSignalbarsSinceSell · line 28
  • BarssincelongSignal[1]previousBuy · line 29
  • BarssinceshortSignal[1]previousSell · line 30

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 datalengthParamLengthsetting · 14hlc3hlc3price datalowlowprice datamultiplierMultipliersetting · 1.618highhighprice datatradeDirectionTrade Directionsetting · BothATRSMA→ ATRPresentTrendRSI / MFI→ PresentTrendlongSignalCrossover→ longSignalshortSignalCrossunder→ shortSignalbarsSinceBuyBarssince→ barsSinceBuybarsSinceSellBarssince→ barsSinceSellpreviousBuyBarssince→ previousBuypreviousSellBarssince→ previousSellupperThresholdupperThresholdvaluelowerThresholdlowerThresholdvaluetrendDirectiontrendDirectionvalueentry:BuyOpen Buystrategy.entryentry:SellOpen Sellstrategy.entryclose:BuyClose Buystrategy.closeclose:SellClose Sellstrategy.closeplot:46PresentTrendplotplotshape:47Buy Signalplotshapeplotshape:48Sell Signalplotshape

Order rules

OrderFires whenBy defaultLine
Open Buy long(trendDirection == 1 and (tradeDirection == "Long" or tradeDirection == "Both"))On37
Open Sell short(trendDirection == -1 and (tradeDirection == "Short" or tradeDirection == "Both"))On39
Close Buy(tradeDirection == "Long" and trendDirection == -1)On42
Close Sell(tradeDirection == "Short" and trendDirection == 1)On44

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.

2/2trades 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%1233%1.006.1%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+0.9%+5.5%1436%1.311.3%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+12.8%+9.8%875%4.753.6%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+1.5%+8.4%633%1.831.7%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−10.0%+16.7%1233%0.4315.5%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.2%+21.5%850%1.053.8%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+4.1%+148.3%650%2.122.7%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.1%+17.1%1233%1.031.8%8 May 2026 – 21 Oct 2026

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

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market10%−$142.21
Sideways market1040%$148.18
Falling market10%−$8.92

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

How bad could the drawdown be?

7.2%

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

0%8%
All 12 trades
SideEntryExitBarsP&L
long22 May 2024 70,148.4025 Jun 2024 60,293.3034−$142.21
short25 Jun 2024 60,293.3021 Jul 2024 67,140.0026−$113.92
long21 Jul 2024 67,140.007 Aug 2024 56,022.0017−$163.00
short7 Aug 2024 56,022.0021 Sep 2024 63,201.1045−$124.70
long21 Sep 2024 63,201.1026 Feb 2025 88,680.40158$378.62
short26 Feb 2025 88,680.4024 Apr 2025 93,691.1057−$57.54
long24 Apr 2025 93,691.1031 Aug 2025 108,816.00129$155.59
short31 Aug 2025 108,816.003 Oct 2025 120,529.0033−$108.92
long3 Oct 2025 120,529.0018 Oct 2025 106,432.0015−$116.65
short18 Oct 2025 106,432.0015 Apr 2026 74,131.60179$292.69
long15 Apr 2026 74,131.6029 May 2026 73,617.5044−$8.92
short29 May 2026 73,617.5021 Aug 2026 73,027.0084$6.02

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
PresentTrend - Strategy [presentTrading] this page—v5 strategy−0.0%126.1%
CCU MFI + RSI + STOCH RSI by Bangsoulmfi rsi smav4 strategy+41.8%637.4%
AlphaTrend Strategy by only_fibonaccisma rsi barssincev5 strategy−1.4%244.2%
AlphaTrend Strategy with Trailing SL - by rohanarora1313sma rsi barssincev5 strategy−1.0%325.2%
3 Indicator Strategy (StochRSI, MFI & EMA) With Safety Orders by ggekko21rsi sma mfiv5 strategyNo trades on this market
SRJ RSI Outperformer Strategy by Sapt_Jashrsi smav5 strategy+0.6%82.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.

  • No v6-only features. v6 is not needed to run this script.

Clean v5

Verified

Nothing to change.

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L7:C25: the argument 'default_qty_type' is specified more than once. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © PresentTrading-//@version=5+//@version=6// Define the strategy settings⋯

Where it runs

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

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © PresentTrading//@version=5// Define the strategy settingsstrategy('PresentTrend - Strategy [presentTrading]' , overlay=true, precision=3, default_qty_type=strategy.cash,  commission_value= 0.1, commission_type=strategy.commission.percent, slippage= 1,   currency=currency.USD, default_qty_type = strategy.percent_of_equity, default_qty_value = 10, initial_capital= 10000)// Define the input parameterspriceSource  = input.source(title='Source', defval=hlc3, group='PresentTrend') // The price source to uselengthParam  = input.int(title='Length', defval=14, group='PresentTrend') // The length of the moving averagemultiplier = input.float(title='Multiplier', defval=1.618, step=0.1, group='PresentTrend') // The multiplier for the ATRindicatorChoice  = input.bool(title='Whether to use RSI or MFI', defval=false, group='PresentTrend') // Whether to use RSI or MFI// Add a parameter for choosing Long or ShorttradeDirection = input.string(title="Trade Direction", defval="Both", options=["Long", "Short", "Both"])// Calculate the ATR and the upT and downT valuesATR = ta.sma(ta.tr, lengthParam)upperThreshold = low - ATR * multiplier lowerThreshold  = high + ATR * multiplier // Initialize the PresentTrend indicatorPresentTrend = 0.0// Calculate the PresentTrend indicatorPresentTrend := (indicatorChoice ? ta.rsi(priceSource, lengthParam) >= 50 : ta.mfi(hlc3, lengthParam) >= 50) ? upperThreshold < nz(PresentTrend[1]) ? nz(PresentTrend[1]) : upperThreshold : lowerThreshold > nz(PresentTrend[1]) ? nz(PresentTrend[1]) : lowerThreshold// Calculate the buy and sell signalslongSignal  = ta.crossover(PresentTrend, PresentTrend[2])shortSignal  = ta.crossunder(PresentTrend, PresentTrend[2])// Calculate the number of bars since the last buy and sell signalsbarsSinceBuy = ta.barssince(longSignal)barsSinceSell = ta.barssince(shortSignal)previousBuy = ta.barssince(longSignal[1])previousSell = ta.barssince(shortSignal[1])// Initialize the direction variabletrendDirection = 0// Calculate the direction of the trendtrendDirection := longSignal and previousBuy > barsSinceSell ? 1 : shortSignal and previousSell > barsSinceBuy ? -1 : trendDirection[1]// Check the trade direction parameter before entering a tradeif (trendDirection == 1 and (tradeDirection == "Long" or tradeDirection == "Both"))    strategy.entry("Buy", strategy.long) if (trendDirection == -1 and (tradeDirection == "Short" or tradeDirection == "Both"))    strategy.entry("Sell", strategy.short) // Add a stop mechanism when the tradeDirection is one-sidedif (tradeDirection == "Long" and trendDirection == -1)    strategy.close("Buy")if (tradeDirection == "Short" and trendDirection == 1)    strategy.close("Sell")// Visualizationplot(PresentTrend, color=color.blue, title="PresentTrend")plotshape(series=longSignal, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal")plotshape(series=shortSignal, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal")