Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

TPS - FX Trade

A Pine Script v5 strategy built on Crossover (close, leadLine[displacement-1]). 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. 7 settings; defaults include Lead Look Back 52, Displacement 26 and Long Kar Al Puanı 10000.

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 TPS - FX Trade repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 5 of 5 trades.
How did TPS - FX Trade do on BTCUSDT 1D with default settings?
+0.09%
From 26 Jan 2024 to 21 Oct 2026, over 36 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does TPS - FX Trade 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: 36 before, 29 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does TPS - FX Trade use a stop loss?
Yes
strategy.exit sets a stop on line 20, 23.
Does TPS - FX Trade run in Zeal Terminal?
Yes
It compiles in 20 ms and runs 1,000 bars in 26 ms, in the browser.

BTCUSDT · 1D · default settings

  • Lead2 Çizgisi
  • 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 (7)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,000,880$2,025,273Equity from $1,000,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.09%
$875.00
Buy and hold
+102.5%
same period
Closed trades
36
17 won · 19 lost
Profitable
47.2%
of closed trades
Profit factor
1.61
gross profit ÷ gross loss
Max drawdown
0.03%
−$300.00

One run with the author's default settings, $1,000,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.

Settings

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

SettingDefaultType and rangeFeeds
Lead Look Back52int · min 1leadLine
Displacement26int · min 1buycross sellcross Lead2 Çizgisi
Sadece Long Yönlü Poz Açfalseboolentry Long exit Exit Long entry Short exit Exit Short line 18 line 21
Long Kar Al Puanı10000int · min 30 · step 10exit Exit Long
Long Zarar Durdur Puanı7500int · min 30 · step 10exit Exit Long
Short Kar Al Puanı20000int · min 30 · step 10exit Exit Short
Short Zarar Durdur Puanı7500int · min 30 · step 10exit Exit Short

What it calculates

  • Crossoverclose, leadLine[displacement-1]buycross · line 16
  • CrossoverleadLine[displacement-1], closesellcross · line 17

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 datadisplacementDisplacementsetting · 26laggingSpan2PeriodsLead Look Backsetting · 52buycrossCrossover→ buycrosssellcrossCrossover→ sellcrossleadLineleadLinevalueentry:LongOpen Longstrategy.entryexit:Exit Longexit Exit Longstrategy.exitentry:ShortOpen Shortstrategy.entryexit:Exit Shortexit Exit Shortstrategy.exitplot:15Lead2 Çizgisiplot

Order rules

OrderFires whenBy defaultLine
Open Long long(buycross) and (pozyonu == true) or buycrossOn19
Exit Exit Long stop and limit(buycross) and (pozyonu == true) or buycrossOn20
Open Short short(sellcross) and pozyonu == falseOn22
Exit Exit Short stop and limit(sellcross) and pozyonu == falseOn23

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.

5/5trades 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.1%+102.5%3647%1.610.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+0.0%+5.5%4536%1.060.1%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−0.0%+9.8%4231%0.790.1%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−0.0%+8.4%5012%0.590.1%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.0%+16.7%4721%1.110.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%3023%1.810.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.0%+148.3%3231%1.960.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.0%+17.1%5417%0.540.0%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 market1164%$700.00
Sideways market2438%$75.00
Falling market1100%$100.00

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

How bad could the drawdown be?

0.1%

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

0%1%
All 36 trades
SideEntryExitBarsP&L
short1 May 2024 60,672.001 May 2024 60,747.000−$75.00
long4 May 2024 62,882.004 May 2024 62,807.000−$75.00
short9 May 2024 61,193.009 May 2024 60,993.000$200.00
long10 May 2024 63,074.0010 May 2024 63,174.000$100.00
short11 May 2024 60,800.0011 May 2024 60,600.000$200.00
long18 May 2024 67,024.0018 May 2024 67,124.000$100.00
short20 May 2024 66,274.0020 May 2024 66,074.000$200.00
long21 May 2024 71,446.6021 May 2024 71,546.600$100.00
short22 Jun 2024 64,143.6022 Jun 2024 64,218.600−$75.00
long16 Jul 2024 64,724.1016 Jul 2024 64,824.100$100.00
short18 Jul 2024 64,088.0018 Jul 2024 63,888.000$200.00
long20 Jul 2024 66,660.0020 Jul 2024 66,585.000−$75.00
short3 Aug 2024 61,498.303 Aug 2024 61,573.300−$75.00
long24 Aug 2024 64,037.2024 Aug 2024 64,137.200$100.00
short28 Aug 2024 59,415.0028 Aug 2024 59,490.000−$75.00
long14 Sep 2024 60,498.0014 Sep 2024 60,598.000$100.00
short16 Sep 2024 59,132.0016 Sep 2024 59,207.000−$75.00
long18 Sep 2024 60,314.0018 Sep 2024 60,239.000−$75.00
short3 Feb 2025 97,700.603 Feb 2025 97,775.600−$75.00
long4 Feb 2025 101,329.004 Feb 2025 101,429.000$100.00
short5 Feb 2025 97,763.105 Feb 2025 97,838.100−$75.00
long23 Apr 2025 93,443.0023 Apr 2025 93,543.000$100.00
short26 Aug 2025 110,112.0026 Aug 2025 109,912.000$200.00
long27 Aug 2025 111,763.0027 Aug 2025 111,863.000$100.00
short30 Aug 2025 108,377.0030 Aug 2025 108,452.000−$75.00
long3 Sep 2025 111,240.003 Sep 2025 111,165.000−$75.00
short6 Sep 2025 110,660.006 Sep 2025 110,735.000−$75.00
long12 Sep 2025 115,483.0012 Sep 2025 115,408.000−$75.00
short20 Sep 2025 115,632.0020 Sep 2025 115,432.000$200.00
long2 Oct 2025 118,595.002 Oct 2025 118,520.000−$75.00
short11 Oct 2025 112,774.0011 Oct 2025 112,849.000−$75.00
long15 Jan 2026 96,951.8015 Jan 2026 97,051.800$100.00
short16 Jan 2026 95,604.8016 Jan 2026 95,679.800−$75.00
long16 Apr 2026 74,810.0016 Apr 2026 74,910.000$100.00
short1 Jun 2026 73,674.401 Jun 2026 73,749.400−$75.00
long19 Aug 2026 64,725.4019 Aug 2026 64,650.400−$75.00

Similar scripts

No other indicator or strategy here shares enough of its calculations.

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 runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 36 before, 29 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.

⋯// © MGULHANN-//@version=5+//@version=6strategy("TPS - FX Trade", overlay=true)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 20 msYes 1,000 bars in 26 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/// © MGULHANN//@version=5strategy("TPS - FX Trade", overlay=true)laggingSpan2Periods = input.int(52, minval=1, title="Lead Look Back")displacement = input.int(26, minval=1, title="Displacement")pozyonu = input.bool(false,title="Sadece Long Yönlü Poz Aç")// Stop Loss ve Kar Al Seviye GirişleriTPLong = input.int(10000, minval = 30, title ="Long Kar Al Puanı", step=10)SLLong = input.int(7500, minval = 30, title ="Long Zarar Durdur Puanı", step=10)TPShort = input.int(20000, minval = 30, title ="Short Kar Al Puanı", step=10)SLShort = input.int(7500, minval = 30, title ="Short Zarar Durdur Puanı", step=10)donchian(len) => math.avg(ta.lowest(len), ta.highest(len))leadLine = donchian(laggingSpan2Periods)plot(leadLine, offset = displacement - 1, color=#EF9A9A,title="Lead2 Çizgisi")buycross = ta.crossover(close,leadLine[displacement-1]) sellcross = ta.crossover(leadLine[displacement-1],close)if (buycross) and (pozyonu == true) or buycross     strategy.entry("Long", strategy.long)    strategy.exit("Exit Long", "Long", profit=TPLong, loss=SLLong)if (sellcross) and pozyonu == false    strategy.entry("Short", strategy.short)    strategy.exit("Exit Short", "Short", profit=TPShort, loss=SLShort)