Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Optimized Zhaocaijinbao strategy

A Pine Script v5 strategy built on SMA (close, 6), EMA (close, 2) and Crossunder (sellLine, buyLine). It has 4 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss and a profit target. Each trade commits 100% of equity and pays no commission. 2 settings; defaults include Max Position Size (%) 0.01 and Risk Factor 2.0.

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 Optimized Zhaocaijinbao strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 6 of 6 trades.
How did Optimized Zhaocaijinbao strategy do on BTCUSDT 1D with default settings?
+15.63%
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 Optimized Zhaocaijinbao strategy run in Pine Script v6?
Yes
Same 12 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 Optimized Zhaocaijinbao strategy use a stop loss?
Yes
strategy.exit sets a stop on line 51.
Does Optimized Zhaocaijinbao strategy run in Zeal Terminal?
Yes
It compiles in 35 ms and runs 1,000 bars in 49 ms, in the browser.

BTCUSDT · 1D · default settings

  • Shape
  • Shape
  • Plot
  • Plot
  • 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 (2)
25,00050,00075,000100,000125,000AprJulOct2025AprJulOct2026AprJulOct$1,156,250$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
+15.63%
$156,263.00
Buy and hold
+102.5%
same period
Closed trades
12
7 won · 5 lost
Profitable
58.3%
of closed trades
Profit factor
1.94
gross profit ÷ gross loss
Max drawdown
9.85%
−$98,458.30

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.

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • 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
Max Position Size (%)0.01float · min 0.001 · max 0.5 · step 0.001positionSize
Risk Factor2.0float · min 0.1 · max 10.0 · step 0.1positionSize

What it calculates

  • SMAclose, 6ma6 · line 7
  • SMAclose, 35ma35 · line 8
  • EMAclose, 2buyLine · line 10
  • SMAclose, 8sellLine · line 12
  • EMAvolume, 20volumeEMA · line 14
  • SMAclose, 50weeklyMa · line 16
  • CrossundersellLine, buyLinesellSignal · line 20
  • ATR14atr · line 25

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 datavolumevolumeprice datahigh · low · closehigh · low · closeprice datamaxPositionSizeMax Position Size (%)setting · 0.01riskFactorRisk Factorsetting · 2.0ma6SMA→ ma6ma35SMA→ ma35buyLineEMA→ buyLinesellLineSMA→ sellLinevolumeEMAEMA→ volumeEMAweeklyMaSMA→ weeklyMasellSignalCrossunder→ sellSignalatrATR→ atrsellSlopesellSlopevalueequity, stopLoss, takeProfitequity · stopLoss +13 valuespositionSizepositionSizevaluebuyConditionbuyConditionconditionsellConditionsellConditionconditionweeklySlopeweeklySlopeconditionbuySignalbuySignalconditionentry:LongOpen Longstrategy.entryclose:LongClose Longstrategy.closeexit:Long Stop Lossexit Long Stop Lossstrategy.exitexit:Long Take Profitexit Long Take Profitstrategy.exitplotshape:40plotshapeplotshapeplotshape:41plotshapeplotshapeplot:43plotplotplot:44plotplotplot:46plotplot

Order rules

OrderFires whenBy defaultLine
Open Long long(buyCondition)On34
Close Long(sellCondition)On37
Exit Long Stop Loss stopinPositionOn51
Exit Long Take Profit limitinPositionOn52

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.

6/6trades 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+15.6%+102.5%1258%1.949.8%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−1.7%+9.8%1443%0.9531.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%+8.4%00%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+34.6%+16.7%757%7.364.3%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+7.1%+21.5%2100%—1.2%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−9.3%+148.3%838%0.5824.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h0.0%+17.1%00%—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 barsTradesWonP&L
Rising market580%$235,747.00
Sideways market540%−$78,468.30
Falling market250%−$1,015.83

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

How bad could the drawdown be?

12.6%

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, 5.3% to 12.6%; the tick is what actually happened, 7.3%. Order luck alone moves it this much.

0%15%
All 12 trades
SideEntryExitBarsP&L
long4 Jun 2024 68,809.901 Jul 2024 62,772.0027−$53,056.20
long27 Sep 2024 65,174.007 Oct 2024 62,819.9010−$19,993.00
long7 Nov 2024 75,572.0020 Nov 2024 92,310.8013$121,538.00
long5 Dec 2024 98,587.3012 Dec 2024 101,125.007$15,750.00
long19 May 2025 106,454.0027 May 2025 109,435.008$23,410.80
long3 Jul 2025 108,850.0023 Jul 2025 119,954.0020$88,129.00
long14 Jan 2026 95,414.0028 Jan 2026 89,250.0014−$57,174.60
long14 Apr 2026 74,418.0022 Apr 2026 76,336.108$16,520.90
long2 May 2026 78,231.1015 May 2026 81,090.0013$28,344.70
long31 Jul 2026 64,780.004 Aug 2026 63,520.004−$17,536.70
long15 Sep 2026 78,189.2019 Sep 2026 80,883.904$28,169.60
long2 Oct 2026 84,880.1014 Oct 2026 83,169.0012−$17,839.60

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
Optimized Zhaocaijinbao strategy this page—v5 strategy+15.6%129.8%
ATR with EOM and VORTEX by SoftKill21atr ema smav4 strategy+66.2%2229.9%
cATRpillar Strategy by Obi-wanClintobeatr sma emav4 strategy+1.02827e+24%2788,097.2%
EMA & Supertrend by bhavikmotaema sma atrv4 strategy+2,123.6%13980.9%
Koala System EURUSD 15min by SoftKill21sma ema atrv4 strategyNo trades on this market
Buy&Sell Bullish Engulfing - The Quant Science by thequantsciencesma ema atrv5 strategyNo trades on this market

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 12 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

⋯// © fzj20020403-////@version=5+////@version=6//@version=5⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 35 msYes 1,000 bars in 49 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/// © fzj20020403////@version=5//@version=5strategy("Optimized Zhaocaijinbao", overlay=true, margin_long=100, margin_short=0, default_qty_type=strategy.percent_of_equity, default_qty_value=100)// Define two moving averagesma6 = ta.sma(close, 6)ma35 = ta.sma(close, 35)// Define buy and sell signal linesbuyLine = ta.ema(close, 2)sellSlope = (close - close[8]) / 8sellLine = sellSlope * 1 + ta.sma(close, 8)// Define volume indicatorvolumeEMA = ta.ema(volume, 20)// Define weekly slope factorweeklyMa = ta.sma(close, 50)weeklySlope = (weeklyMa - weeklyMa[4]) / 4 > 0// Generate buy and sell signalsbuySignal = ta.crossover(buyLine, sellLine) and close > ma35 and volume > volumeEMA and weeklySlopesellSignal = ta.crossunder(sellLine, buyLine)// Define dynamic position sizing factorequity = strategy.equitymaxPositionSize = equity * input.float(title='Max Position Size (%)', defval=0.01, minval=0.001, maxval=0.5, step=0.001)riskFactor = input.float(title='Risk Factor', defval=2.0, minval=0.1, maxval=10.0, step=0.1)atr = ta.atr(14)positionSize = maxPositionSize * riskFactor / atr// Define position statusvar inPosition = false// Define buy and sell conditionsbuyCondition = buySignal and not inPositionsellCondition = sellSignal and inPosition// Perform buy and sell operationsif (buyCondition)    strategy.entry("Long", strategy.long, qty=positionSize)    inPosition := trueif (sellCondition)    strategy.close("Long")    inPosition := false// Draw vertical line markers for buy and sell signalsplotshape(buyCondition, style=shape.arrowdown, location=location.belowbar, color=color.green, size=size.small)plotshape(sellCondition, style=shape.arrowup, location=location.abovebar, color=color.red, size=size.small)// Draw two moving averagesplot(ma6, color=color.blue)plot(ma35, color=color.orange)// Draw volume indicator lineplot(volumeEMA, color=color.yellow)// Define stop loss and take profitstopLoss = strategy.position_avg_price * 0.5takeProfit = strategy.position_avg_price * 1.25if inPosition    strategy.exit("Long Stop Loss", "Long", stop=stopLoss)    strategy.exit("Long Take Profit", "Long", limit=takeProfit)