Zeal Terminal Open in Zeal Terminal

Pine Script v3 · Strategy

Legacy

Pyramiding Entries On Early Trends (by Coinrule)

A Pine Script v3 strategy built on SMA (close, 9) and Crossover (close, MAfast). It has 14 order rules, 7 entries among them, and trades long only with the default settings. Exits use a stop loss and a profit target. Each trade commits 20% of equity and pays 0.1% commission. 12 settings; defaults include From Month 1, From Day 10 and From Year 2020.

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 Pyramiding Entries On Early Trends (by Coinrule) repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 9 of 9 trades.
How did Pyramiding Entries On Early Trends (by Coinrule) do on BTCUSDT 1D with default settings?
+2.27%
From 26 Jan 2024 to 21 Oct 2026, over 20 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Pyramiding Entries On Early Trends (by Coinrule) be converted to Pine Script v5?
No
The automatic step from v3 to v4 changes the results, so no v4 download is offered; the edits are shown below.
Does Pyramiding Entries On Early Trends (by Coinrule) use a stop loss?
Yes
strategy.exit sets a stop on line 67, 68, 69, 70, 71, 72, 73.
Does Pyramiding Entries On Early Trends (by Coinrule) run in Zeal Terminal?
Yes
It compiles in 15 ms and runs 1,000 bars in 43 ms, in the browser.

BTCUSDT · 1D · default settings

  • SMA
  • SMA
  • SMA
  • Crossover
  • 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 (12)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$1,023$2,025Equity from $1,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference.
Net profit
+2.27%
$22.68
Buy and hold
+102.5%
same period
Closed trades
20
13 won · 7 lost
Profitable
65.0%
of closed trades
Profit factor
1.50
gross profit ÷ gross loss
Max drawdown
2.22%
−$23.17

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

    1 setting does nothing

    “Show Date Range” is declared but never read.

  • Note

    2 settings have no label

    In the settings dialog ProfitTarget_Percent (line 39), LossTarget_Percent (line 44) show 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.

  • Note

    Uses an argument v6 removed

    when = on line 50, 52, 54, 56, 58, 60, 62. The upgraded version below moves each call inside an if block.

Upgrade and export

Written in Pine Script v3. The upgrade to v5 takes 2 steps, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.

  • Upgrading to v5 renames sma → ta.sma, crossover → ta.crossover.
  • 7 strategy calls use the when = argument (line 50, 52, 54, 56, 58, 60, 62). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v3 → v4

Differs

Trades differ: 20 before, 20 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 4: //@version=3 → //@version=4
⋯    -//@version=3+//@version=4strategy(shorttitle='Pyramiding Entry On Early Trends',title='Pyramiding Entry On Early Trends (by Coinrule)', overlay=false, pyramiding= 7, initial_capital = 1000, default_qty_type = strategy.percent_of_equity, default_qty_value = 20, commission_type=strategy.commission.percent, commission_value=0.1)⋯

v4 → v5

Verified

Same 20 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 4: //@version=4 → //@version=5
  • Line 28: sma → ta.sma
  • Line 29: sma → ta.sma
  • Line 30: sma → ta.sma
  • Line 33: crossover → ta.crossover
⋯    -//@version=4+//@version=5strategy(shorttitle='Pyramiding Entry On Early Trends',title='Pyramiding Entry On Early Trends (by Coinrule)', overlay=false, pyramiding= 7, initial_capital = 1000, default_qty_type = strategy.percent_of_equity, default_qty_value = 20, commission_type=strategy.commission.percent, commission_value=0.1)⋯    -MAfast= sma(close, inSignal)+MAfast= ta.sma(close, inSignal)-MAslow= sma(close, inlong1)+MAslow= ta.sma(close, inlong1)-MAlong= sma(close, inlong2)+MAlong= ta.sma(close, inlong2)        -Bullish = crossover(close, MAfast) +Bullish = ta.crossover(close, MAfast)     ⋯

Clean v5

Verified

Same 20 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 9: input() → input.int()
  • Line 10: input() → input.int()
  • Line 11: input() → input.int()
  • Line 12: input() → input.int()
  • Line 13: input() → input.int()
  • Line 14: input() → input.int()
13 more edits
  • Line 16: input() → input.bool()
  • Line 24: input() → input.int()
  • Line 25: input() → input.int()
  • Line 26: input() → input.int()
  • Line 39: input() → input.int()
  • Line 44: input() → input.int()
  • Line 50: when = (strategy.opentrades == 0) and longsignal → if block
  • Line 52: when = (strategy.opentrades == 1) and longsignal → if block
  • Line 54: when = (strategy.opentrades == 2) and longsignal → if block
  • Line 56: when = (strategy.opentrades == 3) and longsignal → if block
  • Line 58: when = (strategy.opentrades == 4) and longsignal → if block
  • Line 60: when = (strategy.opentrades == 5) and longsignal → if block
  • Line 62: when = (strategy.opentrades == 6) and longsignal → if block
⋯//Backtest dates-fromMonth = input(defval = 1,  title = "From Month")     +fromMonth = input.int(defval = 1,  title = "From Month")     -fromDay   = input(defval = 10,    title = "From Day")       +fromDay   = input.int(defval = 10,    title = "From Day")       -fromYear  = input(defval = 2020, title = "From Year")       +fromYear  = input.int(defval = 2020, title = "From Year")       -thruMonth = input(defval = 1,    title = "Thru Month")     +thruMonth = input.int(defval = 1,    title = "Thru Month")     -thruDay   = input(defval = 1,    title = "Thru Day")     +thruDay   = input.int(defval = 1,    title = "Thru Day")     -thruYear  = input(defval = 2112, title = "Thru Year")       +thruYear  = input.int(defval = 2112, title = "Thru Year")           -showDate  = input(defval = true, title = "Show Date Range")+showDate  = input.bool(defval = true, title = "Show Date Range")    ⋯//MA inputs and calculations-inSignal=input(9, title='MAfast')+inSignal=input.int(9, title='MAfast')-inlong1=input(100, title='MAslow')+inlong1=input.int(100, title='MAslow')-inlong2=input(200, title='MAlong')+inlong2=input.int(200, title='MAlong')    ⋯    -ProfitTarget_Percent = input(3)+ProfitTarget_Percent = input.int(3)Profit_Ticks = (close * (ProfitTarget_Percent / 100)) / syminfo.mintick⋯    -LossTarget_Percent = input(3)+LossTarget_Percent = input.int(3)Loss_Ticks = (close * (LossTarget_Percent / 100)) / syminfo.mintick⋯    -strategy.entry("Entry 1", strategy.long, when = (strategy.opentrades == 0) and longsignal)+if (strategy.opentrades == 0) and longsignal+    strategy.entry("Entry 1", strategy.long)    -strategy.entry("Entry 2", strategy.long, when = (strategy.opentrades == 1) and longsignal)+if (strategy.opentrades == 1) and longsignal+    strategy.entry("Entry 2", strategy.long)        -strategy.entry("Entry 3", strategy.long, when = (strategy.opentrades == 2) and longsignal)+if (strategy.opentrades == 2) and longsignal+    strategy.entry("Entry 3", strategy.long)    -strategy.entry("Entry 4", strategy.long, when = (strategy.opentrades == 3) and longsignal)+if (strategy.opentrades == 3) and longsignal+    strategy.entry("Entry 4", strategy.long)    -strategy.entry("Entry 5", strategy.long, when = (strategy.opentrades == 4) and longsignal)+if (strategy.opentrades == 4) and longsignal+    strategy.entry("Entry 5", strategy.long)        -strategy.entry("Entry 6", strategy.long, when = (strategy.opentrades == 5) and longsignal)+if (strategy.opentrades == 5) and longsignal+    strategy.entry("Entry 6", strategy.long)        -strategy.entry("Entry 7", strategy.long, when = (strategy.opentrades == 6) and longsignal)+if (strategy.opentrades == 6) and longsignal+    strategy.entry("Entry 7", strategy.long)    ⋯

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: 20 before, 20 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.

⋯    -//@version=5+//@version=6strategy(shorttitle='Pyramiding Entry On Early Trends',title='Pyramiding Entry On Early Trends (by Coinrule)', overlay=false, pyramiding= 7, initial_capital = 1000, default_qty_type = strategy.percent_of_equity, default_qty_value = 20, commission_type=strategy.commission.percent, commission_value=0.1)⋯

Settings

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

SettingDefaultType and rangeFeeds
From Month1intstart
From Day10intstart
From Year2020intstart
Thru Month1intfinish
Thru Day1intfinish
Thru Year2112intfinish
Show Date Rangetrueboolunused
MAfast9intMAfast
MAslow100intMAslow
MAlong200intMAlong
Profit Target Percent (no label in the script)3intProfit_Ticks
Loss Target Percent (no label in the script)3intLoss_Ticks

What it calculates

  • SMA (sma, ta.sma in v5)close, MAfast (9)MAfast · line 28
  • SMA (sma, ta.sma in v5)close, MAslow (100)MAslow · line 29
  • SMA (sma, ta.sma in v5)close, MAlong (200)MAlong · line 30
  • Crossover (crossover, ta.crossover in v5)close, MAfastBullish · line 33

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 datainSignalMAfastsetting · 9inlong1MAslowsetting · 100inlong2MAlongsetting · 200fromYearFrom Yearsetting · 2020fromMonthFrom Monthsetting · 1fromDayFrom Daysetting · 10thruYearThru Yearsetting · 2112thruMonthThru Monthsetting · 1thruDayThru Daysetting · 1ProfitTarget_PercentProfit Target Percentsetting · 3LossTarget_PercentLoss Target Percentsetting · 3MAfastSMA→ MAfastMAslowSMA→ MAslowMAlongSMA→ MAlongBullishCrossover→ BullishstartstartvaluefinishfinishvalueProfit_TicksProfit_TicksvalueLoss_TicksLoss_Ticksvaluelongsignallongsignalconditionentry:Entry 1Open Entry 1strategy.entryentry:Entry 2Open Entry 2strategy.entryentry:Entry 3Open Entry 3strategy.entryentry:Entry 4Open Entry 4strategy.entryentry:Entry 5Open Entry 5strategy.entryentry:Entry 6Open Entry 6strategy.entryentry:Entry 7Open Entry 7strategy.entryexit:Exit 1exit Exit 1strategy.exitexit:Exit 2exit Exit 2strategy.exitexit:Exit 3exit Exit 3strategy.exitexit:Exit 4exit Exit 4strategy.exitexit:Exit 5exit Exit 5strategy.exitexit:Exit 6exit Exit 6strategy.exitexit:Exit 7exit Exit 7strategy.exit

Order rules

OrderFires whenBy defaultLine
Open Entry 1 long(strategy.opentrades == 0) and longsignalOn50
Open Entry 2 long(strategy.opentrades == 1) and longsignalOn52
Open Entry 3 long(strategy.opentrades == 2) and longsignalOn54
Open Entry 4 long(strategy.opentrades == 3) and longsignalOn56
Open Entry 5 long(strategy.opentrades == 4) and longsignalOn58
Open Entry 6 long(strategy.opentrades == 5) and longsignalOn60
Open Entry 7 long(strategy.opentrades == 6) and longsignalOn62
Exit Exit 1 stop and limit(strategy.position_size > 0)On67
Exit Exit 2 stop and limit(strategy.position_size > 0)On68
Exit Exit 3 stop and limit(strategy.position_size > 0)On69
Exit Exit 4 stop and limit(strategy.position_size > 0)On70
Exit Exit 5 stop and limit(strategy.position_size > 0)On71
Exit Exit 6 stop and limit(strategy.position_size > 0)On72
Exit Exit 7 stop and limit(strategy.position_size > 0)On73

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.

9/9trades 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 calc_on_every_tick. 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+2.3%+102.5%2065%1.502.2%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−2.1%+5.5%1644%0.514.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.2%+9.8%1953%1.033.4%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−1.6%+8.4%1443%0.642.3%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+5.5%+16.7%1486%4.341.3%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+1.8%+21.5%2075%1.565.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.9%+148.3%1547%0.823.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−2.0%+17.1%922%0.363.7%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 market863%$8.63
Sideways market1267%$14.05
Falling market0—$0.00

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

How bad could the drawdown be?

2.7%

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

0%3%
All 20 trades
SideEntryExitBarsP&L
long7 Oct 2024 62,819.909 Oct 2024 60,955.102−$6.33
long9 Oct 2024 62,160.5010 Oct 2024 60,341.401−$6.23
long12 Oct 2024 62,540.0014 Oct 2024 64,426.102$5.55
long25 Oct 2024 68,198.3028 Oct 2024 70,062.403$5.03
long28 Oct 2024 68,021.7028 Oct 2024 70,062.400$0.01
long28 Oct 2024 68,021.7028 Oct 2024 70,238.900$6.05
long7 Nov 2024 75,572.0010 Nov 2024 77,872.303$5.70
long7 May 2025 96,834.008 May 2025 99,744.901$5.66
long19 May 2025 106,454.0021 May 2025 109,660.002$5.70
long8 Jun 2025 105,552.009 Jun 2025 108,724.001$5.72
long24 Jun 2025 105,334.0030 Jun 2025 108,585.006$5.92
long21 Apr 2026 75,841.0022 Apr 2026 78,131.101$5.82
long2 May 2026 78,231.104 May 2026 80,588.202$5.84
long15 May 2026 81,090.0016 May 2026 78,716.601−$6.53
long26 May 2026 77,322.0027 May 2026 75,044.101−$6.52
long1 Sep 2026 78,581.303 Sep 2026 80,901.502$5.67
long4 Sep 2026 81,270.407 Sep 2026 78,860.103−$6.56
long15 Sep 2026 78,189.2016 Sep 2026 75,644.501−$7.11
long19 Sep 2026 80,883.9021 Sep 2026 83,319.202$5.75
long2 Oct 2026 84,880.108 Oct 2026 82,380.406−$6.47

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
Pyramiding Entries On Early Trends (by Coinrule) this page—v3 strategy+2.3%202.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%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 15 msYes 1,000 bars in 43 msNot measured
PineTSNo v5 and v6 only—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. PineTS runs Pine Script v5 and v6 only.

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/    // © Coinrule    //@version=3strategy(shorttitle='Pyramiding Entry On Early Trends',title='Pyramiding Entry On Early Trends (by Coinrule)', overlay=false, pyramiding= 7, initial_capital = 1000, default_qty_type = strategy.percent_of_equity, default_qty_value = 20, commission_type=strategy.commission.percent, commission_value=0.1)        //Backtest datesfromMonth = input(defval = 1,  title = "From Month")     fromDay   = input(defval = 10,    title = "From Day")       fromYear  = input(defval = 2020, title = "From Year")       thruMonth = input(defval = 1,    title = "Thru Month")     thruDay   = input(defval = 1,    title = "Thru Day")     thruYear  = input(defval = 2112, title = "Thru Year")           showDate  = input(defval = true, title = "Show Date Range")    start     = timestamp(fromYear, fromMonth, fromDay, 00, 00)        // backtest start windowfinish    = timestamp(thruYear, thruMonth, thruDay, 23, 59)        // backtest finish windowwindow()  => time >= start and time <= finish ? true : false       // create function "within window of time"        //MA inputs and calculationsinSignal=input(9, title='MAfast')inlong1=input(100, title='MAslow')inlong2=input(200, title='MAlong')    MAfast= sma(close, inSignal)MAslow= sma(close, inlong1)MAlong= sma(close, inlong2)        Bullish = crossover(close, MAfast)     longsignal = (Bullish and MAfast > MAslow and MAslow < MAlong and window())    //set take profit    ProfitTarget_Percent = input(3)Profit_Ticks = (close * (ProfitTarget_Percent / 100)) / syminfo.mintick    //set take profit    LossTarget_Percent = input(3)Loss_Ticks = (close * (LossTarget_Percent / 100)) / syminfo.mintick        //Order Placing    strategy.entry("Entry 1", strategy.long, when = (strategy.opentrades == 0) and longsignal)    strategy.entry("Entry 2", strategy.long, when = (strategy.opentrades == 1) and longsignal)        strategy.entry("Entry 3", strategy.long, when = (strategy.opentrades == 2) and longsignal)    strategy.entry("Entry 4", strategy.long, when = (strategy.opentrades == 3) and longsignal)    strategy.entry("Entry 5", strategy.long, when = (strategy.opentrades == 4) and longsignal)        strategy.entry("Entry 6", strategy.long, when = (strategy.opentrades == 5) and longsignal)        strategy.entry("Entry 7", strategy.long, when = (strategy.opentrades == 6) and longsignal)            if (strategy.position_size > 0)    strategy.exit(id="Exit 1", from_entry = "Entry 1", profit = Profit_Ticks, loss = Loss_Ticks)    strategy.exit(id="Exit 2", from_entry = "Entry 2", profit = Profit_Ticks, loss = Loss_Ticks)    strategy.exit(id="Exit 3", from_entry = "Entry 3", profit = Profit_Ticks, loss = Loss_Ticks)    strategy.exit(id="Exit 4", from_entry = "Entry 4", profit = Profit_Ticks, loss = Loss_Ticks)    strategy.exit(id="Exit 5", from_entry = "Entry 5", profit = Profit_Ticks, loss = Loss_Ticks)    strategy.exit(id="Exit 6", from_entry = "Entry 6", profit = Profit_Ticks, loss = Loss_Ticks)    strategy.exit(id="Exit 7", from_entry = "Entry 7", profit = Profit_Ticks, loss = Loss_Ticks)