Pine Script Execution, Series Semantics, and Trailing Stops on FMZ
Summary
This tutorial explains how Pine scripts execute on FMZ, a platform that supports Pine-style strategies, charting, backtesting, and live trading. It outlines platform differences from TradingView, including settings for execution timing and order precision, contract identifiers, plotting options, and debugging functions. It then describes bar-by-bar processing, contrasting close-based calculations with recalculation on each live price update.
Examples demonstrate rollback on a live bar, where variables and plotted signals can change before the bar closes, and show why conditionally called functions may produce different historical series values or incorrect results. The later strategy example combines Supertrend direction changes with entries, reversal exits, and a trailing stop. Charts and sample code illustrate the mechanics, but the tutorial does not provide performance results. Its examples are platform-specific, and live-bar signals may repaint, so their behavior in backtests and live execution can differ.
Key ideas
- FMZ configures execution timing, price and quantity precision, and contract settings through platform parameters.\nA close-based strategy evaluates after a bar closes, while a real-time model recalculates with price updates.\nOn a live bar, rollback can reset variables and cause plotted values or trading signals to change.\nSome series functions need to execute on every bar to preserve their intended history.\nThe example strategy uses Supertrend signals for entries and reversals, with a trailing stop for exits.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.