Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

pomila

A Pine Script v4 strategy built on SMA (tr, 10), ATR (10) and Barssince (buySignal). It has 2 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 13 settings; defaults include ATR Period 10, Source hl2 and ATR Multiplier 3.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 pomila 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 pomila do on BTCUSDT 1D with default settings?
−54.63%
From 26 Jan 2024 to 21 Oct 2026, over 25 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can pomila be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
Does pomila use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does pomila run in Zeal Terminal?
Yes
It compiles in 24 ms and runs 1,000 bars in 68 ms, in the browser.

BTCUSDT · 1D · default settings

  • Up Trend
  • UpTrend Begins
  • Down Trend
  • DownTrend Begins
  • 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 (13)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$63,518$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
−54.63%
−$54,630.60
Buy and hold
+102.5%
same period
Closed trades
25
7 won · 18 lost
Profitable
28.0%
of closed trades
Profit factor
0.61
gross profit ÷ gross loss
Max drawdown
86.58%
−$86,582.10

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

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

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

  • Note

    Uses an argument v6 removed

    when = on line 47, 50. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 25

    transp = on line 25, 26, 29, 30. v5 folds the transparency into the colour with color.new(c, transp).

Upgrade and export

Written in Pine Script v4. The upgrade to v5 takes 1 step, 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, atr → ta.atr, max → math.max, min → math.min, barssince → ta.barssince.
  • 2 strategy calls use the when = argument (line 47, 50). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 5: input(type = input.integer) → input.int()
  • Line 7: input(type = input.float) → input.float()
  • Line 8: input(type = input.bool) → input.bool()
  • Line 9: input(type = input.bool) → input.bool()
  • Line 10: input(type = input.bool) → input.bool()
12 more edits
  • Line 11: input(type = input.bool) → input.bool()
  • Line 12: sma → ta.sma
  • Line 12: tr → ta.tr
  • Line 13: atr → ta.atr
  • Line 16: max → math.max
  • Line 19: min → math.min
  • Line 25: transp = 0 → color.new(color.green, 0)
  • Line 26: transp = 0 → color.new(color.green, 0)
  • Line 29: transp = 0 → color.new(color.red, 0)
  • Line 30: transp = 0 → color.new(color.red, 0)
  • Line 51: barssince → ta.barssince
  • Line 52: barssince → ta.barssince
⋯// © KivancOzbilgic-//@version=4+//@version=5strategy("pomila", overlay=true)-Periods = input(title="ATR Period", type=input.integer, defval=10)+Periods = input.int(title="ATR Period", defval=10)src = input(hl2, title="Source")-Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)+Multiplier = input.float(title="ATR Multiplier", step=0.1, defval=3.0)-changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)+changeATR= input.bool(title="Change ATR Calculation Method ?", defval=true)-showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=false)+showsignals = input.bool(title="Show Buy/Sell Signals ?", defval=false)-highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)+highlighting = input.bool(title="Highlighter On/Off ?", defval=true)-barcoloring = input(title="Bar Coloring On/Off ?", type=input.bool, defval=true)+barcoloring = input.bool(title="Bar Coloring On/Off ?", defval=true)-atr2 = sma(tr, Periods)+atr2 = ta.sma(ta.tr, Periods)-atr= changeATR ? atr(Periods) : atr2+atr= changeATR ? ta.atr(Periods) : atr2up=src-(Multiplier*atr)up1 = nz(up[1],up)-up := close[1] > up1 ? max(up,up1) : up+up := close[1] > up1 ? math.max(up,up1) : updn=src+(Multiplier*atr)dn1 = nz(dn[1], dn)-dn := close[1] < dn1 ? min(dn, dn1) : dn+dn := close[1] < dn1 ? math.min(dn, dn1) : dntrend = 1⋯buySignal = trend == 1 and trend[1] == -1-plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0)+plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.green, 0))-plotshape(buySignal and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)+plotshape(buySignal and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.green, 0), textcolor=color.white)dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red)sellSignal = trend == -1 and trend[1] == 1-plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0)+plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.red, 0))-plotshape(sellSignal and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)+plotshape(sellSignal and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 0), textcolor=color.white)mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)⋯    strategy.entry("SELL", strategy.short, when = window())-buy1= barssince(buySignal)+buy1= ta.barssince(buySignal)-sell1 = barssince(sellSignal)+sell1 = ta.barssince(sellSignal)color1 = buy1[1] < sell1[1] ? color.green : buy1[1] > sell1[1] ? color.red : na⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 6: input() → input.source()
  • Line 36: input() → input.int()
  • Line 37: input() → input.int()
  • Line 38: input() → input.int()
  • Line 39: input() → input.int()
  • Line 40: input() → input.int()
3 more edits
  • Line 41: input() → input.int()
  • Line 47: when = window() → if block
  • Line 50: when = window() → if block
⋯Periods = input.int(title="ATR Period", defval=10)-src = input(hl2, title="Source")+src = input.source(hl2, title="Source")Multiplier = input.float(title="ATR Multiplier", step=0.1, defval=3.0)⋯fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor)-FromMonth = input(defval = 9, title = "From Month", minval = 1, maxval = 12)+FromMonth = input.int(defval = 9, title = "From Month", minval = 1, maxval = 12)-FromDay   = input(defval = 1, title = "From Day", minval = 1, maxval = 31)+FromDay   = input.int(defval = 1, title = "From Day", minval = 1, maxval = 31)-FromYear  = input(defval = 2018, title = "From Year", minval = 999)+FromYear  = input.int(defval = 2018, title = "From Year", minval = 999)-ToMonth   = input(defval = 1, title = "To Month", minval = 1, maxval = 12)+ToMonth   = input.int(defval = 1, title = "To Month", minval = 1, maxval = 12)-ToDay     = input(defval = 1, title = "To Day", minval = 1, maxval = 31)+ToDay     = input.int(defval = 1, title = "To Day", minval = 1, maxval = 31)-ToYear    = input(defval = 9999, title = "To Year", minval = 999)+ToYear    = input.int(defval = 9999, title = "To Year", minval = 999)start     = timestamp(FromYear, FromMonth, FromDay, 00, 00)  ⋯if (longCondition)-    strategy.entry("BUY", strategy.long, when = window())+    if window()+        strategy.entry("BUY", strategy.long)shortCondition = sellSignalif (shortCondition)-    strategy.entry("SELL", strategy.short, when = window())+    if window()+        strategy.entry("SELL", strategy.short)buy1= ta.barssince(buySignal)⋯

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L31:C56: 'linewidth' must be at least 1 in Pine Script v6. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © KivancOzbilgic-//@version=5+//@version=6strategy("pomila", overlay=true)⋯

Settings

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

SettingDefaultType and rangeFeeds
ATR Period10int (written input.integer)atr2 atr
Sourcehl2sourceup dn
ATR Multiplier3.0float · step 0.1up dn
Change ATR Calculation Method ?trueboolatr
Show Buy/Sell Signals ?falseboolBuy Sell
Highlighter On/Off ?trueboollongFillColor shortFillColor
Bar Coloring On/Off ?trueboolbarcolor
From Month9int · min 1 · max 12start
From Day1int · min 1 · max 31start
From Year2018int · min 999start
To Month1int · min 1 · max 12finish
To Day1int · min 1 · max 31finish
To Year9999int · min 999finish

What it calculates

  • SMA (sma, ta.sma in v5)tr, ATR Period (10)atr2 · line 12
  • ATR (atr, ta.atr in v5)ATR Period (10)atr · line 13
  • Barssince (barssince, ta.barssince in v5)buySignalbuy1 · line 51
  • Barssince (barssince, ta.barssince in v5)sellSignalsell1 · line 52

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.

PeriodsATR Periodsetting · 10high · low · closehigh · low · closeprice dataclosecloseprice datahl2hl2price dataMultiplierATR Multipliersetting · 3.0FromYearFrom Yearsetting · 2018FromMonthFrom Monthsetting · 9FromDayFrom Daysetting · 1ToYearTo Yearsetting · 9999ToMonthTo Monthsetting · 1ToDayTo Daysetting · 1ohlc4ohlc4price dataatr2SMA→ atr2atrATR→ atrbuy1Barssince→ buy1sell1Barssince→ sell1upupvalueup1up1valuedndnvaluedn1dn1valuetrendtrendvaluestartstartvaluefinishfinishvaluelongConditionlongConditionvalueshortConditionshortConditionvaluebuySignal, sellSignalbuySignal · sellSignal2 conditionslongFillColor, shortFillColor, color1ColourlongFillColor · shortFillColo…entry:BUYOpen BUYstrategy.entryentry:SELLOpen SELLstrategy.entryplot:23Up Trendplotplotshape:25UpTrend Beginsplotshapeplotshape:26Buyplotshapeplot:27Down Trendplotplotshape:29DownTrend Beginsplotshapeplotshape:30Sellplotshapeplot:31plotfill:UpTrend HighligterUpTrend Highligterfillfill:DownTrend HighligterDownTrend Highligterfillbarcolor:54barcolorbarcolor

Order rules

OrderFires whenBy defaultLine
Open BUY longwindow()On47
Open SELL shortwindow()On50

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−54.6%+102.5%2528%0.6186.6%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+5.5%+5.5%2339%1.1913.1%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−0.0%+9.8%2241%1.002.7%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.1%+8.4%2330%1.080.7%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.1%+16.7%2241%1.420.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%2335%1.300.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.6%+148.3%2631%0.541.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.0%+17.1%2335%1.030.1%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 market617%−$47,537.00
Sideways market1331%$12,702.10
Falling market633%−$19,795.70

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

How bad could the drawdown be?

86.3%

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

0%99%
All 25 trades
SideEntryExitBarsP&L
short20 Mar 2024 61,937.4021 May 2024 71,446.6062−$9,509.21
long21 May 2024 71,446.6022 Jun 2024 64,143.6032−$7,303.06
short22 Jun 2024 64,143.6016 Jul 2024 64,724.1024−$580.50
long16 Jul 2024 64,724.104 Aug 2024 60,698.0019−$4,026.07
short4 Aug 2024 60,698.0024 Aug 2024 64,037.2020−$3,339.25
long24 Aug 2024 64,037.206 Sep 2024 56,180.0013−$7,857.24
short6 Sep 2024 56,180.0020 Sep 2024 62,948.0014−$6,768.00
long20 Sep 2024 62,948.0024 Dec 2024 94,881.5095$31,933.50
short24 Dec 2024 94,881.5018 Jan 2025 104,077.0025−$9,196.00
long18 Jan 2025 104,077.0025 Feb 2025 91,552.9038−$12,524.60
short25 Feb 2025 91,552.903 Mar 2025 94,270.006−$2,717.11
long3 Mar 2025 94,270.0011 Mar 2025 78,595.908−$15,674.10
short11 Mar 2025 78,595.9023 Apr 2025 93,443.0043−$14,847.10
long23 Apr 2025 93,443.0023 Jun 2025 100,964.0061$7,520.88
short23 Jun 2025 100,964.0010 Jul 2025 111,234.0017−$10,270.10
long10 Jul 2025 111,234.0022 Aug 2025 112,500.0043$1,266.00
short22 Aug 2025 112,500.002 Oct 2025 118,595.0041−$6,094.99
long2 Oct 2025 118,595.0011 Oct 2025 112,774.009−$5,820.50
short11 Oct 2025 112,774.0014 Jan 2026 95,414.0095$17,360.50
long14 Jan 2026 95,414.0021 Jan 2026 88,427.707−$6,986.33
short21 Jan 2026 88,427.705 Mar 2026 72,666.8043$15,760.90
long5 Mar 2026 72,666.8030 Mar 2026 66,010.9025−$6,655.84
short30 Mar 2026 66,010.9014 Apr 2026 74,418.0015−$8,407.07
long14 Apr 2026 74,418.0023 May 2026 75,539.5039$1,121.50
short23 May 2026 75,539.5022 Jul 2026 66,556.1060$8,983.35

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
pomila this page—v4 strategy−54.6%2586.6%
Trenbolone Strategy by LeSifsma atr barssincev4 strategy−54.6%2586.6%
Dazzling Bolts by OrcChieftainsma atr barssincev4 strategy+8.5%1413.0%
I11L - Better Buy Low Volatility or High Volatility- by I11Latr smav5 strategy+19.2%8337.4%
Last Price minus Open Price Intraday Volume by avsr90barssince smav5 strategyNo trades on this market
Vortex Cross w-MA Confirmation by DraftVentureatr smav5 strategy+2.4%524.7%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 24 msYes 1,000 bars in 68 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/// © KivancOzbilgic//@version=4strategy("pomila", overlay=true)Periods = input(title="ATR Period", type=input.integer, defval=10)src = input(hl2, title="Source")Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=false)highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)barcoloring = input(title="Bar Coloring On/Off ?", type=input.bool, defval=true)atr2 = sma(tr, Periods)atr= changeATR ? atr(Periods) : atr2up=src-(Multiplier*atr)up1 = nz(up[1],up)up := close[1] > up1 ? max(up,up1) : updn=src+(Multiplier*atr)dn1 = nz(dn[1], dn)dn := close[1] < dn1 ? min(dn, dn1) : dntrend = 1trend := nz(trend[1], trend)trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trendupPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green)buySignal = trend == 1 and trend[1] == -1plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0)plotshape(buySignal and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red)sellSignal = trend == -1 and trend[1] == 1plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0)plotshape(sellSignal and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.whiteshortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.whitefill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor)fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor)FromMonth = input(defval = 9, title = "From Month", minval = 1, maxval = 12)FromDay   = input(defval = 1, title = "From Day", minval = 1, maxval = 31)FromYear  = input(defval = 2018, title = "From Year", minval = 999)ToMonth   = input(defval = 1, title = "To Month", minval = 1, maxval = 12)ToDay     = input(defval = 1, title = "To Day", minval = 1, maxval = 31)ToYear    = input(defval = 9999, title = "To Year", minval = 999)start     = timestamp(FromYear, FromMonth, FromDay, 00, 00)  finish    = timestamp(ToYear, ToMonth, ToDay, 23, 59)       window()  => time >= start and time <= finish ? true : falselongCondition = buySignalif (longCondition)    strategy.entry("BUY", strategy.long, when = window())shortCondition = sellSignalif (shortCondition)    strategy.entry("SELL", strategy.short, when = window())buy1= barssince(buySignal)sell1 = barssince(sellSignal)color1 = buy1[1] < sell1[1] ? color.green : buy1[1] > sell1[1] ? color.red : nabarcolor(barcoloring ? color1 : na)