An alternative to Pine Script

Tuned Script is an in-house scripting language developed to write trading strategies. It is powered by Groovy with a custom API and standard library to easily transform data and generate signals. The core unit of data in a Tuned script is a Series. It represents a contiguous series of data derived from market data. 

Data Flow 

Tuned Script gets candle data from the exchange, which is then executed by the script to generate buy and sell signals and passed to the execution engine. This handles the order placement on the exchange. You can visit our Getting Started guide to get a basic script idea and understand how the data sources work. It contains information on operator functions, comparator functions and a lot more. 

We also have an early pine implementation, in alpha. You can visit Tuned Pine Reference (ALPHA) to get a glimpse of what we offer here. Pine script is an official language to write scripts and indicators on Tradingview.

Why two different languages ?

Tuned Script originally launched with the platform. However, as Tuned matured, and more traders joined, we saw a demand for Pine Script. It’s a language traders were already familiar with.

Generally speaking, a trader can get the same functionality out of Pine Script or Tuned Script. The difference lies in what you are familiar with. For anyone new to automated trading, we believe Tuned Script has a lower barrier to entry and more utility, relative to our current Pine Script implementation.

Example of Pine Script (RSI)

study(title="Relative Strength Index")

len = input(14, minval=1, title="Length")
src = input(close, "Source", type = input.source)

up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))

plot(rsi, "RSI", color=#8E1599)
band1 = hline(70, "Upper Band", color=#C0C0C0)
bandm = hline(50, "Middle Band",, 50))
band0 = hline(30, "Lower Band", color=#C0C0C0)
fill(band1, band0, color=#9915FF, transp=90, title="Background")

Example of Tuned Script (RSI)

len = intInput("Length", 14)
src = srcInput("Source for RSI", "Source", "close")

//Define RMA function
def rma(src, len) {
def alpha = (1.0 / seriesOf(len))
def sum1 = ref(0.0)
sum1.set(alpha * src + (1 - alpha) * nz(sum1[1]))
return sum1

//Calculate RSI
up = rma(max(change(src, 1), seriesOf(0.0)), len)
down = rma((min(change(src, 1), seriesOf(0.0)) * -1.0), len)
rsi = iff(eq(down, seriesOf(0.0)), seriesOf(100.0),
iff(eq(up, seriesOf(0.0)), seriesOf(0.0), seriesOf(100.0) - (100 / (1 + up / down))))

plot(rsi, "rsi", "#8E1599", 1, PlotStyle.LINE, 0, false)
band1 = plot(seriesOf(70.0), "Upper Band", "#C0C0C0", 1, PlotStyle.LINE, 0, false)
bandm = plot(seriesOf(50.0), "Middle Band", "#C0C0C0", 1, PlotStyle.LINE, 0, false)
band0 = plot(seriesOf(30.0), "Lower Band", "#C0C0C0", 1, PlotStyle.LINE, 0, false)
fill(band1, band0, "#9915FF", 90, "Background", false)

//Signal Push

Executing Orders

In order to generate signals to place orders on exchanges, both languages use a different syntax. In Tuned script we use:

signals = signalIf(executeBuy, executeSell)

Signals are generated by using signalIf method with executeBuy and executeSell as the buy and sell conditions respectively.

In Pine Script, the strategy.* function is used with variations like:

strategy.order() in order to place an order

strategy.close() and strategy.close_all() in order to close open  positions.

PlottingVisualizing a Strategy

While a machine may know how to execute an automated strategy, displaying this information doesn’t come naturally. That is why a trader may also want a visual representation of what’s going on. This function is accomplished using plot() in both tuned and pine script. Plots can be used to set the color of the plotted candles, either statically or dynamically based on a calculation. Other common use cases include: setting a chart’s background color, defining an area between two h lines or two plots to be filled, or displaying shapes, characters and arrows.

Some of plot functions are :
plotarrow() Plots arrows on the charts. plotchar() Plots visual shapes using any given one Unicode character on the chart and plotshape() Plots visual shapes on the chart.

Please visit below links to know more about both the scripting languages

Tuned Script Documentation

Pine Script Documentation

Disclaimer: The opinions expressed here are for general informational purposes only and are not intended to provide specific advice or recommendations for any specific security or investment product. You should never invest money that you cannot afford to lose. Before trading using complex financial products, please ensure to understand the risks involved. Past performance is no guarantee of future results.

Supercharge your trading

Sign up to receive updates and access trading strategies developed by quantitative traders.

Get Started