Skip to content
All library documents

FMZ M Language Basics for Moving-Average Trading Strategies

Article FMZ digest · Author: 善

Summary

This tutorial introduces FMZ’s M language as a compact, indicator-oriented way to express trading rules. It builds a moving-average example: long entries require price and the short average to be above the long average while that average rises; short entries use the corresponding bearish conditions. Exit rules close positions when price, average alignment, or the long average’s direction turns against the position. The article explains how to reference current and prior bar data, assign and display variables, use numeric, string, and Boolean values, and combine comparisons with arithmetic and logical operators.

It also describes the language’s bar-close and real-time execution modes, intraday time conditions, and filtered versus unfiltered signal handling. The examples are instructional rather than evidence of strategy performance: no backtest results or risk-adjusted returns are provided. The tutorial explains that bar-close signals trade on the next bar, while real-time signals can act as soon as a condition is met, so execution mode affects how rules behave. The moving-average rules are a teaching example, not a validated trading system.

Key ideas

  • M language packages common indicator and trading operations into concise strategy statements.
  • REF retrieves historical values, while assignment syntax controls variable use and chart display.
  • The example combines moving-average alignment and slope conditions to define entries and exits.
  • Bar-close and real-time modes differ in when signals are evaluated and orders are placed.
  • Filtered models suppress repeated same-direction signals until an opposing signal occurs.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.