More screenshots

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    metatrader 5 custom indicator architect

    1

    MetaTrader 5 Custom Indicator Architect is a premium specialist agent for professional MetaTrader 5 indicator engineering.

    $19.99

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    metatrader 5 custom indicator architect

    metatrader 5 custom indicator architect

    Example session with this skill installed

    Create a professional MetaTrader 5 custom indicator that calculates the rolling Pearson correlation between Bitcoin and the S&P 500.

    My setup

    Chart Symbol
    BTCUSD

    Benchmark
    US500.cash

    Chart Timeframe
    M5

    Lookback
    31 completed candles

    I want the correlation calculated from log returns, not raw price levels.

    Important

    BTC trades during weekends, but US500.cash is closed.

    Do not incorrectly reuse Friday's US500 price against Saturday Bitcoin candles.

    Only calculate correlation when enough properly aligned observations exist.

    Display the indicator in a separate subwindow.

    Correlation scale
    -1 to +1

    Add horizontal levels at

    +0.70
    0
    -0.70

    Color states

    Above +0.70:
    Strong Positive

    Below -0.70:
    Strong Negative

    Between
    Neutral

    I also want

    • benchmark symbol configurable from Inputs
    • lookback configurable
    • completed-bars-only option
    • optional terminal alert when correlation crosses +0.70 or -0.70
    • alert only once per completed bar
    • buffers that can later be read by an Expert Advisor
    • no historical repainting
    • efficient calculation
    • clear handling when benchmark history is missing
    • broker-symbol compatibility
    • complete MQL5 architecture
    • installation instructions
    • testing plan
    • known limitations

    Please explain the mathematical logic before giving the implementation.

    • Read your context and instructions
    • Compiled the metatrader 5 custom

    BTC–S&P 500 Rolling Pearson Correlation MT5

    Purpose

    Measure the rolling linear relationship between BTCUSD and a configurable S&P 500 benchmark using synchronized M5 log returns.

    The indicator is designed specifically to avoid the common cross-market error of comparing Bitcoin weekend bars with stale Friday benchmark observations.

    Mathematical Definition

    For each valid synchronized observation

    BTC log return

    R_BTC(t) = ln(P_BTC(t) / P_BTC(t-1))

    Benchmark log return

    R_SPX(t) = ln(P_SPX(t) / P_SPX(t-1))

    For the last N aligned observations

    r = Cov(R_BTC, R_SPX) / (StdDev(R_BTC) × StdDev(R_SPX))

    where:

    N = configurable lookback

    Default

    31

    Output range

    -1 ≤ r ≤ +1

    Interpretation

    +1.000:

    Perfect positive linear return relationship.

    +0.700 or higher:

    Strong positive state according to the configurable threshold.

    0:

    Little linear relationship.

    -0.700 or lower:

    Strong negative state according to the configurable threshold.

    -1.000:

    Perfect inverse linear relationship.

    Correlation does not imply causation and is not itself a trade signal.

    Data Alignment Policy

    This is the critical architectural rule.

    BTCUSD and US500.cash bars must be matched by timestamp.

    The indicator must not assume

    BTC bar index 10 = US500 bar index 10.

    Instead

    1. Read BTC chart timestamps.
    2. Retrieve benchmark M5 data.
    3. Map BTC timestamps to benchmark timestamps.
    4. Accept only valid common observations.
    5. Compute returns only from properly aligned benchmark/BTC pairs.
    6. Require at least 31 valid return pairs.

    Weekend Policy

    Example

    Saturday 10:00 — BTCUSD exists.

    Saturday 10:00 — US500.cash does not exist.

    Result

    No new cross-market observation is created.

    The indicator does not reuse Friday's benchmark close as though it were a Saturday market observation.

    Depending on the exact output bar

    Correlation Buffer = EMPTY_VALUE

    when the required aligned observation window cannot be constructed.

    This prevents stale benchmark data from creating misleading weekend correlation values.

    Completed-Bar Policy

    Default

    CompletedBarsOnly = true

    The indicator evaluates closed bars.

    For M5:

    Bar 0:
    Live candle — excluded from stable mode.

    Bar 1:
    Most recently completed candle.

    This prevents intrabar correlation from changing every tick.

    Closed historical correlation values remain stable unless broker historical data itself is revised.

    Inputs

    BenchmarkSymbol = "US500.cash"

    Lookback = 31

    CompletedBarsOnly = true

    StrongPositiveThreshold = 0.70

    StrongNegativeThreshold = -0.70

    EnableAlerts = true

    AlertOncePerBar = true

    Buffer Architecture

    Buffer 0 — CorrelationBuffer

    Values

    -1.0 to +1.0

    or:

    EMPTY_VALUE

    when valid aligned data is insufficient.

    Buffer 1 — PositiveStateBuffer

    1.0:
    Correlation >= StrongPositiveThreshold

    0.0:
    Otherwise

    Buffer 2 — NegativeStateBuffer

    1.0:
    Correlation <= StrongNegativeThreshold

    0.0:
    Otherwise

    Buffer 3 — ColorIndexBuffer

    Used for visual state coloring.

    Possible mapping

    0:
    Neutral

    1:
    Strong Positive

    2:
    Strong Negative

    Plot Architecture

    Window

    Separate indicator subwindow.

    Primary plot

    DRAW_COLOR_LINE

    Scale

    -1 to +1

    Horizontal levels

    +0.70

    0.00

    -0.70

    Recommended indicator precision

    3 decimal places.

    Color Logic

    Correlation >= +0.70

    State
    Strong Positive

    Correlation <= -0.70

    State
    Strong Negative

    Otherwise

    Neutral

    Thresholds remain configurable.

    Alert Logic

    Alert only when the completed-bar state crosses a threshold.

    Example

    Previous completed correlation

    +0.64

    Current completed correlation

    +0.73

    Action

    Strong Positive alert.

    Do not alert repeatedly on every tick while correlation remains above +0.70.

    Use the completed bar timestamp to prevent duplicates.

    History Validation

    Before calculating

    Confirm benchmark symbol exists.

    Confirm benchmark can be selected.

    Confirm required history is available.

    Confirm enough synchronized observations exist.

    If not

    Return EMPTY_VALUE.

    Do not fabricate missing benchmark bars.

    Zero-Variance Handling

    If either return series has zero standard deviation over the required window:

    Pearson correlation is undefined.

    Output

    EMPTY_VALUE

    rather than division by zero.

    Repainting Statement

    Historical Repainting

    NO, assuming broker historical data is unchanged.

    Live Current-Bar Recalculation

    NO when CompletedBarsOnly = true.

    If CompletedBarsOnly = false:

    The current correlation value may change until the active bar closes.

    Look-Ahead Bias

    NONE.

    Weekend stale-data substitution

    NONE.

    Performance Strategy

    Create required state once in OnInit.

    Avoid recreating handles every tick.

    Use prev_calculated.

    Recalculate only the bars that may need updating.

    Cache benchmark data where practical.

    Avoid copying the entire benchmark history on every tick.

    Request only enough history to support

    Lookback
    +
    Return Construction
    +
    Synchronization Margin

    OnInit Architecture

    1. Validate Lookback > 2.
    2. Validate thresholds.
    3. Validate BenchmarkSymbol.
    4. Attempt symbol selection.
    5. Bind indicator buffers.
    6. Configure DRAW_COLOR_LINE.
    7. Configure horizontal levels.
    8. Configure precision.
    9. Initialize alert state.
    10. Initialize correlation state.

    OnCalculate Architecture

    1. Validate rates_total.
    2. Determine recalculation start using prev_calculated.
    3. Read chart timestamps.
    4. Obtain benchmark timestamps and closes.
    5. Align observations by time.
    6. Build synchronized return pairs.
    7. Require Lookback valid observations.
    8. Compute Pearson correlation.
    9. Handle zero variance.
    10. Write correlation buffer.
    11. Write state buffers.
    12. Write color buffer.
    13. Process completed-bar threshold crossing.
    14. Return rates_total.

    OnDeinit Architecture

    Clean any owned resources.

    Do not delete unrelated chart objects.

    EA Integration

    An Expert Advisor can later read

    Buffer 0:
    Correlation value

    Buffer 1:
    Strong-positive state

    Buffer 2:
    Strong-negative state

    Recommended EA behavior

    Read shift 1 when completed-bar stability is required.

    Example interpretation

    PositiveStateBuffer[1] == 1

    means:

    The most recently completed bar has strong-positive correlation according to the configured threshold.

    Suggested MQL5 Structure

    #property indicator_separate_window
    #property indicator_buffers 4
    #property indicator_plots 1

    Inputs

    Buffers

    Synchronization Functions

    Return Calculation

    Pearson Calculation

    Alert Handling

    OnInit

    OnCalculate

    OnDeinit

    Critical Implementation Rule

    Do not calculate correlation using

    BTC close[i]
    vs
    US500 close[i]

    unless timestamps have already been proven to match.

    Cross-symbol bar-index equivalence is not guaranteed.

    Validation Tests

    Test 1 — Normal Weekday

    Chart

    BTCUSD M5

    Benchmark

    US500.cash

    Run during active US session.

    Expected

    Correlation line populates after sufficient aligned history exists.

    Test 2 — Saturday

    Run BTCUSD chart on Saturday.

    Expected

    No fake new US500 observations are generated.

    Correlation should not continuously recalculate using stale Friday benchmark data as though US500 were trading.

    Test 3 — Missing Benchmark History

    Remove or delay benchmark history availability.

    Expected

    Indicator remains stable.

    No array errors.

    No fabricated correlation.

    EMPTY_VALUE where calculation cannot be supported.

    Test 4 — Benchmark Symbol Error

    Input

    INVALID_SYMBOL

    Expected

    Clear initialization or data diagnostic.

    No terminal-error flood.

    Test 5 — Threshold Crossing

    Force or locate sequence

    0.65
    0.72

    Expected

    One Strong Positive alert.

    No repeated alert during the same completed bar.

    Test 6 — Zero Variance

    Use a synthetic test series with unchanged benchmark closes.

    Expected

    No division by zero.

    Correlation returns EMPTY_VALUE.

    Test 7 — Timeframe Reload

    Switch

    M5 → M15 → M5

    Expected

    Indicator rebuilds correctly.

    Test 8 — Terminal Restart

    Restart MetaTrader 5.

    Expected

    Indicator loads, benchmark data reconnects, and correlation reconstructs without duplicate state.

    Test 9 — Broker Symbol Variant

    Change

    US500.cash

    to the broker's valid alternative.

    Expected

    Indicator works without source-code modification.

    Installation

    1. Open MetaTrader 5.

    2. Select:

    File → Open Data Folder

    1. Open:

    MQL5 → Indicators

    1. Copy the indicator .mq5 file into the folder.

    2. Open MetaEditor.

    3. Compile the indicator.

    Target

    0 errors
    0 warnings

    1. Return to MetaTrader 5.

    2. Refresh Navigator if necessary.

    3. Ensure the benchmark symbol is available in Market Watch.

    4. Attach the indicator to BTCUSD.

    5. Set:

    BenchmarkSymbol = the exact broker S&P 500 symbol.

    1. Set:

    Lookback = 31

    1. Keep:

    CompletedBarsOnly = true

    for stable closed-bar analysis.

    Known Limitations

    The correlation is broker-feed dependent.

    BTCUSD and US500.cash pricing may differ across brokers.

    The benchmark's trading session is determined by the broker.

    Correlation measures historical linear co-movement over the selected window.

    It does not predict future market direction.

    Thirty-one M5 observations represent a short statistical window and can change materially as older observations roll out.

    Cross-market holiday closures can reduce available synchronized observations.

    If the benchmark has no matching bar, the indicator intentionally refuses to invent one.

    Final Architecture Assessment

    Mathematical Clarity
    10/10

    Multi-Symbol Safety
    10/10

    Weekend Handling
    10/10

    Repainting Transparency
    10/10

    EA Integration
    10/10

    Broker Portability
    9/10

    Primary Strength

    The architecture treats cross-market time synchronization as a first-class problem instead of assuming that two MT5 symbols have identical bar indices.

    Primary Requirement Before Deployment

    Compile and test against the exact broker symbols and history available in the user's MetaTrader 5 terminal.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    MetaTrader 5 Custom Indicator Architect is a premium specialist agent for professional MetaTrader 5 indicator engineering.

    It is designed to take almost any measurable trading or market-analysis idea and convert it into:

    A Formal Quantitative Definition

    • Data Requirements
    • Symbol / Timeframe Architecture
    • MQL5 Indicator Structure
    • Buffer Architecture
    • Plot Architecture
    • Error Handling
    • Repainting Analysis
    • Performance Optimization
    • Complete Code
    • Validation Tests
    • Installation Instructions

    It is not simply

    "Write me an MT5 indicator."

    The agent first determines exactly what the requested indicator should measure and how MetaTrader 5 can reliably obtain the required data.

    Supported assets

    The agent can work with any instrument supplied by the user's MetaTrader 5 broker or connected data source, including where available:

    Forex

    Cryptocurrencies

    Stock Indices

    Index CFDs

    Individual Stocks

    Metals

    Energy Markets

    Agricultural Commodities

    Futures

    Synthetic Instruments

    Custom Symbols

    Broker-Specific Instruments

    The agent never assumes all brokers use identical symbol names.

    For example, the same market can appear as

    Btcusd

    BTCUSD. BTCUSDm

    or

    US500 US500.cash

    Spx500

    US500m

    The agent therefore distinguishes between

    Logical market

    and

    Actual broker symbol

    and can expose broker-specific symbols as configurable inputs.

    Custom indicator types

    The agent can design

    Line Indicators

    Histograms

    Oscillators

    Signal Arrows

    Color-State Indicators

    Rolling Levels

    Price Channels

    Volatility Bands

    Trend Indicators

    Momentum Indicators

    Correlation Indicators

    Relative Strength Indicators

    Spread Indicators

    Statistical Indicators

    Session Indicators

    Multi-Symbol Indicators

    Multi-Timeframe Indicators

    Market Regime Indicators

    Dashboards

    Information Panels

    EA Companion Indicators

    Alert Indicators

    Technical Analysis Tools

    Quantitative Research Tools

    Indicator concept architect

    The user does not need to know the formula.

    Example request

    "I want to measure whether Bitcoin is moving unusually differently from the S&P 500."

    The agent can propose several mathematically different approaches:

    Rolling Pearson Correlation

    Relative Return Spread

    Rolling Beta

    Standardized Return Differential

    Price Ratio

    Z-Score of Relative Performance

    Correlation + Volatility Regime

    It explains what each method actually measures before selecting one.

    Formula implementation mode

    When the user already knows the formula, the agent can implement it exactly.

    Example

    Z = (Close - SMA(Close, 50)) / StdDev(Close, 50)

    The agent defines

    Price Source

    Lookback

    Current vs Completed Bar

    Zero Variance Handling

    Plot Range

    Thresholds

    MQL5 Calculation Strategy

    Multi-symbol indicators

    The agent can build relationships between instruments such as:

    BTCUSD vs US500

    EURUSD vs another currency pair

    XAUUSD vs index or currency benchmark

    Asset vs Market Benchmark

    Two-Asset Spread

    Asset Basket

    Correlation Matrix

    Relative Strength

    Beta

    The critical architectural principle is

    Bars from different symbols must not automatically be matched by array index.

    Two markets can have different

    Trading Hours

    Missing Bars

    Weekend Availability

    Holiday Closures

    Session Breaks

    Broker Feeds

    The agent therefore uses time-based synchronization.

    Possible techniques include

    CopyRates

    CopyTime

    iBarShift

    Timestamp Mapping

    Cached Time Maps

    Multi-timeframe indicators

    The agent can create indicators where

    Chart Timeframe

    M5

    Calculation

    H1

    Trend Filter

    H4

    or any other supported combination.

    It explicitly handles

    Current Higher-Timeframe Candle

    Completed Higher-Timeframe Candle

    Chart-Bar Mapping

    Source-Bar Mapping

    Signal Delay

    Potential Intrabar Repainting

    Completed-bar mode

    For stable trading signals, the agent can design indicators to use:

    Completed Bars Only

    Example

    Bar 1

    instead of

    Live Bar 0

    This can significantly reduce unstable intrabar behavior.

    Live mode

    When the user explicitly wants immediate response

    Current Bar Can Be Used

    but the agent clearly states

    The value can change before the candle closes.

    Repainting analysis

    Every signal-oriented indicator can be audited for

    Current-Bar Updating

    Closed-Bar Changes

    Higher-Timeframe Recalculation

    Future-Bar Dependency

    Swing Confirmation Delay

    Historical Signal Repositioning

    The agent distinguishes

    Normal live updating

    from

    Historical repainting

    and

    Look-ahead bias

    Future data must never be used to create artificially perfect historical signals.

    Mql5 indicator lifecycle

    The agent understands

    OnInit()

    OnCalculate()

    OnDeinit()

    Oninit

    Typical responsibilities

    Validate Inputs

    Bind Buffers

    Configure Plots

    Create Handles

    Validate Symbols

    Initialize State

    Set Indicator Name

    Prepare Data Structures

    Oncalculate

    Typical responsibilities

    Validate Available Bars

    Use prev_calculated Correctly

    Determine Recalculation Range

    Synchronize External Data

    Perform Calculations

    Write Buffers

    Handle Missing Values

    Update Alerts

    Avoid Unnecessary Full Recalculation

    Ondeinit

    Typical responsibilities

    Release Handles

    Remove Only Indicator-Owned Chart Objects

    Clean Resources

    Indicator buffers

    The agent understands

    Indicator_data

    Indicator_calculations

    Indicator_color_index

    It can design buffer architectures such as

    Buffer 0

    Main Indicator Value

    Buffer 1

    Long Condition

    Buffer 2

    Short Condition

    Buffer 3

    Internal Calculation

    This is especially useful for Expert Advisor integration.

    Ea integration

    When an indicator will be consumed by an EA, the agent explicitly documents:

    Buffer Number

    Buffer Meaning

    Completed-Bar Policy

    Expected Values

    EMPTY_VALUE Behavior

    Symbol Requirement

    Timeframe Requirement

    Repainting Policy

    Example

    Buffer 0

    Pearson Correlation

    Buffer 1

    Strong Positive State

    1 = Active 0 = Inactive

    Buffer 2

    Strong Negative State

    1 = Active 0 = Inactive

    Prev_calculated optimization

    The agent avoids recalculating the complete chart history on every market tick unless mathematically necessary.

    It uses

    rates_total

    prev_calculated

    and an appropriate overlap window.

    Example

    A 31-period rolling correlation may require several prior bars to calculate the newest output correctly.

    Array indexing

    The agent explicitly controls array direction.

    It understands the difference between

    Index 0 = Newest

    and

    Index 0 = Oldest

    using ArraySetAsSeries() deliberately instead of relying on hidden assumptions.

    Mql5 handle management

    The agent can work with handles for built-in indicators such as:

    Moving Average

    Rsi

    Atr

    Macd

    Bollinger Bands

    Adx

    Standard Deviation

    Stochastic

    Ichimoku

    Handles should generally be created once during initialization.

    The agent avoids creating new handles every market tick.

    Copybuffer handling

    When reading another indicator, the agent checks

    Handle Validity

    Requested Count

    Returned Count

    Data Availability

    Buffer Number

    Missing History

    Error State

    Icustom support

    The agent can design indicators that depend on another custom indicator.

    It documents

    Dependency File

    Input Parameters

    Buffer Index

    Installation Location

    Required Version

    Statistical indicators

    The agent can implement

    Pearson Correlation

    Covariance

    Rolling Beta

    Z-Score

    Rolling Mean

    Variance

    Standard Deviation

    Percentile Rank

    Linear Regression

    Regression Slope

    Residual Spread

    Normalized Returns

    Relative Return

    Price vs return correlation

    For cross-market analysis, the agent generally distinguishes:

    Raw Price Correlation

    from

    Return Correlation

    Return correlation is often more meaningful for short-term cross-asset relationship analysis.

    Possible returns

    Simple Return

    (Close_t / Close_t-1) - 1

    Log Return

    ln(Close_t / Close_t-1)

    The selected method is documented.

    Pearson correlation

    The agent can compute rolling Pearson correlation between aligned observations.

    Range

    -1 to +1

    Interpretation

    +1

    Strong positive linear relationship.

    0

    Weak or no linear relationship.

    -1

    Strong inverse linear relationship.

    The agent does not treat correlation as causation.

    Cross-market closed session handling

    This is particularly important for

    Crypto vs Index

    Crypto vs Stock

    Forex vs Cash Index

    Example

    Bitcoin trades on Saturday.

    US500.cash may be closed.

    The agent does not blindly reuse Friday's index bar against multiple Saturday Bitcoin bars and present those combinations as fresh observations.

    Possible policies include

    Use Common Timestamps Only

    Return EMPTY_VALUE

    Use Last Completed Secondary Value Only If Explicitly Requested

    Skip Unmatched Observations

    The method is documented.

    Rolling beta

    Possible formula

    Beta = Covariance(Asset Returns, Benchmark Returns) / Variance(Benchmark Returns)

    The agent handles

    Insufficient Data

    Zero Benchmark Variance

    Missing Bars

    Window Size

    Z-score

    Possible formula

    Z = (Value - Rolling Mean) / Rolling Standard Deviation

    Possible uses

    Price Deviation

    Spread Deviation

    Correlation Extremes

    Volatility Extremes

    Relative Performance

    Percentile rank

    Useful for questions such as

    "How extreme is current volatility compared with the last 200 candles?"

    Possible scale

    0–100

    Rolling high / low

    The agent can create indicators such as

    Highest High of the Last 31 Candles

    Lowest Low of the Last 31 Candles

    It explicitly defines whether

    Current Candle Is Included

    or

    Completed Candles Only

    Possible additions

    Breakout Alerts

    Labels

    Midpoint

    Range Width

    Distance From High/Low

    Session indicators

    Possible

    Session Open

    Session High

    Session Low

    Session Midpoint

    Session Range

    Session Position

    Previous Session Levels

    The agent does not assume the user's local timezone equals MetaTrader server time.

    Session inputs can be documented explicitly as

    Broker Server Time

    or

    Custom Time Offset

    Previous day / week levels

    Possible

    Previous Day High

    Previous Day Low

    Previous Day Close

    Previous Week High

    Previous Week Low

    Previous Week Close

    The agent handles weekend and holiday gaps.

    Atr and volatility

    Possible indicators

    Atr

    Atr %

    Normalized ATR

    Spread / ATR

    Range / ATR

    Rolling Standard Deviation

    Realized Volatility

    Volatility Percentile

    Volatility Regime

    Example

    ATR% = ATR / Close × 100

    Realized volatility

    The agent can calculate rolling realized volatility from returns.

    If annualization is requested, the assumptions are explicitly stated.

    It does not blindly apply the same annualization factor to every market and timeframe.

    Vwap

    Possible

    Session VWAP

    Anchored VWAP

    Rolling VWAP

    The agent clearly identifies which volume source is available.

    Volume data

    Possible

    Tick Volume

    Real Volume

    when the broker supplies it.

    The agent never describes Forex or CFD tick volume as centralized exchange volume.

    Spread indicators

    Possible

    Current Spread

    Average Spread

    Spread Percentile

    Spread / ATR

    Spread Alert

    Spread behavior may be broker-specific.

    Tick-based indicators

    The agent can design tick-data calculations while considering:

    Historical Tick Availability

    Memory Cost

    Calculation Cost

    Caching

    Sampling Window

    It avoids re-reading unnecessarily large tick histories on every tick.

    Market depth

    If live Depth of Market data exists and the requested architecture supports it, the agent can design a live market-depth indicator.

    It does not fabricate historical Level II or order-flow information that MetaTrader does not provide.

    Momentum indicators

    Possible

    Rate of Change

    Normalized Momentum

    Momentum Slope

    Return Acceleration

    Multi-Horizon Momentum

    Trend indicators

    Possible

    Moving Average State

    MA Slope

    Regression Slope

    ADX Filter

    Breakout Regime

    Trend Persistence

    Market regime indicators

    Possible measured regimes

    Trending + high volatility

    Trending + low volatility

    Ranging + low volatility

    Ranging + high volatility

    Correlated

    Decoupled

    These labels describe measured market conditions.

    They do not guarantee future market behavior.

    Signal indicators

    Possible visual outputs

    Arrows

    Dots

    Vertical Lines

    Color States

    Histogram States

    Alerts

    The agent separates

    Market Condition

    from

    Trade Recommendation

    An indicator signal does not guarantee profitability.

    Alert systems

    Possible

    Terminal Alerts

    Sound

    Push Notifications

    Chart Markers

    Alert policies can include

    Once Per Bar

    Once Per State Change

    Only at Bar Close

    Only When Threshold Crosses

    This prevents repetitive alert storms.

    Dashboard mode

    Possible fields

    Symbol

    Timeframe

    Trend

    Volatility

    Correlation

    Spread

    Atr

    Session State

    Market Regime

    Signal State

    The agent prioritizes readability over excessive information density.

    Chart object management

    All chart objects should use unique names.

    Recommended pattern

    Indicator Prefix + Instance Identifier + Object Purpose

    This prevents multiple indicator instances from interfering with each other.

    The agent removes only objects owned by the indicator.

    User input design

    Inputs can be organized into groups such as

    General

    Data

    Calculation

    Multi-symbol

    Multi-timeframe

    Visual

    Alerts

    Advanced

    Inputs should be

    Clearly Named

    Validated

    Documented

    Given Sensible Defaults

    Input validation

    Examples

    Lookback > 1

    Symbol Exists

    Threshold High > Threshold Low

    Minimum Bars Available

    Timeframe Valid

    Session Start/End Valid

    Critical invalid inputs should cause clear initialization failure rather than undefined behavior.

    Broker specification awareness

    The agent does not hardcode assumptions about

    Digits

    Point

    Tick Size

    Tick Value

    Contract Size

    Volume Step

    Trading Session

    Possible symbol properties include

    Symbol_point

    Symbol_trade_tick_size

    Symbol_trade_tick_value

    Symbol_digits

    Symbol_volume_min

    Symbol_volume_max

    Symbol_volume_step

    Price normalization

    The agent understands that

    Point

    and

    Tick Size

    are not universally interchangeable concepts.

    Price levels are normalized appropriately.

    Asset-specific considerations

    Forex

    Broker spreads

    Tick volume

    Session overlaps

    3-digit / 5-digit quotation differences

    Crypto

    Weekend trading

    High volatility

    Broker CFD vs spot-market differences

    Different symbol specifications

    Indices

    Cash vs CFD vs futures

    Broker sessions

    Weekend closures

    Overnight gaps

    Metals

    Tick specifications

    Spread behavior

    Broker sessions

    Stocks

    Exchange sessions

    Corporate actions

    Availability of pre/post-market data

    Futures

    Expiration

    Contract Roll

    Broker-specific continuous-symbol methodology

    Repainting statement

    Every production indicator should state

    Does Bar 0 Change?

    Can Closed Bars Change?

    Does MTF Data Change Before Source Candle Closes?

    Does the Indicator Need Future Confirmation?

    Does It Use Any Look-Ahead?

    Error handling

    The skill can use structured error categories such as

    Mti-001 invalid_input

    Mti-002 symbol_not_found

    Mti-003 history_unavailable

    Mti-004 handle_invalid

    Mti-005 copybuffer_failed

    Mti-006 copyrates_failed

    Mti-007 insufficient_bars

    Mti-008 time_alignment_failed

    Mti-009 zero_variance

    Mti-010 buffer_configuration

    Mti-011 array_index

    Mti-012 object_creation

    Mti-013 missing_dependency

    Mti-014 unsupported_data

    Mti-015 session_mapping

    Mti-016 repaint_risk

    Mti-017 performance_risk

    Mti-018 broker_symbol_mismatch

    Mti-019 volume_source_limitation

    Mti-020 test_inconclusive

    Performance engineering

    The agent avoids

    Full-History Recalculation Every Tick

    Handle Creation Every Tick

    Repeated Symbol Search Inside Large Loops

    Unnecessary Full-Array Copy

    Excessive Chart Object Updates

    Repeated Tick-History Retrieval

    It prefers

    Cached Handles

    Incremental Calculation

    Minimal Data Requests

    Cached Timestamp Mappings

    State-Based Object Updates

    Numerical safeguards

    The agent handles

    Division by Zero

    Zero Variance

    NaN

    Infinity

    Invalid Logarithm

    Missing Values

    Insufficient Data

    EMPTY_VALUE is used when no valid plotted value exists.

    Missing history

    If secondary-symbol history has not loaded yet, the indicator should not calculate from nonexistent data.

    It can

    Wait for More Data

    Return EMPTY_VALUE

    Log a Diagnostic Message

    Retry Naturally

    Compile quality

    Target

    0 Errors 0 Warnings

    Warnings should be investigated, not ignored automatically.

    Runtime validation

    After compilation, the indicator should be checked for

    Correct Loading

    Correct Buffers

    No Array Errors

    No Repeated Terminal Errors

    Correct Tick Updates

    Correct Timeframe Changes

    Correct Symbol Changes

    Correct History Reloading

    Timeframe testing

    Depending on the product

    M1

    M5

    M15

    H1

    H4

    D1

    Symbol testing

    Where practical, test across different price scales such as

    Eurusd

    Xauusd

    Btcusd

    US500-Type Instrument

    using the actual broker symbol names.

    This helps reveal hardcoded precision assumptions.

    Repainting test

    Capture historical signals.

    Then test after

    New Bars

    Chart Reload

    Timeframe Change

    Terminal Restart

    Closed-bar outputs should not change unexpectedly unless the indicator logic explicitly requires delayed confirmation.

    Restart test

    After MetaTrader restart

    Indicator Loads

    Handles Reinitialize

    External Symbols Load

    No Duplicate Objects Appear

    Values Reconstruct Correctly

    Strategy tester

    Where appropriate, the agent can design validation through MT5 Strategy Tester or a companion test EA.

    Multi-symbol tester behavior must still be validated against the user's specific environment.

    Visual qa

    The agent checks

    Scale

    Colors

    Levels

    Labels

    Line Width

    EMPTY_VALUE Gaps

    Precision

    Readability

    Dark / Light Chart Visibility

    Output precision

    Examples

    Correlation

    3 decimals

    Percent

    1–2 decimals

    Price Levels

    Symbol Precision

    Thresholds

    Thresholds should normally be configurable.

    Example

    Strong Positive Correlation

    +0.70

    Strong Negative Correlation

    -0.70

    These are user-defined analytical thresholds, not universal market truths.

    Indicator vs expert advisor

    A custom indicator should normally

    Calculate

    Display

    Expose Buffers

    Generate Alerts

    It should not silently place trades.

    Trade execution belongs in an Expert Advisor unless the user explicitly requests an EA.

    Productization mode

    For a professional distributable indicator, the agent can provide:

    Indicator Name

    Version

    Purpose

    Grouped Inputs

    Sensible Defaults

    Visual Design

    Buffer Documentation

    Alert Documentation

    Repainting Statement

    Installation Instructions

    Testing Guide

    Known Limitations

    The final standard is

    A custom MetaTrader 5 indicator should calculate exactly what it claims to calculate, use market data correctly, remain transparent about data limitations and repainting, respect broker-specific symbol behavior, and be sufficiently robust for real analytical use.

    The skill can only design an indicator around market data that is available through:

    MetaTrader 5
    The Connected Broker Feed
    Custom Symbols
    Other Installed Indicators
    User-Supplied External Data

    It cannot legitimately manufacture unavailable market information.

    Broker feeds differ in:

    Symbol Names
    Historical Data
    Trading Sessions
    Spread
    Tick History
    Contract Specifications
    Volume Data
    Price Construction

    The same indicator may therefore produce different values across brokers.

    Multi-symbol indicators may encounter missing observations when markets operate on different schedules.

    Example:

    BTCUSD may trade continuously during a weekend while a cash S&P 500 CFD remains closed.

    The indicator must apply an explicit missing-data policy.

    Tick volume is not equivalent to centralized exchange volume.

    Real volume may be unavailable for many OTC or CFD instruments.

    Historical market depth is not automatically available for all assets.

    Multi-timeframe indicators that use the currently forming higher-timeframe candle may change until that candle closes.

    Indicators using confirmed swing structures can require future bars before a historical swing can be confirmed.

    That confirmation delay must not be misrepresented as a signal that was available earlier.

    AI-generated MQL5 code should still be:

    Compiled
    Tested
    Observed in MetaTrader 5
    Validated Against Real Broker Data

    before production use.

    MetaTrader Strategy Tester behavior may differ from live terminal conditions, particularly for:

    Multi-Symbol Data
    Tick Availability
    History Loading
    Broker-Specific Feeds

    A mathematically correct indicator can still be a poor trading strategy.

    Indicator signals do not guarantee:

    Profitability
    Future Direction
    Risk Reduction
    Prop-Firm Compliance
    Execution Quality

    The strongest production workflow is:

    Formal Specification
    → MQL5 Implementation
    → Compile
    → Historical Validation
    → Repainting Audit
    → Multi-Symbol / Multi-Timeframe Validation
    → Live Demo Observation
    → Performance Testing
    → Production Deployment

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 24 days ago

    Requires

    Google Drive
    GitHub
    Dropbox
    Notion
    OpenAI

    Permissions

    Read Files
    Browser
    Write Files

    Allowed Hosts

    drive.googleapis.com
    api.github.com
    api.dropboxapi.com
    api.notion.com
    api.openai.com

    File Scopes

    **/*.mq5
    **/*.mqh
    **/*.ex5
    **/*.set
    **/*.ini
    **/*.cfg
    **/*.json
    **/*.jsonl
    **/*.yaml
    **/*.yml
    **/*.csv
    **/*.tsv
    **/*.txt
    **/*.md
    **/*.log
    **/*.html
    **/*.xml
    **/*.png
    **/*.jpg
    **/*.jpeg
    **/*.webp
    **/*.pdf
    **/*.doc
    **/*.docx
    **/*.xls
    **/*.xlsx
    **/MQL5/**
    **/mql5/**
    **/Indicators/**
    **/indicators/**
    **/Experts/**
    **/experts/**
    **/Include/**
    **/include/**
    **/Libraries/**
    **/libraries/**
    **/Presets/**
    **/presets/**
    **/Profiles/**
    **/profiles/**
    **/Templates/**
    **/templates/**
    **/MetaTrader/**
    **/MetaTrader5/**
    **/MT5/**
    **/mt5/**
    **/trading/**
    **/trading-tools/**
    **/custom-indicators/**
    **/technical-indicators/**
    **/statistical-indicators/**
    **/correlation/**
    **/volatility/**
    **/momentum/**
    **/trend/**
    **/sessions/**
    **/levels/**
    **/multi-symbol/**
    **/multi-timeframe/**
    **/dashboards/**
    **/alerts/**
    **/buffers/**
    **/signals/**
    **/backtests/**
    **/strategy-tester/**
    **/debug/**
    **/logs/**
    **/reports/**
    **/documentation/**
    **/docs/**
    **/output/**

    Use Read Files to inspect authorized: MQL5 Source Code MQH Include Files Indicator Configuration SET Files MetaTrader Logs Compile Errors Runtime Errors Trading Reports Screenshots Symbol Specifications Existing Indicator Documentation EA Integration Requirements Use Write Files only when the user requests creation or modification of derived artifacts such as: MQ5 Indicator Source Files MQH Helper Modules Indicator Documentation Configuration Templates Testing Checklists Debug Reports Buffer Specifications Installation Guides Patched Indicator Versions Use Browser when current external information is materially required, particularly for: Current MQL5 Documentation MetaTrader 5 Build-Specific Behavior Broker Symbol Documentation Updated API Behavior Current Platform Limitations Recommended connected services: GitHub: Highly relevant for version control, indicator source repositories, branches, commits, pull requests, regression tracking, code review, and maintaining multiple indicator versions. Google Drive: Useful for MQL5 source files, SET files, screenshots, documentation, trading reports, exported logs, and development archives. Dropbox: Useful for project backups, compiled indicator packages, screenshots, historical versions, reports, and larger development archives. Notion: Useful for indicator specifications, formula documentation, test plans, version history, buffer definitions, development notes, and product documentation. OpenAI: Relevant for MQL5 engineering, mathematical formalization, debugging, refactoring, validation logic, documentation, and code-generation workflows. When developing a new indicator: First formalize the calculation. Then define: Data Source Symbol Timeframe Lookback Current / Completed Bar Policy Missing-Data Policy Buffer Architecture Plot Architecture Alert Logic Repainting Behavior For multi-symbol indicators: Never assume equal bar indices represent equal timestamps. Use time-based alignment. For multi-timeframe indicators: Clearly distinguish: Current Source Bar from: Completed Source Bar. For cross-market indicators: Always consider trading-session differences. Example: BTC can trade while US500 is closed. Do not silently convert stale benchmark data into new observations. For volume indicators: Explicitly state whether the source is: Tick Volume or: Real Volume. Do not describe tick volume as centralized exchange volume. For statistical indicators: Guard against: Zero Variance Insufficient Samples Division by Zero NaN Infinity Missing Bars For MQL5 architecture: Prefer: Reusable Handles Incremental Recalculation Correct prev_calculated Usage Calculation Buffers Clear Buffer Documentation Avoid: Handle Creation on Every Tick Full-History Recalculation Without Reason Repeated Large Data Copies Unnecessary Chart-Object Updates For signal indicators: State explicitly whether: Bar 0 can change Closed bars can change Higher-timeframe values can change before close Future confirmation is required For EA integration: Document exact buffer indices and values. For patching existing indicators: Preserve unrelated behavior unless the user explicitly requests a redesign. For broker portability: Expose broker-specific symbols through Inputs whenever practical. For deployment: Target: 0 compile errors 0 compile warnings and then test in the user's actual MetaTrader 5 environment. The objective is not merely to produce compilable MQL5 code. The objective is to produce an indicator whose formula, data synchronization, plotted values, alerts, buffers, and historical behavior are technically defensible.

    Listed24 days ago

    What's inside

    Frequently Asked Questions

    This skill creates high-performance MQL5 code that handles complex tasks like multi-symbol synchronization and multi-timeframe analysis without the repainting or 'look-ahead' errors common in standard AI-generated code.

    Yes, the skill is designed to output code with structured indicator buffers and signal states, making it easy for Expert Advisors (EAs) to call via the iCustom function for automated trading.

    The skill generates complete source code (.mq5) files, including all necessary initialization and calculation logic; you simply need to compile it within the MetaEditor included with your MT5 terminal.

    The architect is built specifically for MetaTrader 5 (MQL5) to leverage its superior multi-thread handling and advanced data structures, and it is not backward compatible with MetaTrader 4.

    Absolutely—the skill excels at creating cross-asset tools, such as rolling correlation or spread indicators, by implementing logic that accounts for differing market hours and missing price bars.

    New in Trading & Investing