Zeal Terminal Open in Zeal Terminal

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
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (3)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$135,725$202,527Equity from $100,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
+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.

SettingDefaultType and rangeFeeds
Mode (no label in the script)Buy Uptrendstring · options ["Buy Uptrend", "Buy Downtrend"]longCondition closeCondition
Stop Loss (SL) level0.9float · step 0.01closeCondition
Take Profit (TP) level1.1float · step 0.01closeCondition

What it calculates

  • SMAclose, 200sma · 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.

closecloseprice datamodeModesetting · Buy UptrendstopLossStop Loss (SL) levelsetting · 0.9takeProfitTake Profit (TP) levelsetting · 1.1smaSMA→ smalongConditionlongConditionvaluecloseConditioncloseConditionvalueentry:My Long Entry IdOpen My Long Entry Idstrategy.entryexit:Exitexit Exitstrategy.exitplot:13plotplot

Order rules

OrderFires whenBy defaultLine
Open My Long Entry Id long(longCondition)On20
Exit Exit limit(closeCondition)On23

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 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+28.5%+102.5%1060%1.7313.2%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+31.3%+5.5%3100%—5.4%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.4%+9.8%2348%1.0045.6%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+39.7%+8.4%580%4.587.5%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+34.8%+16.7%2955%1.2233.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+30.6%+21.5%863%2.1011.6%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+38.9%+148.3%2650%1.3028.6%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+23.6%+17.1%475%4.426.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 market333%−$13,058.40
Sideways market683%$47,825.80
Falling market10%−$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.

0%25%
All 10 trades
SideEntryExitBarsP&L
long30 Sep 2024 65,602.0030 Oct 2024 72,736.4030$10,875.30
long31 Oct 2024 72,344.8011 Nov 2024 80,370.0011$11,093.10
long12 Nov 2024 88,648.0022 Nov 2024 98,317.1010$10,907.30
long23 Nov 2024 98,892.0026 Feb 2025 88,680.4095−$10,326.00
long27 Feb 2025 84,250.103 Mar 2025 94,270.004$11,893.10
long4 Mar 2025 86,221.2011 Mar 2025 78,595.907−$8,843.94
long13 Mar 2025 83,680.107 Apr 2025 78,430.0025−$6,274.03
long28 Apr 2025 93,749.309 May 2025 103,262.0011$10,146.60
long10 May 2025 102,972.0011 Jul 2025 116,010.0062$12,661.70
long12 Jul 2025 117,528.005 Nov 2025 101,497.00116−$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.

ScriptSharesTypeNetTradesMax drawdown
Cycle Position Trading this page—v5 strategy+28.5%1013.2%
Follow the Crypto Shorts by xtradernetsmav4 strategyNo trades on this market
buy down and sell high trend 200 sma and ma cross by willi130503smav4 strategyNo trades on this market
Mayer Multiple Strategy by xtradernetsmav4 strategyNo trades on this market
Moving Average Cross Strategy early Closing by Geduldtradersmav4 strategy+73.8%20151.5%
MFI Simple Strategy by OztheWozsmav5 strategy−0.2%283.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

Verified

Nothing 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.

Download the v6 script

⋯// © 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

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 8 msYes 1,000 bars in 19 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/// © 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)