Metastock Formulas - New ^new^
The MetaStock formula language allows you to create custom indicators, system tests, and explorations using a syntax similar to spreadsheet formulas . Recent updates, particularly in MetaStock 19 (2024–2026)
, focus on improved workflows, including theme support (dark/light mode), tabbed charts, and easier access to past exploration results. Core Concepts for New Formulas Data Arrays : Use standard identifiers like (Volume), and (Typical Price). Logical Syntax : Use operators like IF(condition, then, else) to build decision-based triggers. Referencing
function is critical for looking back at previous periods (e.g., Ref(C, -1) for yesterday's close). Examples of Useful Formulas These formulas can be used in the Indicator Builder Oracle Traders Metastock Formulae | PDF | Moving Average | Day Trading
The MetaStock Formula Language is a specialized scripting language designed for creating custom indicators, explorations, system tests, and expert advisors. Patterned after popular spreadsheet languages, it allows you to define technical trading strategies by combining price data with mathematical operators and built-in functions. Core Components of MetaStock Formulas
Writing a formula requires understanding three primary building blocks:
Price Array Identifiers: These represent specific data points for a security.
O (Open), H (High), L (Low), C (Close), V (Volume), OI (Open Interest).
Mathematical Operators: Standard operators like +, -, *, and / are used for calculations. metastock formulas new
Functions: Pre-defined operations that perform complex tasks. Examples include:
Mov(data, periods, method): Calculates moving averages (e.g., Simple, Exponential).
Ref(data, periods): References data from a specific number of bars ago (e.g., Ref(C, -1) for yesterday's close).
Cross(data1, data2): Identifies when one data array crosses above another. Fundamental Syntax Examples
For those new to the language, basic formulas often combine a price array with a condition or a function.
Price Range Filter: To find stocks closing between $20 and $50:C >= 20 AND C <= 50
Simple Moving Average Crossover: A classic buy signal where a 3-period average crosses above a 10-period average:Cross(Mov(C, 3, S), Mov(C, 10, S)) The MetaStock formula language allows you to create
Volume Spike: Identifying stocks where today's volume is 50% higher than the 21-period average:V > Mov(V, 21, S) * 1.5 Advanced Concepts
As you progress, you can use more complex logic to build sophisticated tools: MetaStock Formula Language Overview | PDF - Scribd
3. The Cum( ) Function for Regime Filtering
Stop looking for trends in a sideways market. Use cumulative logic to define regimes:
Sideways := (HHV(H,20) - LLV(L,20)) / LLV(L,20) < 0.05;
Common formula patterns
- Trend filter + momentum trigger:
- Use a longer MA as trend (e.g., Mov(Close, 200, 1)) and a shorter MA or oscillator for entries.
- Example entry: Cross(Mov(Close, 20,1), Mov(Close, 200,1)) AND RSI(14) > 50
- Pullback entries:
- Detect retracement to moving average or recent support.
- Example: Close < Mov(Close, 20,1) AND Cross(Close, Mov(Close, 20,1)) — signals when price returns above MA.
- Breakout with volume confirmation:
- Use Highest(Close, n) for breakout level plus Volume > Mov(Volume, vlen, 1) * factor
- Exit rules:
- Trailing stop with Highest/Lowest: Sell = Cross(Mov(Close, 10,1), Close) OR Close < Lowest(Close, 10)
- Fixed percent or ATR-based stops can be approximated with price comparisons.
3. The "No-Noise" Trend Filter
Type: Exploration / System Test
One of the biggest frustrations for MetaStock users is the "Whipsaw"—getting stuck in a trade that looks like a breakout but immediately reverses. This formula acts as a strict trend filter to keep you out of choppy, sideways markets.
The Logic: It combines an Exponential Moving Average (EMA) slope with a volatility threshold. It only gives a "True" signal if the trend is moving and volatility is sufficient to sustain the move.
Copy this code into the Exploration Builder: Common formula patterns
Trend Filter Period := 21; Threshold := 0.5; Minimum % change requiredSlope Calculation MA_Calc := Mov(C, Period, E); Slope := (MA_Calc - Ref(MA_Calc, -1)) / MA_Calc * 100;
Volatility Filter Vol_Check := ATR(14) > Ref(ATR(14), -5);
Conditions Bullish := Slope > Threshold AND Vol_Check; Bearish := Slope < -Threshold AND Vol_Check;
Output for Exploration Bullish
How to use it: Run this exploration on your watchlist. It will return a "1" for stocks that are currently in a confirmed, healthy trend, allowing you to focus your attention only on actionable setups.