MultiChart EasyLanguage Trading Systems Guide
Table of Contents
- Introduction to MultiCharts and EasyLanguage
- Trading System Components
- EasyLanguage Syntax and Programming
- Sample Trading Strategies
- Resources for Further Learning
Introduction to MultiCharts and EasyLanguage
What is MultiCharts?
MultiCharts is an award-winning trading platform designed for backtesting and algorithmic trading. It enables traders to design and execute high-performance trading strategies with advanced analytics, technical indicators, and optimization capabilities. The platform allows traders to turn their ideas into trading systems by combining programming with historical market data to test performance in real market conditions without risk.
Key features of MultiCharts include:
- Charting and visualization tools for multiple assets
- Strategy development and backtesting
- Portfolio-level strategy testing
- High-precision simulation with tick-by-tick accuracy
- Connectivity to various brokers, exchanges, and data feeds
- Automated trading capabilities
What is EasyLanguage?
EasyLanguage is a powerful yet easy-to-learn programming language developed by TradeStation Securities. It has been widely used in the trading industry for over 20 years and has become a standard for trading applications. The language was designed to express financial instrument trading rules in a systematic and logical way that can be executed by a computer.
EasyLanguage allows traders to:
- Create custom technical indicators
- Develop trading strategies
- Automate trading systems
- Modify existing studies or create new ones from scratch
Relationship Between MultiCharts and EasyLanguage
MultiCharts uses PowerLanguage, which is an advanced programming environment developed by MCT Limited. PowerLanguage maintains high compatibility with EasyLanguage, making it possible to use the extensive collection of existing EasyLanguage indicators and strategies.
Key points about their relationship:
- PowerLanguage is an evolution of EasyLanguage
- Up to 99% of EasyLanguage strategies and indicators are fully compatible with MultiCharts
- MultiCharts chose to support EasyLanguage despite compatibility challenges to leverage its extensive knowledge base
- Object-oriented EasyLanguage is not supported in MultiCharts
PowerLanguage extends EasyLanguage functionality by allowing:
- External DLLs to be referenced
- Use of high-level programming languages like C++ or C#
- Creation of functions for recurring tasks
Trading System Components
Entry and Exit Signals
MultiCharts provides robust capabilities for creating and managing entry and exit signals in trading systems. These are essential components that determine when to enter or exit the market.
Entry Strategies
Entry strategies in MultiCharts are pre-designed One-Cancels-Other (OCO) order groups to enter positions. They consist of combinations of limit and/or stop orders, and if one is filled then the other one is cancelled. Key entry strategies include:
Breakout Strategy: Places two stop orders at specified prices/distances - a buy stop order above the current price and a sell stop order below the current price. This strategy is designed to capture sudden and significant price movements through support and resistance levels.
Fade Strategy: Places two limit orders at specified prices/distances - a buy limit order below the current price and a sell limit order above the current price. This strategy trades against the trend, buying when prices go down and selling when prices go up.
Breakout Up/Fade Strategy: A combination of breakout and fade strategies used when the trader expects the price to go up. It places a buy stop above the current price and a buy limit order below the current price.
Breakout Down/Fade Strategy: A combination of breakout and fade strategies used when the trader expects the price to go down. It places a sell stop below current price and sell limit above current price.
Entry strategies can be applied to charts through drag-and-drop or by right-clicking, making them easy to implement.
Exit Strategies
Exit strategies are designed to protect against sudden market movements and to exit a position in a structured and organized fashion. MultiCharts uses a 'building block' approach to construct automated exit strategies. Key exit strategies include:
Stop Loss: A stop order that defines how much loss is tolerable before a position will be exited. When the specified price is reached, the order becomes a market order.
Profit Target: A limit order placed to define how much profit must be attained before the position is closed. Unlike stop orders, limit orders are filled only at the specified price or better.
Brackets: A One-Cancel-Other (OCO) order group with one limit order and one stop order. If one of these orders is filled, the other one will be cancelled.
Breakeven: An exit strategy for exiting the market without losing money. It places a stop order that becomes active once a specified profit level is reached.
Trailing Stop: A 'smart' stop order that follows the current position's profit and executes if the price goes in the opposite direction. It allows for capturing profits while limiting losses.
Exit strategies can be automatically applied to every new order placed, ensuring consistent risk management.
Position Sizing
Position sizing is a critical component of trading systems that determines how many contracts or shares to trade. MultiCharts offers various approaches to position sizing:
Fixed Position Sizing: Trading a fixed number of contracts or shares regardless of account size or market conditions.
Risk-Based Position Sizing: Calculating position size based on a fixed amount or percentage of risk per trade. This approach adjusts position size based on the distance to the stop loss.
Equity-Based Position Sizing: Adjusting position size based on account equity, allowing for position scaling as the account grows or shrinks.
Volatility-Based Position Sizing: Adjusting position size based on market volatility, typically using indicators like Average True Range (ATR).
When optimizing trading strategies, it's generally recommended to use fixed position sizing to avoid introducing starting point dependencies that can distort optimization results. In live trading, however, risk-based or equity-based position sizing is often preferred for proper risk management.
Risk Management
MultiCharts provides comprehensive risk management tools to protect trading capital:
Risk Management Mode: A specialized interface that allows traders to set and visualize risk parameters for trades. It includes:
- Controls for setting stop loss and profit target levels
- Calculation of risk in terms of ticks, price, currency amount, and percentage of equity
- Automatic calculation of position size based on risk parameters
- Visual representation of risk/reward ratios
Money Management: Features for controlling the amount of capital risked per trade, including:
- Dollar risk per trade
- Percentage risk per trade
- Maximum drawdown controls
- Position sizing based on volatility
Portfolio-Level Risk Management: Tools for managing risk across multiple instruments and strategies, ensuring diversification and preventing overexposure to specific markets.
Backtesting Capabilities
MultiCharts offers sophisticated backtesting capabilities to evaluate trading strategies before deploying them in live markets:
Realistic Backtesting: MultiCharts aims to recreate past market conditions and order execution as accurately as possible, minimizing assumptions and considering many factors that affect trading outcomes.
Tick-by-Tick Simulation: The Bar Magnifier feature allows for reconstructing exact price movements within each bar, increasing precision during backtesting. This enables testing on a more granular level than the displayed chart timeframe.
Comprehensive Factors: The backtesting engine considers essential factors including:
- Liquidity and order fill probability
- Tick-by-tick price changes
- Ask-bid-trade price differences (spread)
- Commission and slippage
- Initial capital and interest rates
- Trade size and currency conversion
Advanced Order Types: The backtesting engine emulates various order types including market, stop, limit, stop-limit, and one-cancels-other (OCO) orders, as well as profit targets, stop-losses, and trailing stops.
Multi-Currency Support: Base currency allows calculating profit and loss during strategy backtesting with a specified currency for Forex pairs or non-US symbols, applying currency conversion as needed.
Performance Metrics: Comprehensive performance reports with metrics such as net profit, drawdown, profit factor, Sharpe ratio, and many others to evaluate strategy effectiveness.
Multi-Threading Optimization: The platform uses multi-threading for strategy optimization, distributing tasks across different CPU cores for faster processing, especially beneficial when testing multiple parameter combinations.
EasyLanguage Syntax and Programming
Program Structure
EasyLanguage is a compiled language based on the Pascal programming language. Programs are evaluated from top to bottom, once for each historical bar in a chart, and then calculated tick-by-tick in real-time when markets are open.
Key structural characteristics:
- Statements are processed sequentially from top to bottom
- Code is compiled into machine language for faster processing
- Built-in library of reserved words and functions for technical analysis
- Automatic database management system for tracking chart data
- Automatic run-time error handling
Basic Syntax Elements
Variables and Data Types
EasyLanguage supports three main data types:
Numeric Types:
- Integer (int): Whole numbers from -2,147,483,648 to 2,147,483,647
- Float (float): Signed decimal values with less precision than doubles (not recommended)
- Double (double): Signed decimal values with highest precision (default type)
Boolean (True/False):
- Used for logical conditions
- Can be initialized as true or false
String:
- Used for text values
- Enclosed in quotes: "This is a string"
Variable Declaration
Variables are declared at the beginning of the code using the Variables or Vars keyword:
Variables: MyValue(0), Counter(0);
Or with specific types:
Variables: double AvgHighs(0), int LookBack(0), bool IsUptrend(false);
Arrays
Arrays allow storing multiple values under a single variable name:
Fixed Arrays:
Arrays: WeeklyHighs[52](0), WeeklyLows[52](0);This creates two arrays with 53 elements each (0-52), initialized to 0.
Multi-dimensional Arrays:
Arrays: VolumeHighs[5,20](0), VolumeLows[5,20](0);This creates two 2-dimensional arrays with 6 columns and 21 rows.
Dynamic Arrays:
Array: MyDynamicArray[](0); Array_SetMaxIndex(MyDynamicArray, Count);Used when the number of elements isn't known at declaration time.
Inputs
Inputs allow users to customize indicators or strategies without modifying the code:
Inputs: Length(20), Factor(0.5), UseFilter(true);
Input types include:
- Numeric inputs (default is double)
- Boolean inputs (true/false)
- String inputs (text)
Historical References
EasyLanguage can reference previous bar values using square bracket notation:
Close[1] // Close price of the previous bar
High[5] // High price from 5 bars ago
MyValue[3] // Value of MyValue variable 3 bars ago
The current bar can be referenced with [0] or without brackets:
Close[0] // Same as Close
IntrabarPersist Variables
Special variables that can store and update values tick-by-tick within a bar:
Vars: IntrabarPersist TickCount(0);
TickCount = TickCount + 1;
Control Structures
Conditional Statements
If-Then-Else:
If Condition Then
Statement1;
Else
Statement2;
Single-line format:
If Close > Close[1] Then Value1 = 1 Else Value1 = -1;
Begin-End Blocks:
If Condition Then Begin
Statement1;
Statement2;
Statement3;
End
Else Begin
Statement4;
Statement5;
End;
Loops
For Loop:
For Value1 = 1 To 10 Begin
Statement1;
Statement2;
End;
While Loop:
While Condition Begin
Statement1;
Statement2;
End;
Common Functions and Keywords
Price Data References
Open- Opening price of the current barHigh- Highest price of the current barLow- Lowest price of the current barClose- Closing price of the current barVolume- Volume of the current barTime- Time of the current barDate- Date of the current bar
Mathematical Functions
Average(Price, Length)- Simple moving averageHighest(Price, Length)- Highest value over specified lengthLowest(Price, Length)- Lowest value over specified lengthSum(Price, Length)- Sum of values over specified lengthStandardDev(Price, Length, Std)- Standard deviation
Plotting Functions
Plot1(Value)- Plots the first line on a chartPlot2(Value)- Plots the second line on a chartPlot3(Value)- Plots the third line on a chartPlot4(Value)- Plots the fourth line on a chart
Trading Commands
Buy- Generates a buy signalSell- Generates a sell signalShort- Generates a short signalCover- Generates a cover signalSetStopLoss(Amount)- Sets a stop lossSetProfitTarget(Amount)- Sets a profit target
Sample Trading Strategies
Moving Average Crossover Strategy
The Moving Average Crossover strategy is one of the most popular and straightforward trading strategies. It generates buy signals when a fast moving average crosses above a slow moving average and sell signals when the fast moving average crosses below the slow moving average.
// Simple Moving Average Crossover Strategy
// This strategy generates buy signals when a fast moving average crosses above a slow moving average
// and sell signals when the fast moving average crosses below the slow moving average.
[IntrabarOrderGeneration = false]
// Input parameters that can be adjusted by the user
Inputs:
FastLength(9), // Length of the fast moving average
SlowLength(20), // Length of the slow moving average
StopLoss(500), // Stop loss amount in points
ProfitTarget(1000); // Profit target amount in points
// Variables to store the moving average values
Variables:
FastMA(0), // Fast moving average value
SlowMA(0), // Slow moving average value
FastMAprev(0), // Previous bar's fast moving average
SlowMArev(0); // Previous bar's slow moving average
// Calculate the moving averages
FastMA = Average(Close, FastLength);
SlowMA = Average(Close, SlowLength);
FastMArev = FastMA[1];
SlowMArev = SlowMA[1];
// Plot the moving averages on the chart
Plot1(FastMA, "Fast MA", Blue);
Plot2(SlowMA, "Slow MA", Red);
// Entry conditions
// Buy when fast MA crosses above slow MA
If FastMA > SlowMA AND FastMArev <= SlowMArev Then
Buy("MA Crossover") Next Bar at Market;
// Sell when fast MA crosses below slow MA
If FastMA < SlowMA AND FastMArev >= SlowMArev Then
Sell("MA Crossover") Next Bar at Market;
// Exit conditions
// Set stop loss and profit target for long positions
If MarketPosition = 1 Then Begin
SetStopLoss(StopLoss);
SetProfitTarget(ProfitTarget);
End;
// Set stop loss and profit target for short positions
If MarketPosition = -1 Then Begin
SetStopLoss(StopLoss);
SetProfitTarget(ProfitTarget);
End;
Strategy Explanation:
Inputs: The strategy has four customizable inputs:
FastLength: The period for the fast moving average (default: 9)SlowLength: The period for the slow moving average (default: 20)StopLoss: The stop loss amount in points (default: 500)ProfitTarget: The profit target amount in points (default: 1000)
Calculations:
- Two moving averages are calculated: a fast one and a slow one
- Previous bar values are stored to detect crossovers
Entry Logic:
- Buy when the fast moving average crosses above the slow moving average
- Sell when the fast moving average crosses below the slow moving average
Risk Management:
- Stop loss and profit target are set for both long and short positions
Visualization:
- Both moving averages are plotted on the chart for visual confirmation
RSI Strategy
The Relative Strength Index (RSI) strategy is a popular mean-reversion strategy that uses the RSI indicator to identify potential overbought and oversold conditions. It generates buy signals when RSI crosses above an oversold threshold and sell signals when RSI crosses below an overbought threshold.
// RSI Strategy
// This strategy uses the Relative Strength Index (RSI) to generate buy and sell signals
// Buy when RSI crosses above oversold level, sell when RSI crosses below overbought level
[IntrabarOrderGeneration = false]
// Input parameters that can be adjusted by the user
Inputs:
RSILength(14), // Length for RSI calculation
OverSold(30), // Oversold threshold
OverBought(70), // Overbought threshold
StopLoss(500), // Stop loss amount in points
ProfitTarget(1000); // Profit target amount in points
// Variables to store values
Variables:
RSIValue(0), // Current RSI value
RSIValuePrev(0); // Previous bar's RSI value
// Calculate RSI
RSIValue = RSI(Close, RSILength);
RSIValuePrev = RSIValue[1];
// Plot RSI on the chart
Plot1(RSIValue, "RSI", Blue);
Plot2(OverBought, "Overbought", Red);
Plot3(OverSold, "Oversold", Green);
// Entry conditions
// Buy when RSI crosses above oversold level
If RSIValue > OverSold AND RSIValuePrev <= OverSold Then
Buy("RSI Oversold") Next Bar at Market;
// Sell when RSI crosses below overbought level
If RSIValue < OverBought AND RSIValuePrev >= OverBought Then
Sell("RSI Overbought") Next Bar at Market;
// Exit conditions
// Set stop loss and profit target for long positions
If MarketPosition = 1 Then Begin
SetStopLoss(StopLoss);
SetProfitTarget(ProfitTarget);
End;
// Set stop loss and profit target for short positions
If MarketPosition = -1 Then Begin
SetStopLoss(StopLoss);
SetProfitTarget(ProfitTarget);
End;
Strategy Explanation:
Inputs: The strategy has five customizable inputs:
RSILength: The period for RSI calculation (default: 14)OverSold: The oversold threshold (default: 30)OverBought: The overbought threshold (default: 70)StopLoss: The stop loss amount in points (default: 500)ProfitTarget: The profit target amount in points (default: 1000)
Calculations:
- RSI is calculated using the built-in RSI function
- Previous bar RSI value is stored to detect crossovers
Entry Logic:
- Buy when RSI crosses above the oversold threshold
- Sell when RSI crosses below the overbought threshold
Risk Management:
- Stop loss and profit target are set for both long and short positions
Visualization:
- RSI and threshold levels are plotted on the chart for visual confirmation
Breakout Strategy
The Breakout strategy is designed to capture significant price movements by generating buy signals when price breaks above a resistance level and sell signals when price breaks below a support level. This strategy works well in trending markets.
// Breakout Strategy
// This strategy generates buy signals when price breaks above a resistance level
// and sell signals when price breaks below a support level
[IntrabarOrderGeneration = false]
// Input parameters that can be adjusted by the user
Inputs:
Length(20), // Lookback period for support/resistance levels
StopLoss(500), // Stop loss amount in points
ProfitTarget(1000); // Profit target amount in points
// Variables to store values
Variables:
HighestVal(0), // Highest high over lookback period
LowestVal(0); // Lowest low over lookback period
// Calculate support and resistance levels
HighestVal = Highest(High[1], Length);
LowestVal = Lowest(Low[1], Length);
// Plot support and resistance levels on the chart
Plot1(HighestVal, "Resistance", Red);
Plot2(LowestVal, "Support", Green);
// Entry conditions
// Buy when price breaks above resistance level
If Close > HighestVal Then
Buy("Breakout") Next Bar at Market;
// Sell when price breaks below support level
If Close < LowestVal Then
Sell("Breakdown") Next Bar at Market;
// Exit conditions
// Set stop loss and profit target for long positions
If MarketPosition = 1 Then Begin
SetStopLoss(StopLoss);
SetProfitTarget(ProfitTarget);
End;
// Set stop loss and profit target for short positions
If MarketPosition = -1 Then Begin
SetStopLoss(StopLoss);
SetProfitTarget(ProfitTarget);
End;
Strategy Explanation:
Inputs: The strategy has three customizable inputs:
Length: The lookback period for calculating support/resistance levels (default: 20)StopLoss: The stop loss amount in points (default: 500)ProfitTarget: The profit target amount in points (default: 1000)
Calculations:
- Resistance level is calculated as the highest high over the lookback period
- Support level is calculated as the lowest low over the lookback period
Entry Logic:
- Buy when price closes above the resistance level
- Sell when price closes below the support level
Risk Management:
- Stop loss and profit target are set for both long and short positions
Visualization:
- Support and resistance levels are plotted on the chart for visual confirmation
Resources for Further Learning
Official Documentation
MultiCharts Documentation
EasyLanguage Manuals
Online Resources
Forums and Communities
Tutorials and Blogs
Books
"Building Winning Trading Systems with TradeStation" by George Pruitt and John Hill
- Comprehensive guide to developing trading systems using EasyLanguage
- Covers strategy development, backtesting, and optimization
"Trading Systems and Methods" by Perry Kaufman
- Covers various trading systems and methods that can be implemented in EasyLanguage
- Provides theoretical background and practical implementation details
"Quantitative Trading Systems" by Howard Bandy
- Focuses on the development and testing of quantitative trading systems
- Includes examples that can be implemented in EasyLanguage
Video Tutorials
MultiCharts YouTube Channel
Third-Party Tutorials
Courses and Training
MultiCharts Training
Third-Party Training