1. Home
  2. Docs
  3. Knowledge Base
  4. TALib Indicators
  5. Introduction

Introduction

TALib (Technical Analysis Library) Indicators can be seamlessly integrated and utilized in MachinaTrader for developing and enhancing trading strategies. Whether you prefer writing code in the built-in script editor or utilizing the visual Python nodes in the editor, MachinaTrader empowers you with the capability to leverage a wide range of TALib indicators. These indicators provide you with valuable insights and analysis tools, allowing you to make more informed trading decisions. With MachinaTrader, you have the flexibility to incorporate both standard and custom TALib indicators into your unique trading strategies, offering a powerful and adaptable environment for your trading endeavors. Please check the below sample for how to incorporate TALib indicators and a complete list of builtin indicators. Find more information about TALib here: TA-Lib – Technical Analysis Library

Example:

class Calcs:
    def __init__(self, candles):
        self.onCalculate(candles)

    def onCalculate(self, candles):
        self.IDX = len(candles.T) - 1

        # Calculate Simple Moving Averages (SMAs) based on user-defined parameters
        self.smaFast = talib.func.SMA(candles.C, _mt.getParameter(SMA_FAST))
        self.smaSlow = talib.func.SMA(candles.C, _mt.getParameter(SMA_SLOW))

        # Check for cross over and cross under events between SMAs
        self.crossOver = _mt.crossOver(self.smaFast, self.smaSlow)
        self.crossUnder = _mt.crossUnder(self.smaFast, self.smaSlow)

    def hasCrossedOver(self):
        # Return the most recent cross over event
        return self.crossOver[len(self.crossOver) - 1]

    def hasCrossedUnder(self):
        # Return the most recent cross under event
        return self.crossUnder[len(self.crossUnder) - 1]

How can we help?