BullScript™ and Pine Script
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 header | indicator("Name", overlay=true) | The same call |
| Inputs | input.int, input.float, input.bool, input.string, input.source | The same calls |
| Moving average | ta.sma(close, 20) and ta.ema(close, 20) | The same calls |
| Plot, colours, background | plot, plotshape, bgcolor, color.new | The same calls |
| Alerts in a script | alertcondition and alert | The same calls |
| Strategy | strategy, strategy.entry, strategy.close | The same calls |
| Bars ahead of the last close | A fixed offset, and xloc.bar_time for a future time | The same calls |
| Old header | study() does not run | study() is the old header |
| Libraries | import User/Lib/1 is not available on a chart script | A script can import a library |
| Version line | Optional. //@version=5 and //@version=6 both run with indicator() | A script usually starts with //@version |
Indicator header#
This is how it looks in BullScript™.
//@version=6indicator("Close", overlay=true)plot(close)
This is how it looks in Pine Script.
//@version=6indicator("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.
//@version=5indicator("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™.
1//@version=62indicator("Length", overlay=true)3length = input.int(20, "Length", minval=1)4plot(ta.sma(close, length))
This is how it looks in Pine Script.
1//@version=62indicator("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™.
1//@version=62indicator("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.
1//@version=62indicator("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™.
1//@version=62indicator("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.
1//@version=62indicator("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™.
1//@version=62indicator("Colours", overlay=true)3up = close >= open4bgcolor(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.
1//@version=62indicator("Colours", overlay=true)3up = close >= open4bgcolor(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™.
1//@version=62indicator("Alerts", overlay=true)3bull = ta.crossover(close, ta.sma(close, 10))4alertcondition(bull, "Cross up", "Price crossed the average")5if bull6 alert("Price crossed the average", alert.freq_once_per_bar_close)7plot(close)
This is how it looks in Pine Script.
1//@version=62indicator("Alerts", overlay=true)3bull = ta.crossover(close, ta.sma(close, 10))4alertcondition(bull, "Cross up", "Price crossed the average")5if bull6 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™.
1//@version=62strategy("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.
1//@version=62strategy("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™.
1//@version=62indicator("Zones", overlay=true)3AHEAD = 304barMs = timeframe.in_seconds(timeframe.period) * 10005zone(t) => t >= timestamp("UTC", 2027, 2, 1, 0, 0) and t < timestamp("UTC", 2028, 4, 15, 0, 0) ? color.new(color.gray, 75) : na6bgcolor(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.
1//@version=62indicator("Zones", overlay=true)3AHEAD = 304barMs = timeframe.in_seconds(timeframe.period) * 10005zone(t) => t >= timestamp("UTC", 2027, 2, 1, 0, 0) and t < timestamp("UTC", 2028, 4, 15, 0, 0) ? color.new(color.gray, 75) : na6bgcolor(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.