> ## Documentation Index
> Fetch the complete documentation index at: https://gocharting.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Oscillators across languages

> How Lipi maps to MQL4, MQL5, NinjaScript, Pine Script and thinkScript for oscillators: commodity channel index, chande momentum oscillator, center of gravity, directional movement index, macd, money flow index and more, with the differences that matter when converting.

The built-in oscillators and momentum indicators. Each row maps one concept from Lipi to the other languages; the word in a cell is the relation, explained in the [language map overview](https://gocharting.com/docs/scripting/reference/language-map.md#relations).

| Concept | Lipi | MQL4 | MQL5 | NinjaScript | Pine Script | thinkScript |
| - | - | - | - | - | - | - |
| [Commodity channel index](#ta-cci) | `ta.cci` | Caveat | Caveat | Caveat | Caveat | Caveat |
| [Chande momentum oscillator](#ta-cmo) | `ta.cmo` | Absent | Absent | Exact | Caveat | Caveat |
| [Center of gravity](#ta-cog) | `ta.cog` | Absent | Absent | Absent | Caveat | Absent |
| [Directional movement index](#ta-dmi) | `ta.dmi` | Caveat | Differs | Caveat | Caveat | Caveat |
| [MACD](#ta-macd) | `ta.macd` | Caveat | Caveat | Caveat | Caveat | Caveat |
| [Money flow index](#ta-mfi) | `ta.mfi` | Caveat | Caveat | Exact | Caveat | Caveat |
| [Rate of change](#ta-roc) | `ta.roc` | Caveat | Unresolved | Caveat | Caveat | Caveat |
| [Relative strength index](#ta-rsi) | `ta.rsi` | Caveat | Caveat | Caveat | Caveat | Caveat |
| [Stochastic](#ta-stoch) | `ta.stoch` | Differs | Differs | Caveat | Caveat | Caveat |
| [True strength index](#ta-tsi) | `ta.tsi` | Absent | Absent | Caveat | Differs | Caveat |
| [Williams %R](#ta-wpr) | `ta.wpr` | Caveat | Caveat | Caveat | Differs | Differs |

Each section below gives the Lipi construct first, then the construct in each language, with a note wherever behaviour differs. The language name links to the documentation the row was checked against.

## Commodity channel index

Commodity Channel Index for `source` over `length` bars.

In Lipi: `ta.cci`.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/indicators/icci#iCCI) | `iCCI` | Equivalent, with a caveat | Source is an applied-price constant, not any series. iCCIOnArray takes array data instead. History indexing: shift counts bars back from the current bar; shift 0 is the still-forming bar, and any shift can be read in one call. Other timeframes: symbol and timeframe arguments read another symbol or period directly; Lipi ta calls use the chart's own bars. |
| [MQL5](https://www.mql5.com/en/docs/indicators/icci) | `iCCI` | Equivalent, with a caveat | Price is an applied-price constant or another indicator's handle, not an arbitrary series. One buffer. State and side effects: Returns a handle; values are read later with CopyBuffer and are not ready right after creation. History indexing: CopyBuffer start\_pos 0 is the current bar and counts toward the past; copied data lands oldest-first. Other timeframes: Symbol and timeframe are explicit arguments, so another symbol or timeframe is requested directly. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/entering_calculation_logic6.htm) | `CCI` | Equivalent, with a caveat | NinjaTrader's CCI has values from the first bar (0, then partial windows); Lipi's ta.cci is na until bar length-1. |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/#fun_ta.cci) | `ta.cci` | Equivalent, with a caveat | Pine's reference says na source values are ignored; Lipi's ta.cci returns na on a bar whose source is na. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/C-D/CCI) | `CCI` | Equivalent, with a caveat | Study page lists no price input, only length and level settings; Lipi ta.cci takes an explicit source series. |

## Chande momentum oscillator

Chande Momentum Oscillator for `source` over `length` bars.

In Lipi: `ta.cmo`.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/indicators) | | Not in MQL4 | No Chande Momentum Oscillator among the indicator functions. |
| [MQL5](https://www.mql5.com/en/docs/indicators) | | Not in MQL5 | No Chande Momentum Oscillator among the built-in indicators. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/chande_momentum_oscillator_cmo.htm) | `CMO` | Exact | |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/#fun_ta.cmo) | `ta.cmo` | Equivalent, with a caveat | Pine's reference says na source values are ignored; Lipi's ta.cmo returns na on a bar whose source is na. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/C-D/ChandeMomentumOscillator) | `ChandeMomentumOscillator` | Equivalent, with a caveat | Study page lists only length (no source input) and adds fixed +50/-50 level plots; scale is -100 to 100. |

## Center of gravity

Centre of gravity of `source` across a window of `length` bars.

In Lipi: `ta.cog`.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/indicators) | | Not in MQL4 | No centre-of-gravity function among the indicator functions. |
| [MQL5](https://www.mql5.com/en/docs/indicators) | | Not in MQL5 | No centre-of-gravity indicator among the built-in indicators. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/indicators.htm) | | Not in NinjaScript | No centre-of-gravity indicator in the system list; code the weighted sum by hand. |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/#fun_ta.cog) | `ta.cog` | Equivalent, with a caveat | Pine's reference says na source values are ignored; Lipi's ta.cog returns na on a bar whose source is na. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library) | | Not in thinkScript | No centre-of-gravity function or study in the functions list or the study library. |

## Directional movement index

The directional movement family in one call, calculated from the chart's own bars.

In Lipi: `ta.dmi`. Smooths true range and directional movement with alpha 2/(length+1); the ADX stage uses RMA.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/indicators/iadx) | `iADX` | Equivalent, with a caveat | One call returns one line by mode (0 ADX, 1 +DI, 2 -DI) from a single period; Lipi takes two lengths and returns a tuple. History indexing: shift counts bars back from the current bar; shift 0 is the still-forming bar, and any shift can be read in one call. Other timeframes: symbol and timeframe arguments read another symbol or period directly; Lipi ta calls use the chart's own bars. |
| [MQL5](https://www.mql5.com/en/docs/indicators/iadx) | `iADX` | Looks alike, behaves differently | One period argument, not two. Buffers are 0 ADX, 1 plus DI, 2 minus DI, while Lipi returns plus DI, minus DI, then ADX. State and side effects: Returns a handle; values are read later with CopyBuffer and are not ready right after creation. History indexing: CopyBuffer start\_pos 0 is the current bar and counts toward the past; copied data lands oldest-first. Other timeframes: Symbol and timeframe are explicit arguments, so another symbol or timeframe is requested directly. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/directional_movement_dm.htm) | `DM` | Equivalent, with a caveat | One period only, with no separate ADX smoothing length. Default series is ADX; read .DiPlus and .DiMinus as properties, not a tuple. |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/) | `ta.dmi` | Equivalent, with a caveat | The reference does not state Pine's smoothing. Lipi smooths true range and movement with alpha 2/(length+1) and ADX with RMA; compare values. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/C-D/DMI) | `DMI` | Equivalent, with a caveat | One length drives DI+, DI- and ADX, with Wilder smoothing by default; Lipi ta.dmi takes separate diLength and adxSmoothing. |

## MACD

Moving average convergence/divergence for `source`, from three lengths: `fastlen`, `slowlen` and `siglen`.

In Lipi: `ta.macd`.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/indicators/imacd) | `iMACD` | Equivalent, with a caveat | One call returns the main or signal line by mode; no histogram mode (use iOsMA or subtract). Source is an applied-price constant, not any series. History indexing: shift counts bars back from the current bar; shift 0 is the still-forming bar, and any shift can be read in one call. Other timeframes: symbol and timeframe arguments read another symbol or period directly; Lipi ta calls use the chart's own bars. |
| [MQL5](https://www.mql5.com/en/docs/indicators/imacd) | `iMACD` | Equivalent, with a caveat | Buffers are 0 main and 1 signal only; there is no histogram buffer (iOsMA provides it). Lipi returns three values. State and side effects: Returns a handle; values are read later with CopyBuffer and are not ready right after creation. History indexing: CopyBuffer start\_pos 0 is the current bar and counts toward the past; copied data lands oldest-first. Other timeframes: Symbol and timeframe are explicit arguments, so another symbol or timeframe is requested directly. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/moving_average_convergence-divergence_macd.htm) | `MACD` | Equivalent, with a caveat | Line, signal and histogram come back as the default series, .Avg and .Diff properties, not a tuple. Arguments are fast, slow, smooth. |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/) | `ta.macd` | Equivalent, with a caveat | Pine's reference says na source values are ignored; Lipi's ta.macd returns na on a bar whose source is na. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/M-N/MACD) | `MACD` | Equivalent, with a caveat | Adds a selectable average type for all averages; plots Value, Avg, Diff in that order, matching Lipi's \[macd, signal, histogram] order. |

## Money flow index

Money Flow Index for `source` over `length` bars.

In Lipi: `ta.mfi`.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/indicators/imfi#iMFI) | `iMFI` | Equivalent, with a caveat | No source argument. Not iBWMFI, which is the Bill Williams Market Facilitation Index. History indexing: shift counts bars back from the current bar; shift 0 is the still-forming bar, and any shift can be read in one call. Other timeframes: symbol and timeframe arguments read another symbol or period directly; Lipi ta calls use the chart's own bars. |
| [MQL5](https://www.mql5.com/en/docs/indicators/imfi) | `iMFI` | Equivalent, with a caveat | Volume type is chosen with applied\_volume; the price input is not an argument. Lipi takes a source series instead. State and side effects: Returns a handle; values are read later with CopyBuffer and are not ready right after creation. History indexing: CopyBuffer start\_pos 0 is the current bar and counts toward the past; copied data lands oldest-first. Other timeframes: Symbol and timeframe are explicit arguments, so another symbol or timeframe is requested directly. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/money_flow_index_mfi.htm) | `MFI` | Exact | |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/#fun_ta.mfi) | `ta.mfi` | Equivalent, with a caveat | Pine's reference says na source values are ignored; Lipi's ta.mfi returns na on a bar whose source is na. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/M-N/MoneyFlowIndex) | `MoneyFlowIndex` | Equivalent, with a caveat | Built on typical price and volume, with no source input, and an extra moving-average length setting; Lipi ta.mfi takes a source. |

## Rate of change

Rate of change of `source` measured across `length` bars.

In Lipi: `ta.roc`.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/indicators/imomentum#iMomentum) | `iMomentum` | Equivalent, with a caveat | Nearest built-in; the docs give no formula or scale, so confirm it matches a percentage rate of change before use. History indexing: shift counts bars back from the current bar; shift 0 is the still-forming bar, and any shift can be read in one call. Other timeframes: symbol and timeframe arguments read another symbol or period directly; Lipi ta calls use the chart's own bars. |
| [MQL5](https://www.mql5.com/en/docs/indicators/imomentum) | | Unresolved | Nearest built-in is iMomentum, but its page does not say whether it is a ratio, percent or difference, so the mapping is unconfirmed. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/rate_of_change_roc.htm) | `ROC` | Equivalent, with a caveat | Percent change against the value period bars ago, the same percent scale as Lipi's ta.roc. |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/#fun_ta.roc) | `ta.roc` | Equivalent, with a caveat | Same percent change on clean data; Pine gives na when the source or its lagged value is na, Lipi resumes right after. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/R-S/RateOfChange) | `RateOfChange` | Equivalent, with a caveat | Percent change against the price length bars back, the same scale as Lipi's ta.roc. The study also takes a price input. |

## Relative strength index

Relative Strength Index for `source` over `length` bars.

In Lipi: `ta.rsi`.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/indicators/irsi#iRSI) | `iRSI` | Equivalent, with a caveat | Source is an applied-price constant, not any series. iRSIOnArray takes array data instead. History indexing: shift counts bars back from the current bar; shift 0 is the still-forming bar, and any shift can be read in one call. Other timeframes: symbol and timeframe arguments read another symbol or period directly; Lipi ta calls use the chart's own bars. |
| [MQL5](https://www.mql5.com/en/docs/indicators/irsi) | `iRSI` | Equivalent, with a caveat | Price is an applied-price constant or another indicator's handle, not an arbitrary series. One buffer. State and side effects: Returns a handle; values are read later with CopyBuffer and are not ready right after creation. History indexing: CopyBuffer start\_pos 0 is the current bar and counts toward the past; copied data lands oldest-first. Other timeframes: Symbol and timeframe are explicit arguments, so another symbol or timeframe is requested directly. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/relative_strength_index_rsi.htm) | `RSI` | Equivalent, with a caveat | Extra required smooth argument; the .Avg series is the smoothed line. Wilder smoothing is stated on the page. |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/#fun_ta.rsi) | `ta.rsi` | Equivalent, with a caveat | Pine's reference says na source values are ignored; Lipi's ta.rsi returns na on a bar whose source is na. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/R-S/RSI) | `RSI` | Equivalent, with a caveat | Wilder smoothing by default but the average type is selectable; also takes a price input and level settings. Lipi ta.rsi takes only source and length. |

## Stochastic

Stochastic reading that places `source` inside the span set by `high` and `low` over `length` bars.

In Lipi: `ta.stoch`.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/indicators/istochastic#iStochastic) | `iStochastic` | Looks alike, behaves differently | Built-in has slowing, a %D line and a price\_field (0 Low/High, 1 Close/Close), with no source, high or low series; not Lipi's raw form. History indexing: shift counts bars back from the current bar; shift 0 is the still-forming bar, and any shift can be read in one call. Other timeframes: symbol and timeframe arguments read another symbol or period directly; Lipi ta calls use the chart's own bars. |
| [MQL5](https://www.mql5.com/en/docs/indicators/istochastic) | `iStochastic` | Looks alike, behaves differently | Returns smoothed lines (K, D, slowing) from the bar's own prices; Lipi gives one raw reading on supplied series. Buffers: 0 main, 1 signal. State and side effects: Returns a handle; values are read later with CopyBuffer and are not ready right after creation. History indexing: CopyBuffer start\_pos 0 is the current bar and counts toward the past; copied data lands oldest-first. Other timeframes: Symbol and timeframe are explicit arguments, so another symbol or timeframe is requested directly. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/stochastics_fast.htm) | `StochasticsFast` | Equivalent, with a caveat | Closest is StochasticsFast with .K and .D, taking periods only, with no high and low series. |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/#fun_ta.stoch) | `ta.stoch` | Equivalent, with a caveat | Lipi's ta.stoch returns values from bar 0 over a partial window, and na on a bar whose source is na. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Tech-Analysis/FastKCustom) | `FastKCustom` | Equivalent, with a caveat | Scales one series between its own highest and lowest over length bars (0 on a flat range); Lipi ta.stoch takes separate high and low series. |

## True strength index

True Strength Index for `source`, smoothed by two lengths, `r` and `s`.

In Lipi: `ta.tsi`.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/indicators) | | Not in MQL4 | No True Strength Index among the indicator functions. |
| [MQL5](https://www.mql5.com/en/docs/indicators) | | Not in MQL5 | No True Strength Index among the built-in indicators. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/true_strength_index_tsi.htm) | `TSI` | Equivalent, with a caveat | Arguments are fast then slow; the page does not map them onto Lipi's r and s, so check the pairing. |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/#fun_ta.tsi) | `ta.tsi` | Looks alike, behaves differently | Pine returns -1 to 1; Lipi multiplies by 100. Pine takes short then long length; Lipi takes r (long) then s (short). |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/T-U/TrueStrengthIndex) | `TrueStrengthIndex` | Equivalent, with a caveat | Study also yields a Signal average and takes an average type; the long length comes first, so map it to Lipi's r and s carefully. |

## Williams %R

Williams %R over `length` bars.

In Lipi: `ta.wpr`.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/indicators/iwpr#iWPR) | `iWPR` | Equivalent, with a caveat | Value is read at the shift you pass. Lipi's wpr reads the previous bar, so compare with a shift of 1. History indexing: shift counts bars back from the current bar; shift 0 is the still-forming bar, and any shift can be read in one call. Bar timing: Lipi's wpr lags the chart by one bar; iWPR has no stated lag. |
| [MQL5](https://www.mql5.com/en/docs/indicators/iwpr) | `iWPR` | Equivalent, with a caveat | One buffer, period is calc\_period. Lipi's reference says its wpr lags one bar; CopyBuffer position 0 is the current bar's reading. Bar timing: Lipi's wpr reads the previous bar's values; here position 0 is the current bar. State and side effects: Returns a handle; values are read later with CopyBuffer and are not ready right after creation. Other timeframes: Symbol and timeframe are explicit arguments, so another symbol or timeframe is requested directly. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/williams_r.htm) | `WilliamsR` | Equivalent, with a caveat | Scale runs 0 to -100. Lipi's build reads the previous bar, so its value lags one bar; NinjaTrader documents no such lag. Bar timing: Lipi's value is the previous bar's reading. |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/#fun_ta.wpr) | `ta.wpr` | Looks alike, behaves differently | Pine reads the current bar's high, low and close. Lipi's build reads the previous bar's, so its value lags Pine's by one bar. Bar timing: Lipi shows %R as of the prior bar; Pine shows it for the current bar. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Tech-Analysis/Lowest) | `WilliamsPercentR` | Looks alike, behaves differently | The thinkScript formula uses highest and lowest including the current bar; Lipi ta.wpr is lagged one bar. Scale is 0 to -100 in both. Bar timing: thinkScript reads the current bar's high, low and close; Lipi reads the previous bar's values. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.