Skip to main content
Version: 1.0.0

Custom Indicators

Custom indicators help you take advantage of Pluto's platform features like:

  • Drawing your indicator on backtest charts
  • Performance optimizations
  • Historical data fetching and consistency

There are two ways to create custom indicators, the name of your method determines which one you are using. "Compute latest" and "Compute all".

compute_latest​

def compute_latest(last_value: float, bars: List[Bar], data) -> float

Using this method your indicator will calculate every point one by one. Compute latest is the easiest and most common way to create a custom indicator.

You can use other indicators as inputs to your custom indicator.

# sin of the last close
def compute_latest(last_value: float, bars: List[Bar], data) -> float:
import math
return math.sin(bars[0].close)

# simple moving average
def compute_latest(last_value: float, bars: List[Bar], data) -> float:
return sum([bar.close for bar in bars]) / len(bars)

# simple ewo using EMAs as inputs
def compute_latest(last_value: float, bars: List[Bar], data) -> float:
return data.EMA(ln=5) - data.EMA(ln=34)

compute_all​

def compute_latest(values: List[float]) -> List[float]

If you only need the close prices of each bar — you can use the compute_all method which is slightly faster. Note: This method is only available for indicators that do not use any inputs.

You have to return a list of floats with the exact same length as the values list.

# last price plus standard deviation
def compute_all(values: List[float]) -> List[float]:
import numpy as np
std = np.std(values)
return values + std