Porting a Multi-Indicator My-Language Strategy to JavaScript
Summary
This tutorial walks through translating a My-Language trading system into JavaScript. The example calculates a WaveTrend-style indicator from the average of each bar’s high, low, and close, applies exponential moving averages and a normalized deviation, then smooths the result with a weighted recursive average. The article notes that the platform’s available simple moving average does not match the three-argument My-Language SMA, so it implements the required recurrence directly. It then maps indicator crossovers to long and short entries, accounting for the source language’s delayed signal reference and the platform’s position-state handling.
The explanation covers array construction, indicator validity checks, and a close-based update pattern intended to speed backtests. It shows side-by-side backtest material for the original and translated versions, but the text gives no numerical performance comparison or proof of exact equivalence. Translation details such as missing values, initialization, crossover timing, and order-state transitions can change results; the author also flags the signal offset as something that must be understood rather than assumed.
Key ideas
- Translate each source indicator step into an equivalent JavaScript calculation while preserving array alignment.
- Implement the source language’s weighted SMA recurrence when a library function has different semantics.
- Check input lengths and invalid values before calculating dependent indicators.
- Signal timing must account for the source strategy’s prior-bar reference and crossover behavior.
- Backtest comparison is useful, but the article does not report numerical results or establish exact equivalence.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.