Skip to content
All library documents

Visual Programming for a Moving Average Trading Strategy

Article FMZ digest · Author: 善

Summary

This tutorial introduces block based visual programming as an entry point to quantitative trading and demonstrates its use with a simple moving average rule. The example opens a long position when the previous candle closes above a 50 period average, opens short below it, and closes positions when price crosses back over the average. It describes the sequence of tasks represented in the blocks, from selecting a market and retrieving candle data to checking position state and acting on the signal.

The guide explains how candle data is stored in an array of records, how to retrieve the most recent or prior candle as the array grows, and how to access fields such as closing price, time, and volume. It also demonstrates a basic text output program and presents Blockly as a way to build logic through connected modules. The material is instructional rather than an evaluation of strategy performance: it gives no backtest, returns, or risk analysis. It cautions that the platform’s visual interface has a limited API and frames it mainly as a learning aid for organizing strategy logic.

Key ideas

  • The example trades around a 50 period moving average using prior candle data.
  • A strategy flow checks market data, indicator values, current positions, and trade conditions.
  • Candle arrays contain records whose fields can be accessed by index and name.
  • The latest array item can be located relative to the array length as new candles arrive.
  • Visual blocks can lower the programming barrier, though the platform interface has API limits.

Tags

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