1. Home
  2. Docs
  3. Knowledge Base
  4. MT Basics
  5. Algorithm Execution Logic

Algorithm Execution Logic

General Approach

Trading strategies on MachinaTrader follow a systematic approach to analyze market data and generate buy and sell signals. Strategies can incorporate a wide range of technical indicators, mathematical calculations, and custom rules to identify potential entry and exit points in the market.

Code Structure and Purpose

Global Methods: These methods are not specific to any market and are used for internal purposes. They can include functions for parameter setup, configuration, or any other global tasks required by the strategy.

Per Market Methods: These methods are executed per market as per the MachinaTrader configuration. They include methods like onInit and onTick. The onInit method is called during the initialization of the strategy and can be used to perform setup tasks or log information. The onTick method is triggered for each tick of market data and is responsible for analyzing the data and generating trading signals.

Indicator Calculation: Strategies often involve the calculation of various technical indicators or mathematical formulas. These calculations are typically performed within a separate class or set of functions. Common libraries such as Talib or custom functions can be used to calculate indicators like moving averages, Bollinger Bands, or any other desired technical indicators.

Trading Logic: The trading logic is implemented in the onTick method or other relevant methods. It involves analyzing the market data, such as price, volume, or other relevant indicators, and generating buy, sell, or hold signals based on predefined conditions. The logic can be based on simple or complex rules and can incorporate multiple indicators or market factors.

Charting and Indicator Integration: MachinaTrader provides charting functionality that allows traders to visualize market data and indicators. Strategies can utilize the onSendIndicatorModels method to add indicators to the chart. Indicators can be displayed as lines, shapes, or any other visual representation. Traders can customize the appearance and behavior of the indicators to suit their preferences.

Charting and Indicator Integration

MachinaTrader’s charting functionality enables traders to visualize market data and indicators, providing valuable insights into the strategy’s performance. Traders can use the onSendIndicatorModels method to add various indicators to the chart, such as moving averages, Bollinger Bands, or custom indicators. Indicators can be plotted as lines, shapes, or any other visual representation.

The platform offers extensive customization options for indicators, including color, line style, thickness, and shape properties. Traders can adjust these parameters to enhance visibility and interpret the indicators more effectively.

How can we help?