Pine Script v5 · Strategy
Cycle Position Trading
A Pine Script v5 strategy built on SMA (close, 200). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits use a profit target and no stop loss. Each trade commits 100000 in cash and pays no commission. 3 settings; defaults include Mode Buy Uptrend, Stop Loss (SL) level 0.9 and Take Profit (TP) level 1.1.
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 Cycle Position Trading repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did Cycle Position Trading do on BTCUSDT 1D with default settings?
- +28.49%
- From 26 Jan 2024 to 21 Oct 2026, over 10 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does Cycle Position Trading run in Pine Script v6?
- Yes
- Same 10 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
- Does Cycle Position Trading use a stop loss?
- No
- Its exits set a profit target but no stop.
- Does Cycle Position Trading run in Zeal Terminal?
- Yes
- It compiles in 8 ms and runs 1,000 bars in 19 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +28.49%
- $28,493.30
- Buy and hold
- +102.5%
- same period
- Closed trades
- 10
- 6 won · 4 lost
- Profitable
- 60.0%
- of closed trades
- Profit factor
- 1.73
- gross profit ÷ gross loss
- Max drawdown
- 13.18%
- −$18,734.80
One run with the author's default settings, $100,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
strategy.exit is used without a stop, loss or trailing stop.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
1 setting has no label
In the settings dialog mode (line 6) shows an empty name. The labels on this page come from the variable names.
-
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 |
|---|---|---|---|
| Mode (no label in the script) | Buy Uptrend | string · options ["Buy Uptrend", "Buy Downtrend"] | longCondition closeCondition |
| Stop Loss (SL) level | 0.9 | float · step 0.01 | closeCondition |
| Take Profit (TP) level | 1.1 | float · step 0.01 | closeCondition |
What it calculates
- SMAclose, 200
sma · line 11
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 My Long Entry Id long | (longCondition) | On | 20 |
| Exit Exit limit | (closeCondition) | 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.
- 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 | +28.5% | +102.5% | 10 | 60% | 1.73 | 13.2% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +31.3% | +5.5% | 3 | 100% | — | 5.4% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +0.4% | +9.8% | 23 | 48% | 1.00 | 45.6% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +39.7% | +8.4% | 5 | 80% | 4.58 | 7.5% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +34.8% | +16.7% | 29 | 55% | 1.22 | 33.1% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +30.6% | +21.5% | 8 | 63% | 2.10 | 11.6% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +38.9% | +148.3% | 26 | 50% | 1.30 | 28.6% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +23.6% | +17.1% | 4 | 75% | 4.42 | 6.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 | 3 | 33% | −$13,058.40 |
| Sideways market | 6 | 83% | $47,825.80 |
| Falling market | 1 | 0% | −$6,274.03 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
22.1%
The 95th percentile of the worst drawdown when the same 10 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 9.6% to 22.1%; the tick is what actually happened, 11.2%. Order luck alone moves it this much.
All 10 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 30 Sep 2024 65,602.00 | 30 Oct 2024 72,736.40 | 30 | $10,875.30 |
| long | 31 Oct 2024 72,344.80 | 11 Nov 2024 80,370.00 | 11 | $11,093.10 |
| long | 12 Nov 2024 88,648.00 | 22 Nov 2024 98,317.10 | 10 | $10,907.30 |
| long | 23 Nov 2024 98,892.00 | 26 Feb 2025 88,680.40 | 95 | −$10,326.00 |
| long | 27 Feb 2025 84,250.10 | 3 Mar 2025 94,270.00 | 4 | $11,893.10 |
| long | 4 Mar 2025 86,221.20 | 11 Mar 2025 78,595.90 | 7 | −$8,843.94 |
| long | 13 Mar 2025 83,680.10 | 7 Apr 2025 78,430.00 | 25 | −$6,274.03 |
| long | 28 Apr 2025 93,749.30 | 9 May 2025 103,262.00 | 11 | $10,146.60 |
| long | 10 May 2025 102,972.00 | 11 Jul 2025 116,010.00 | 62 | $12,661.70 |
| long | 12 Jul 2025 117,528.00 | 5 Nov 2025 101,497.00 | 116 | −$13,639.70 |
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Cycle Position Trading this page | — | v5 strategy | +28.5% | 10 | 13.2% |
| Follow the Crypto Shorts by xtradernet | sma | v4 strategy | No trades on this market | ||
| buy down and sell high trend 200 sma and ma cross by willi130503 | sma | v4 strategy | No trades on this market | ||
| Mayer Multiple Strategy by xtradernet | sma | v4 strategy | No trades on this market | ||
| Moving Average Cross Strategy early Closing by Geduldtrader | sma | v4 strategy | +73.8% | 20 | 151.5% |
| MFI Simple Strategy by OztheWoz | sma | v5 strategy | −0.2% | 28 | 3.2% |
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?
Yes
Same 10 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.
⋯// © I11L-//@version=5+//@version=6strategy("Cycle Position Trading", overlay=true, pyramiding=1, default_qty_value=100000, initial_capital=100000, default_qty_type=strategy.cash, process_orders_on_close=false, calc_on_every_tick=false)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 8 ms | Yes 1,000 bars in 19 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/// © I11L//@version=5strategy("Cycle Position Trading", overlay=true, pyramiding=1, default_qty_value=100000, initial_capital=100000, default_qty_type=strategy.cash, process_orders_on_close=false, calc_on_every_tick=false)// Input for selecting the modemode = input.string("Buy Uptrend", options = ["Buy Uptrend", "Buy Downtrend"])// Input for customizing stop loss and take profit levelsstopLoss = input.float(0.9, title="Stop Loss (SL) level", step=0.01)takeProfit = input.float(1.1, title="Take Profit (TP) level", step=0.01)// Calculate the 200-day Simple Moving Average (SMA)sma = ta.sma(close, 200)// Plot the SMA on the chartplot(sma)// Define the conditions for entering a long position based on the selected modelongCondition = mode == "Buy Uptrend" ? close > sma and close[5] > sma : close < sma// Define the conditions for closing a position based on the selected modecloseCondition = mode == "Buy Uptrend" ? (strategy.position_avg_price * stopLoss > close or strategy.position_avg_price * takeProfit < close or close < sma * 0.95) : (strategy.position_avg_price * stopLoss > close or strategy.position_avg_price * takeProfit < close or close > sma * 1.05)// Execute a long position if the longCondition is metif (longCondition) strategy.entry("My Long Entry Id", strategy.long)// Close the position if the closeCondition is metif (closeCondition) strategy.exit("Exit", limit = close)