BullScript™ and Pine Script

Changed

If you already write Pine Script, you can read a BullScript™ script. Many of the calls are the same. BullScript™ is Bullmania's own compiler and runtime.

Bullmania is not affiliated with, endorsed or sponsored by TradingView. Pine Script and TradingView are trademarks of TradingView, Inc.

A script you already wrote may still need a change. This page does not claim that most scripts run unmodified.

What is the same, and what differs#

BullScript™Pine Script
Indicator headerindicator("Name", overlay=true)The same call
Inputsinput.int, input.float, input.bool, input.string, input.sourceThe same calls
Moving averageta.sma(close, 20) and ta.ema(close, 20)The same calls
Plot, colours, backgroundplot, plotshape, bgcolor, color.newThe same calls
Alerts in a scriptalertcondition and alertThe same calls
Strategystrategy, strategy.entry, strategy.closeThe same calls
Bars ahead of the last closeA fixed offset, and xloc.bar_time for a future timeThe same calls
Old headerstudy() does not runstudy() is the old header
Librariesimport User/Lib/1 is not available on a chart scriptA script can import a library
Version lineOptional. //@version=5 and //@version=6 both run with indicator()A script usually starts with //@version

Indicator header#

This is how it looks in BullScript™.

bullscript-run
//@version=6
indicator("Close", overlay=true)
plot(close)

This is how it looks in Pine Script.

text
//@version=6
indicator("Close", overlay=true)
plot(close)

overlay=true draws on the price. overlay=false puts the script in its own pane.

//@version=5 and //@version=6 both run when the script uses indicator(). //@version=4 also runs with indicator(). study() does not run. The message is unknown function 'study'. You do not have to include a version line. A different version number is fine when the rest of the script is accepted.

bullscript-run
//@version=5
indicator("Version 5", overlay=true)
plot(close)

Inputs#

A setting you can change on the chart is an input. The title is the label you see.

This is how it looks in BullScript™.

bullscript-run
1//@version=6
2indicator("Length", overlay=true)
3length = input.int(20, "Length", minval=1)
4plot(ta.sma(close, length))

This is how it looks in Pine Script.

text
1//@version=6
2indicator("Length", overlay=true)
3length = input.int(20, "Length", minval=1)
4plot(ta.sma(close, length))

The same family includes input.float, input.bool, input.string, and input.source.

A moving average#

This is how it looks in BullScript™.

bullscript-run
1//@version=6
2indicator("Average", overlay=true)
3plot(ta.sma(close, 20), "SMA 20")
4plot(ta.ema(close, 20), "EMA 20")

This is how it looks in Pine Script.

text
1//@version=6
2indicator("Average", overlay=true)
3plot(ta.sma(close, 20), "SMA 20")
4plot(ta.ema(close, 20), "EMA 20")

The first bars of a moving average can be empty, until there are enough bars to calculate it.

Plotting#

plot draws a line. plotshape draws a mark when a condition is true.

This is how it looks in BullScript™.

bullscript-run
1//@version=6
2indicator("Cross", overlay=true)
3basis = ta.sma(close, 20)
4plot(basis, "Basis", color=color.orange)
5plotshape(ta.crossover(close, basis), "Cross up", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.tiny)

This is how it looks in Pine Script.

text
1//@version=6
2indicator("Cross", overlay=true)
3basis = ta.sma(close, 20)
4plot(basis, "Basis", color=color.orange)
5plotshape(ta.crossover(close, basis), "Cross up", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.tiny)

Colours and backgrounds#

color.new sets how see-through a colour is. bgcolor fills the pane from top to bottom for that bar. It does not move the price scale.

This is how it looks in BullScript™.

bullscript-run
1//@version=6
2indicator("Colours", overlay=true)
3up = close >= open
4bgcolor(up ? color.new(color.green, 90) : color.new(color.red, 90))
5plot(close, "Close", color=up ? color.green : color.red)

This is how it looks in Pine Script.

text
1//@version=6
2indicator("Colours", overlay=true)
3up = close >= open
4bgcolor(up ? color.new(color.green, 90) : color.new(color.red, 90))
5plot(close, "Close", color=up ? color.green : color.red)

Alerts#

You can write alertcondition and alert in the script. The call looks the same in both languages. An alert you create with the alert button on the chart is a separate step.

This is how it looks in BullScript™.

bullscript-run
1//@version=6
2indicator("Alerts", overlay=true)
3bull = ta.crossover(close, ta.sma(close, 10))
4alertcondition(bull, "Cross up", "Price crossed the average")
5if bull
6 alert("Price crossed the average", alert.freq_once_per_bar_close)
7plot(close)

This is how it looks in Pine Script.

text
1//@version=6
2indicator("Alerts", overlay=true)
3bull = ta.crossover(close, ta.sma(close, 10))
4alertcondition(bull, "Cross up", "Price crossed the average")
5if bull
6 alert("Price crossed the average", alert.freq_once_per_bar_close)
7plot(close)

Strategies#

A strategy uses strategy() instead of indicator(). Orders fill from the script. On Bullmania you run it from the Backtests tab, or ask a connected app to run it.

This is how it looks in BullScript™.

bullscript-run
1//@version=6
2strategy("Cross", overlay=true)
3if ta.crossover(close, ta.sma(close, 10))
4 strategy.entry("Long", strategy.long)
5if ta.crossunder(close, ta.sma(close, 10))
6 strategy.close("Long")
7plot(close)

This is how it looks in Pine Script.

text
1//@version=6
2strategy("Cross", overlay=true)
3if ta.crossover(close, ta.sma(close, 10))
4 strategy.entry("Long", strategy.long)
5if ta.crossunder(close, ta.sma(close, 10))
6 strategy.close("Long")
7plot(close)

Each strategy name that runs here has its own page, starting at strategy.

Drawing in the future#

You can colour bars that have not printed yet, and you can put a line on a time that is still ahead. Use a fixed number of bars, not a number that changes. The rules are on Future dates.

This is how it looks in BullScript™.

bullscript-run
1//@version=6
2indicator("Zones", overlay=true)
3AHEAD = 30
4barMs = timeframe.in_seconds(timeframe.period) * 1000
5zone(t) => t >= timestamp("UTC", 2027, 2, 1, 0, 0) and t < timestamp("UTC", 2028, 4, 15, 0, 0) ? color.new(color.gray, 75) : na
6bgcolor(zone(time), title="Zone")
7bgcolor(bar_index + AHEAD > last_bar_index ? zone(time + AHEAD * barMs) : na, offset=AHEAD, title="Zone ahead")
8plot(close)

This is how it looks in Pine Script.

text
1//@version=6
2indicator("Zones", overlay=true)
3AHEAD = 30
4barMs = timeframe.in_seconds(timeframe.period) * 1000
5zone(t) => t >= timestamp("UTC", 2027, 2, 1, 0, 0) and t < timestamp("UTC", 2028, 4, 15, 0, 0) ? color.new(color.gray, 75) : na
6bgcolor(zone(time), title="Zone")
7bgcolor(bar_index + AHEAD > last_bar_index ? zone(time + AHEAD * barMs) : na, offset=AHEAD, title="Zone ahead")
8plot(close)

line.new, label.new, box.new, and polyline.new can take xloc = xloc.bar_time and a time in the future.

Where a script stops#

study("Name") does not run. Start with indicator() or strategy().

import User/Lib/1 does not run on a chart script or from a connected app. The message says the library is not available. More of these cases are on Differences from Pine Script.