How MultiCharts Executes Strategy#

PowerLanguage and Scripts#

A strategy is a set of instructions written in the programming language called PowerLanguage. You need to use the PowerLanguage Editor to write PowerLanguage instructions. The completed PowerLanguage instructions are called a script. A script must be compiled before it can be executed (press F3 in the PowerLanguage Editor to compile). The compilation confirms whether the syntax is correct and translates the script into a MultiCharts-executable format. After successful compilation, the script can be selected and executed in MultiCharts.

Script Types#

In the PowerLanguage Editor, there are three types of scripts: Function, Indicator and Signal. Open PowerLanguage Editor -> File -> Open a new file to select the type of script to be written.

Script TypePurposeExecutable Instructions
FunctionEncapsulates reusable logic, see Function for details-
IndicatorDraws lines on the chart (Ex: Plot), such as drawing a 5-period moving averageDrawing instructions
SignalExecutes trades (Ex: Buy, Sell, SellShort, BuyToCover)Buy and sell instructions

The main differences between indicator scripts and signal scripts:

  • Indicator scripts: Can execute drawing instructions, but cannot execute buy and sell instructions. You can execute the indicator script only, observe the changes of lines on the chart, and then manually place an order to buy or sell.
  • Signal scripts: Can execute buy and sell instructions, but cannot execute drawing instructions.

Script Execution Mechanism#

When trading manually, if you use a strategy of buying on the golden cross of 2 moving averages, you will keep staring at the chart that is constantly receiving market data, watching the bars form one by one, and then “constantly” checking whether the 2 moving averages have a golden cross to decide whether to buy. Maybe not consciously, but as market data continues to arrive, you are constantly repeating the logic of the strategy.

MultiCharts executes strategies with the same concept: as market data is continuously received, MultiCharts continuously re-executes the script. However, “continuously” does not mean that the next execution starts immediately after the previous one finishes. MultiCharts defines execution rules to determine when to re-execute the script.

The execution rules for indicator scripts and signal scripts are different. The respective rules are as follows.

Indicator Execution Rules#

  1. Historical Bars Phase (Bar by Bar): For past completed bars, the script is executed at the end of each bar sequentially.
  2. Real-time Phase (Tick by Tick): Once the script has been executed for all completed bars, it enters the real-time phase. Before the current bar is completed, the script is re-executed every time a tick is received.

Signal Execution Rules#

  1. Historical Bars Phase (Bar by Bar): For past completed bars, the script is executed at the end of each bar sequentially. (Same as indicators)
  2. Real-time Phase (Bar on Close): Once the script has been executed for all completed bars, it enters the real-time phase. Before the current bar is completed, the script will NOT be re-executed. It waits until the current bar is completed before re-executing.

IOG (Intra-bar Order Generation)#

Signal scripts can enable the IOG property to change the real-time phase behavior, making it the same as indicators: before the current bar is completed, the script is re-executed every time a tick is received.

Note: Even with IOG enabled, the historical bars phase remains Bar by Bar and will not become Tick by Tick.

Indicator vs Signal Execution Rules Comparison#

Execution PhaseIndicatorSignalSignal (IOG Enabled)
Historical BarsBar by BarBar by BarBar by Bar
Real-time (Current Bar Incomplete)Tick by TickNot ExecutedTick by Tick
Real-time (Current Bar Completed)ExecuteExecuteExecute

Completed Bars#

In the execution rules above, “completed bars” is a key concept. Taking time-based charts (Ex: minute charts) as an example, a bar is considered completed when either of the following conditions is met:

  1. The next tick received has a time stamp exceeding the time interval defined by the bar
  2. No additional ticks are received for a certain period of time

The timeout duration in condition 2 differs between indicators and signals:

Script TypeTimeout Duration
Indicator3 seconds
Signal300 seconds

Reference#

https://www.multicharts.com/trading-software/index.php/How_Scripts_Work

© 2026 CodeReindeer. All rights reserved.