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
- 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Lead Look Back | 52 | int · min 1 | leadLine |
| Displacement | 26 | int · min 1 | buycross sellcross Lead2 Çizgisi |
| Sadece Long Yönlü Poz Aç | false | bool | entry Long exit Exit Long entry Short exit Exit Short line 18 line 21 |
| Long Kar Al Puanı | 10000 | int · min 30 · step 10 | exit Exit Long |
| Long Zarar Durdur Puanı | 7500 | int · min 30 · step 10 | exit Exit Long |
| Short Kar Al Puanı | 20000 | int · min 30 · step 10 | exit Exit Short |
| Short Zarar Durdur Puanı | 7500 | int · min 30 · step 10 | exit Exit Short |
What it calculates
- Crossoverclose, leadLine[displacement-1]
buycross · line 16 - CrossoverleadLine[displacement-1], close
sellcross · 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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Long long | (buycross) and (pozyonu == true) or buycross | On | 19 |
| Exit Exit Long stop and limit | (buycross) and (pozyonu == true) or buycross | On | 20 |
| Open Short short | (sellcross) and pozyonu == false | On | 22 |
| Exit Exit Short stop and limit | (sellcross) and pozyonu == false | On | 23 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +0.1% | +102.5% | 36 | 47% | 1.61 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +0.0% | +5.5% | 45 | 36% | 1.06 | 0.1% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −0.0% | +9.8% | 42 | 31% | 0.79 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −0.0% | +8.4% | 50 | 12% | 0.59 | 0.1% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.0% | +16.7% | 47 | 21% | 1.11 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.0% | +21.5% | 30 | 23% | 1.81 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.0% | +148.3% | 32 | 31% | 1.96 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −0.0% | +17.1% | 54 | 17% | 0.54 | 0.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 11 | 64% | $700.00 |
| Sideways market | 24 | 38% | $75.00 |
| Falling market | 1 | 100% | $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.
All 36 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 1 May 2024 60,672.00 | 1 May 2024 60,747.00 | 0 | −$75.00 |
| long | 4 May 2024 62,882.00 | 4 May 2024 62,807.00 | 0 | −$75.00 |
| short | 9 May 2024 61,193.00 | 9 May 2024 60,993.00 | 0 | $200.00 |
| long | 10 May 2024 63,074.00 | 10 May 2024 63,174.00 | 0 | $100.00 |
| short | 11 May 2024 60,800.00 | 11 May 2024 60,600.00 | 0 | $200.00 |
| long | 18 May 2024 67,024.00 | 18 May 2024 67,124.00 | 0 | $100.00 |
| short | 20 May 2024 66,274.00 | 20 May 2024 66,074.00 | 0 | $200.00 |
| long | 21 May 2024 71,446.60 | 21 May 2024 71,546.60 | 0 | $100.00 |
| short | 22 Jun 2024 64,143.60 | 22 Jun 2024 64,218.60 | 0 | −$75.00 |
| long | 16 Jul 2024 64,724.10 | 16 Jul 2024 64,824.10 | 0 | $100.00 |
| short | 18 Jul 2024 64,088.00 | 18 Jul 2024 63,888.00 | 0 | $200.00 |
| long | 20 Jul 2024 66,660.00 | 20 Jul 2024 66,585.00 | 0 | −$75.00 |
| short | 3 Aug 2024 61,498.30 | 3 Aug 2024 61,573.30 | 0 | −$75.00 |
| long | 24 Aug 2024 64,037.20 | 24 Aug 2024 64,137.20 | 0 | $100.00 |
| short | 28 Aug 2024 59,415.00 | 28 Aug 2024 59,490.00 | 0 | −$75.00 |
| long | 14 Sep 2024 60,498.00 | 14 Sep 2024 60,598.00 | 0 | $100.00 |
| short | 16 Sep 2024 59,132.00 | 16 Sep 2024 59,207.00 | 0 | −$75.00 |
| long | 18 Sep 2024 60,314.00 | 18 Sep 2024 60,239.00 | 0 | −$75.00 |
| short | 3 Feb 2025 97,700.60 | 3 Feb 2025 97,775.60 | 0 | −$75.00 |
| long | 4 Feb 2025 101,329.00 | 4 Feb 2025 101,429.00 | 0 | $100.00 |
| short | 5 Feb 2025 97,763.10 | 5 Feb 2025 97,838.10 | 0 | −$75.00 |
| long | 23 Apr 2025 93,443.00 | 23 Apr 2025 93,543.00 | 0 | $100.00 |
| short | 26 Aug 2025 110,112.00 | 26 Aug 2025 109,912.00 | 0 | $200.00 |
| long | 27 Aug 2025 111,763.00 | 27 Aug 2025 111,863.00 | 0 | $100.00 |
| short | 30 Aug 2025 108,377.00 | 30 Aug 2025 108,452.00 | 0 | −$75.00 |
| long | 3 Sep 2025 111,240.00 | 3 Sep 2025 111,165.00 | 0 | −$75.00 |
| short | 6 Sep 2025 110,660.00 | 6 Sep 2025 110,735.00 | 0 | −$75.00 |
| long | 12 Sep 2025 115,483.00 | 12 Sep 2025 115,408.00 | 0 | −$75.00 |
| short | 20 Sep 2025 115,632.00 | 20 Sep 2025 115,432.00 | 0 | $200.00 |
| long | 2 Oct 2025 118,595.00 | 2 Oct 2025 118,520.00 | 0 | −$75.00 |
| short | 11 Oct 2025 112,774.00 | 11 Oct 2025 112,849.00 | 0 | −$75.00 |
| long | 15 Jan 2026 96,951.80 | 15 Jan 2026 97,051.80 | 0 | $100.00 |
| short | 16 Jan 2026 95,604.80 | 16 Jan 2026 95,679.80 | 0 | −$75.00 |
| long | 16 Apr 2026 74,810.00 | 16 Apr 2026 74,910.00 | 0 | $100.00 |
| short | 1 Jun 2026 73,674.40 | 1 Jun 2026 73,749.40 | 0 | −$75.00 |
| long | 19 Aug 2026 64,725.40 | 19 Aug 2026 64,650.40 | 0 | −$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
VerifiedNothing 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
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 20 ms | Yes 1,000 bars in 26 ms | Not measured |
| PineTS | Not tested | Not tested | 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.
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)