Modified God Mode (MG)

Parameters: n1 = 17 | n2 = 6 | n3 = 4 | mode = tradition_mg | use_volume = true

Overview

The Modified God Mode indicator creates a sophisticated composite oscillator by intelligently averaging multiple momentum components including TCI, RSI or MFI, CSI variants, Williams %R, CBCI, and Laguerre RSI into a single unified signal. This multi layered approach captures different aspects of market momentum simultaneously, with each component contributing its unique perspective on price action to produce a more robust overall reading than any single oscillator could provide. The indicator generates three outputs: a wavetrend line showing the composite momentum value, a signal line smoothed with a 6 period SMA for crossover signals, and a histogram displaying the difference between them to highlight momentum shifts. Traders value this indicator for its ability to filter out false signals that plague individual oscillators, as the averaging process requires multiple components to align before generating strong readings. The various mode options allow adaptation to different market conditions, with tradition_mg mode incorporating volume through Money Flow Index when available, adding another dimension to the momentum analysis that pure price based oscillators miss.

Implementation Examples

Get wavetrend, signal, and histogram in a few lines:

use vector_ta::indicators::mod_god_mode::{mod_god_mode, ModGodModeInput, ModGodModeParams, ModGodModeMode};
use vector_ta::utilities::data_loader::{Candles, read_candles_from_csv};

// Using with OHLCV slices
let high = vec![/* ... */];
let low = vec![/* ... */];
let close = vec![/* ... */];
let volume = vec![/* ... */];
let params = ModGodModeParams { n1: Some(17), n2: Some(6), n3: Some(4), mode: Some(ModGodModeMode::TraditionMg), use_volume: Some(true) };
let input = ModGodModeInput::from_slices(&high, &low, &close, Some(&volume), params);
let out = mod_god_mode(&input)?; // out.wavetrend, out.signal, out.histogram

// Using with Candles and defaults (n1=17, n2=6, n3=4, mode=tradition_mg, use_volume=true)
let candles: Candles = read_candles_from_csv("data/sample.csv")?;
let input = ModGodModeInput::with_default_candles(&candles);
let out = mod_god_mode(&input)?;

API Reference

Input Methods
// From slices (volume optional)
ModGodModeInput::from_slices(&[f64], &[f64], &[f64], Option<&[f64]>, ModGodModeParams) -> ModGodModeInput

// From candles
ModGodModeInput::from_candles(&Candles, ModGodModeParams) -> ModGodModeInput

// Candles with library defaults (n1=17, n2=6, n3=4, mode=TraditionMg, use_volume=true)
ModGodModeInput::with_default_candles(&Candles) -> ModGodModeInput
Parameters Structure
#[derive(Debug, Clone)]
pub enum ModGodModeMode { Godmode, Tradition, GodmodeMg, TraditionMg }
// Default: TraditionMg

#[derive(Debug, Clone)]
pub struct ModGodModeParams {
    pub n1: Option<usize>,       // Default: 17
    pub n2: Option<usize>,       // Default: 6
    pub n3: Option<usize>,       // Default: 4
    pub mode: Option<ModGodModeMode>, // Default: TraditionMg
    pub use_volume: Option<bool>,     // Default: true
}
Output Structure
#[derive(Debug, Clone)]
pub struct ModGodModeOutput {
    pub wavetrend: Vec<f64>,  // composite oscillator
    pub signal: Vec<f64>,     // SMA(6) of wavetrend
    pub histogram: Vec<f64>,  // EMA(n3) of ((wt - sig)*2 + 50)
}
Validation, Warmup & NaNs
  • n1 > 0, n2 > 0, n3 > 0; otherwise ModGodModeError::InvalidPeriod.
  • Requires at least max(n1, n2, n3) valid points after first finite value; else NotEnoughValidData.
  • Leading indices are NaN until warmup; signal/histogram start after an extra 5 samples due to SMA(6).
  • use_volume=true uses MFI for MF; otherwise MF falls back to RSI.
  • Streaming returns None until ring buffer reaches max(n1, n2, n3).
Error Handling
use vector_ta::indicators::mod_god_mode::{mod_god_mode, ModGodModeError};

match mod_god_mode(&input) {
    Ok(o) => handle(o),
    Err(ModGodModeError::EmptyInputData) => eprintln!("Input data is empty"),
    Err(ModGodModeError::AllValuesNaN) => eprintln!("All input values are NaN"),
    Err(ModGodModeError::InvalidPeriod { n1, n2, n3, data_len }) =>
        eprintln!("Invalid period n1={}, n2={}, n3={}, len={}", n1, n2, n3, data_len),
    Err(ModGodModeError::NotEnoughValidData { needed, valid }) =>
        eprintln!("Need {} valid points after first finite, got {}", needed, valid),
    Err(ModGodModeError::InvalidDestinationLen { dst, src }) =>
        eprintln!("Destination length {} != source {}", dst, src),
    Err(ModGodModeError::InvalidKernelForBatch) => eprintln!("Invalid batch kernel"),
    Err(ModGodModeError::CalculationError(msg)) => eprintln!("Calc error: {}", msg),
}

Python Bindings

Basic Usage

Calculate wavetrend, signal, and histogram (tuple of arrays):

import numpy as np
from vector_ta import mod_god_mode, ModGodModeStream

high = np.array([...], dtype=float)
low = np.array([...], dtype=float)
close = np.array([...], dtype=float)
volume = np.array([...], dtype=float)

wt, sig, hist = mod_god_mode(
    high, low, close,
    volume=volume,    # or None
    n1=17, n2=6, n3=4,
    mode="tradition_mg",
    use_volume=True,
    kernel="auto"
)
Streaming
from vector_ta import ModGodModeStream

stream = ModGodModeStream(n1=17, n2=6, n3=4, mode="tradition_mg", use_volume=False)
for h, l, c in zip(high, low, close):
    out = stream.update(h, l, c, volume=None)
    if out is not None:
        wt, sig, hist = out
# Reset when needed
stream.reset()
Batch (Parameter Sweep)

Returns dict with matrices and tested params:

from vector_ta import mod_god_mode_batch

result = mod_god_mode_batch(
    high, low, close,
    volume=None,
    n1_range=(12, 20, 2),
    n2_range=(4, 8, 2),
    n3_range=(3, 5, 1),
    mode="tradition_mg",
    kernel="auto"
)

wt = result["wavetrend"]      # shape: (rows, len)
sig = result["signal"]        # shape: (rows, len)
hist = result["histogram"]    # shape: (rows, len)
rows, cols = result["rows"], result["cols"]
n1s, n2s, n3s = result["n1s"], result["n2s"], result["n3s"]
modes = result["modes"]
CUDA Acceleration

CUDA helpers are available when the Python package is built with CUDA support. Inputs must be float32; outputs are device arrays (DLPack / __cuda_array_interface__ compatible).

import numpy as np
from vector_ta import mod_god_mode_cuda_batch_dev, mod_god_mode_cuda_many_series_one_param_dev

# One series (float32)
high_f32 = np.asarray(load_high(), dtype=np.float32)
low_f32 = np.asarray(load_low(), dtype=np.float32)
close_f32 = np.asarray(load_close(), dtype=np.float32)

dev = mod_god_mode_cuda_batch_dev(
    high_f32=high_f32,
    low_f32=low_f32,
    close_f32=close_f32,
    n1_range=(2, 20, 2),
    n2_range=(2, 20, 2),
    n3_range=(2, 20, 2),
    mode=14,
    use_volume=False,
    volume_f32=14,
    device_id=0,
)

# Many series (time-major)
high_tm_f32 = np.asarray(load_high_time_major_matrix(), dtype=np.float32)
rows, cols = high_tm_f32.shape
high_tm_f32 = high_tm_f32.ravel()
low_tm_f32 = np.asarray(load_low_time_major_matrix(), dtype=np.float32)
low_tm_f32 = low_tm_f32.ravel()
close_tm_f32 = np.asarray(load_close_time_major_matrix(), dtype=np.float32)
close_tm_f32 = close_tm_f32.ravel()

dev_tm = mod_god_mode_cuda_many_series_one_param_dev(
    high_tm_f32=high_tm_f32,
    low_tm_f32=low_tm_f32,
    close_tm_f32=close_tm_f32,
    cols=cols,
    rows=rows,
    n1=14,
    n2=14,
    n3=14,
    mode=14,
    use_volume=False,
    volume_tm_f32=14,
    device_id=0,
)

JavaScript/WASM Bindings

Basic Usage

Calculate MG in JavaScript/TypeScript; returns {{ wavetrend, signal, histogram }}:

import { mod_god_mode } from 'vectorta-wasm';

const high = new Float64Array([/* ... */]);
const low = new Float64Array([/* ... */]);
const close = new Float64Array([/* ... */]);
const volume = new Float64Array([/* ... */]);

const out = mod_god_mode(
  high, low, close,
  volume,        // or null/undefined
  17, 6, 4,      // n1, n2, n3 (optional)
  'tradition_mg',
  true           // use_volume
);

console.log(out.wavetrend.length, out.signal.length, out.histogram.length);
Memory-Efficient Operations

Use zero-copy “into” APIs for large datasets; allocate and map inputs/outputs in WASM memory:

import { mod_god_mode_alloc, mod_god_mode_free, mod_god_mode_into, memory } from 'vectorta-wasm';

const len = high.length;

// Allocate and copy inputs
const highPtr = mod_god_mode_alloc(len);
const lowPtr  = mod_god_mode_alloc(len);
const closePtr= mod_god_mode_alloc(len);
const volPtr  = mod_god_mode_alloc(len);
new Float64Array(memory.buffer, highPtr, len).set(high);
new Float64Array(memory.buffer, lowPtr,  len).set(low);
new Float64Array(memory.buffer, closePtr,len).set(close);
new Float64Array(memory.buffer, volPtr,  len).set(volume);

// Allocate outputs
const outWPtr = mod_god_mode_alloc(len);
const outSPtr = mod_god_mode_alloc(len);
const outHPtr = mod_god_mode_alloc(len);

// Pass mode as string; has_volume indicates whether vol_ptr is used
mod_god_mode_into(
  highPtr, lowPtr, closePtr, volPtr,
  len, /* has_volume= */ true,
  17, 6, 4, 'tradition_mg',
  outWPtr, outSPtr, outHPtr
);

// Read results
const wt = new Float64Array(memory.buffer, outWPtr, len).slice();
const sig = new Float64Array(memory.buffer, outSPtr, len).slice();
const hist = new Float64Array(memory.buffer, outHPtr, len).slice();

// Free allocations
for (const [ptr] of [[highPtr],[lowPtr],[closePtr],[volPtr],[outWPtr],[outSPtr],[outHPtr]]) {
  mod_god_mode_free(ptr, len);
}
Flat Output Variant

Flat layout for the three outputs (row-major [wt..., sig..., hist...]):

import { mod_god_mode_js_flat } from 'vectorta-wasm';

const res = mod_god_mode_js_flat(high, low, close, null, 17, 6, 4, 'tradition_mg', false);
// res has: { values: Float64Array, rows: 3, cols: len }
const { values, rows, cols } = res;
const wt = values.slice(0, cols);
const sig = values.slice(cols, 2*cols);
const hist = values.slice(2*cols, 3*cols);

CUDA Bindings (Rust)

use vector_ta::cuda::CudaModGodModeBatchResult;
use vector_ta::indicators::mod_god_mode::ModGodModeBatchRange;

let cuda = CudaModGodModeBatchResult::new(0)?;

let high: [f32] = /* ... */;
let low: [f32] = /* ... */;
let close: [f32] = /* ... */;
let volume: Option<&[f32]> = /* ... */;
let sweep = ModGodModeBatchRange::default();

let out = cuda.mod_god_mode_batch_dev(&high, &low, &close, volume, &sweep)?;
let _ = out;

Performance Analysis

Comparison:
View:
Loading chart...

AMD Ryzen 9 9950X (CPU) | NVIDIA RTX 4090 (GPU) | Benchmarks: 2026-02-28

Related Indicators