KababaliScript 2.4 Language Reference
KababaliScript (KSL) is the executable strategy language for custom and AI-generated algorithmic trading strategies for MetaTrader 5 (MT5) on Kababali. The compiler, closed-candle runtime, chart preview, and Historical Backtest read one native capability registry. AUTO AI Brain may generate only compiler-valid KSL candidates; MANUAL executes the exact trader-activated KSL without adaptive rewriting. Both paths use the same indicators and conditions while remaining isolated strategy authorities. The MT5 EA v3.84 stays a clean, guarded executor and does not recalculate local strategy indicators.
Compiler-to-execution parity
A capability is shown as executable only when validation, runtime evaluation, chart preview, and historical replay share the implementation.
Executable capability registry
Every card below is available to AUTO candidate validation, exact MANUAL execution, chart preview, and Historical Backtest.
ema()seriesDeterministic Trend capability backed by the shared closed-candle KSL runtime.
ema(close, 9)
sma()seriesDeterministic Trend capability backed by the shared closed-candle KSL runtime.
sma(close, 20)
wma()seriesDeterministic Trend capability backed by the shared closed-candle KSL runtime.
wma(close, 20)
dema()seriesDouble EMA with reduced lag for responsive trend filtering.
dema(close, 20)
tema()seriesTriple EMA with stronger lag reduction for trend confirmation.
tema(close, 20)
hma()seriesHull moving average using weighted smoothing for fast, low-lag trend tracking.
hma(close, 20)
smma()seriesWilder-style smoothed moving average for stable trend and volatility calculations.
smma(close, 20)
rsi()seriesDeterministic Momentum capability backed by the shared closed-candle KSL runtime.
rsi(close, 14)
stochastic_k()seriesDeterministic Momentum capability backed by the shared closed-candle KSL runtime.
stochastic_k(high, low, close, 14)
stochastic_d()seriesDeterministic Momentum capability backed by the shared closed-candle KSL runtime.
stochastic_d(high, low, close, 14, 3)
cci()seriesDeterministic Momentum capability backed by the shared closed-candle KSL runtime.
cci(high, low, close, 20)
momentum()seriesDeterministic Momentum capability backed by the shared closed-candle KSL runtime.
momentum(close, 14)
roc()seriesPercentage rate of change against the selected historical period.
roc(close, 14)
williams_r()seriesWilliams %R oscillator scaled from -100 to 0.
williams_r(high, low, close, 14)
awesome_oscillator()seriesFast-minus-slow SMA of median price for momentum regime analysis.
awesome_oscillator(high, low, 5, 34)
macd_line()seriesDeterministic Momentum capability backed by the shared closed-candle KSL runtime.
macd_line(close, 12, 26)
macd_signal()seriesDeterministic Momentum capability backed by the shared closed-candle KSL runtime.
macd_signal(close, 12, 26, 9)
adx()seriesDeterministic Momentum capability backed by the shared closed-candle KSL runtime.
adx(high, low, close, 14)
plus_di()seriesDeterministic Momentum capability backed by the shared closed-candle KSL runtime.
plus_di(high, low, close, 14)
minus_di()seriesDeterministic Momentum capability backed by the shared closed-candle KSL runtime.
minus_di(high, low, close, 14)
atr()seriesDeterministic Volatility capability backed by the shared closed-candle KSL runtime.
atr(14)
true_range()seriesPer-candle true range including gaps from the prior close.
true_range(high, low, close)
bb_mid()seriesDeterministic Volatility capability backed by the shared closed-candle KSL runtime.
bb_mid(close, 20)
bb_upper()seriesDeterministic Volatility capability backed by the shared closed-candle KSL runtime.
bb_upper(close, 20, 2.0)
bb_lower()seriesDeterministic Volatility capability backed by the shared closed-candle KSL runtime.
bb_lower(close, 20, 2.0)
stddev()seriesRolling population standard deviation of a series.
stddev(close, 20)
variance()seriesRolling population variance of a series.
variance(close, 20)
zscore()seriesRolling standard score showing distance from the mean in standard deviations.
zscore(close, 20)
linear_regression()seriesRolling least-squares regression value at the latest point in each window.
linear_regression(close, 20)
slope()seriesRolling least-squares slope of a series.
slope(close, 20)
median()seriesRolling statistical median of a series.
median(close, 20)
typical_price()seriesAverage of high, low, and close.
typical_price(high, low, close)
weighted_close()seriesWeighted close price: high + low + 2×close, divided by four.
weighted_close(high, low, close)
vwap()seriesDeterministic Volume capability backed by the shared closed-candle KSL runtime.
vwap(close, volume)
obv()seriesDeterministic Volume capability backed by the shared closed-candle KSL runtime.
obv(close, volume)
mfi()seriesDeterministic Momentum capability backed by the shared closed-candle KSL runtime.
mfi(high, low, close, volume, 14)
chaikin_money_flow()seriesRolling Chaikin Money Flow from OHLC and volume.
chaikin_money_flow(high, low, close, volume, 20)
volume_sma()seriesSimple moving average of volume for participation filters.
volume_sma(volume, 20)
keltner_mid()seriesEMA center line for a Keltner Channel.
keltner_mid(close, 20)
keltner_upper()seriesEMA center plus ATR multiplied by the registered channel multiplier.
keltner_upper(close, high, low, close, 20, 1.5)
keltner_lower()seriesEMA center minus ATR multiplied by the registered channel multiplier.
keltner_lower(close, high, low, close, 20, 1.5)
supertrend()seriesDeterministic Trend capability backed by the shared closed-candle KSL runtime.
supertrend(high, low, close, 14, 3.0)
parabolic_sar()seriesDeterministic Trend capability backed by the shared closed-candle KSL runtime.
parabolic_sar(high, low, 0.02, 0.2)
pivot_point()seriesDeterministic Price levels capability backed by the shared closed-candle KSL runtime.
pivot_point(high, low, close)
pivot_r1()seriesDeterministic Price levels capability backed by the shared closed-candle KSL runtime.
pivot_r1(high, low, close)
pivot_s1()seriesDeterministic Price levels capability backed by the shared closed-candle KSL runtime.
pivot_s1(high, low, close)
pivot_r2()seriesDeterministic Price levels capability backed by the shared closed-candle KSL runtime.
pivot_r2(high, low, close)
pivot_s2()seriesDeterministic Price levels capability backed by the shared closed-candle KSL runtime.
pivot_s2(high, low, close)
donchian_high()seriesDeterministic Volatility capability backed by the shared closed-candle KSL runtime.
donchian_high(high, 20)
donchian_low()seriesDeterministic Volatility capability backed by the shared closed-candle KSL runtime.
donchian_low(low, 20)
highest()seriesDeterministic Statistics capability backed by the shared closed-candle KSL runtime.
highest(high, 20)
lowest()seriesDeterministic Statistics capability backed by the shared closed-candle KSL runtime.
lowest(low, 20)
ichimoku_conversion()seriesDeterministic Trend capability backed by the shared closed-candle KSL runtime.
ichimoku_conversion(9)
ichimoku_base()seriesDeterministic Trend capability backed by the shared closed-candle KSL runtime.
ichimoku_base(26)
ichimoku_span_a()seriesDeterministic Trend capability backed by the shared closed-candle KSL runtime.
ichimoku_span_a(9, 26)
ichimoku_span_b()seriesDeterministic Trend capability backed by the shared closed-candle KSL runtime.
ichimoku_span_b(52)
higher_close()seriesDeterministic Higher timeframe capability backed by the shared closed-candle KSL runtime.
higher_close(M5)
higher_ema()seriesDeterministic Higher timeframe capability backed by the shared closed-candle KSL runtime.
higher_ema(M5, close, 21)
custom_ma()seriesDeterministic Trend capability backed by the shared closed-candle KSL runtime.
custom_ma(close, 20, EMA)
custom_oscillator()seriesDeterministic Momentum capability backed by the shared closed-candle KSL runtime.
custom_oscillator(close, 14, RSI)
crossover()boolDeterministic Signal conditions capability backed by the shared closed-candle KSL runtime.
crossover(fastEma, slowEma)
crossunder()boolDeterministic Signal conditions capability backed by the shared closed-candle KSL runtime.
crossunder(fastEma, slowEma)
rising()boolTrue when the current value is above every value in the prior lookback window.
rising(close, 3)
falling()boolTrue when the current value is below every value in the prior lookback window.
falling(close, 3)
above_for()boolTrue only when the first series stayed above the second for all requested closed candles.
above_for(fastEma, slowEma, 3)
below_for()boolTrue only when the first series stayed below the second for all requested closed candles.
below_for(fastEma, slowEma, 3)
break_of_structure_up()boolDeterministic Market structure capability backed by the shared closed-candle KSL runtime.
break_of_structure_up(20)
break_of_structure_down()boolDeterministic Market structure capability backed by the shared closed-candle KSL runtime.
break_of_structure_down(20)
choch_up()boolDeterministic Market structure capability backed by the shared closed-candle KSL runtime.
choch_up(20)
choch_down()boolDeterministic Market structure capability backed by the shared closed-candle KSL runtime.
choch_down(20)
liquidity_sweep_high()boolDeterministic Market structure capability backed by the shared closed-candle KSL runtime.
liquidity_sweep_high(20)
liquidity_sweep_low()boolDeterministic Market structure capability backed by the shared closed-candle KSL runtime.
liquidity_sweep_low(20)
bullish_divergence()boolDeterministic Signal conditions capability backed by the shared closed-candle KSL runtime.
bullish_divergence(close, rsiValue, 20)
bearish_divergence()boolDeterministic Signal conditions capability backed by the shared closed-candle KSL runtime.
bearish_divergence(close, rsiValue, 20)
retest_long()boolDeterministic Signal conditions capability backed by the shared closed-candle KSL runtime.
retest_long(level, 10)
retest_short()boolDeterministic Signal conditions capability backed by the shared closed-candle KSL runtime.
retest_short(level, 10)
candle_bullish_engulfing()boolDeterministic Candle patterns capability backed by the shared closed-candle KSL runtime.
candle_bullish_engulfing()
candle_bearish_engulfing()boolDeterministic Candle patterns capability backed by the shared closed-candle KSL runtime.
candle_bearish_engulfing()
candle_hammer()boolDeterministic hammer geometry on the latest closed candle.
candle_hammer()
candle_shooting_star()boolDeterministic shooting-star geometry on the latest closed candle.
candle_shooting_star()
candle_doji()boolTrue when the latest candle body is at most 10% of its full range.
candle_doji()
inside_bar()boolTrue when the latest closed candle is fully inside the prior candle range.
inside_bar()
outside_bar()boolTrue when the latest closed candle fully exceeds the prior candle range.
outside_bar()
volume_spike()boolTrue when current volume exceeds its rolling average by the chosen multiplier.
volume_spike(20, 1.5)
in_session()boolDeterministic Signal conditions capability backed by the shared closed-candle KSL runtime.
in_session("LONDON")
volatility_low()boolDeterministic Volatility capability backed by the shared closed-candle KSL runtime.
volatility_low(14, 1.5)
volatility_normal()boolDeterministic Volatility capability backed by the shared closed-candle KSL runtime.
volatility_normal(14, 1.5)
volatility_high()boolDeterministic Volatility capability backed by the shared closed-candle KSL runtime.
volatility_high(14, 1.5)
swing_low()stopDeterministic Risk and exits capability backed by the shared closed-candle KSL runtime.
swing_low(10)
swing_high()stopDeterministic Risk and exits capability backed by the shared closed-candle KSL runtime.
swing_high(10)
atr_stop()stopDeterministic Risk and exits capability backed by the shared closed-candle KSL runtime.
atr_stop(1.5)
rr()targetDeterministic Risk and exits capability backed by the shared closed-candle KSL runtime.
rr(2.0)
fixed_pips()distanceDeterministic Risk and exits capability backed by the shared closed-candle KSL runtime.
fixed_pips(20)
No registered function matches that search.
Safe compatibility aliases
The Compatibility Checker can rename these known terms to native KSL. It does not change the trading logic or invent missing features.
ADX()adx()Common namingATR()atr()Common namingaverage_true_range()atr()Common namingbollinger_lower()bb_lower()Common namingbollinger_mid()bb_mid()Common namingbollinger_upper()bb_upper()Common namingbos_down()break_of_structure_down()Common namingbos_up()break_of_structure_up()Common namingCCI()cci()Common namingCMF()chaikin_money_flow()Common namingDEMA()dema()Common namingdi_minus()minus_di()Common namingdi_plus()plus_di()Common namingEMA()ema()Common namingexponential_moving_average()ema()Common namingHMA()hma()Common namingkeltner_channel_lower()keltner_lower()Common namingkeltner_channel_mid()keltner_mid()Common namingkeltner_channel_upper()keltner_upper()Common namingliquidity_sweep_buy()liquidity_sweep_low()Common namingliquidity_sweep_sell()liquidity_sweep_high()Common namingmacd()macd_line()Common namingmacd_sig()macd_signal()Common namingMFI()mfi()Common namingOBV()obv()Common namingrelative_strength_index()rsi()Common namingRMA()smma()Common namingROC()roc()Common namingRSI()rsi()Common namingsimple_moving_average()sma()Common namingSMA()sma()Common namingta.adx()adx()AI/Pine compatibilityta.atr()atr()AI/Pine compatibilityta.cci()cci()AI/Pine compatibilityta.cmf()chaikin_money_flow()AI/Pine compatibilityta.crossover()crossover()AI/Pine compatibilityta.crossunder()crossunder()AI/Pine compatibilityta.dema()dema()AI/Pine compatibilityta.ema()ema()AI/Pine compatibilityta.falling()falling()AI/Pine compatibilityta.highest()highest()AI/Pine compatibilityta.hma()hma()AI/Pine compatibilityta.linreg()linear_regression()AI/Pine compatibilityta.lowest()lowest()AI/Pine compatibilityta.median()median()AI/Pine compatibilityta.mfi()mfi()AI/Pine compatibilityta.obv()obv()AI/Pine compatibilityta.rising()rising()AI/Pine compatibilityta.rma()smma()AI/Pine compatibilityta.roc()roc()AI/Pine compatibilityta.rsi()rsi()AI/Pine compatibilityta.sma()sma()AI/Pine compatibilityta.stdev()stddev()AI/Pine compatibilityta.tema()tema()AI/Pine compatibilityta.variance()variance()AI/Pine compatibilityta.vwap()vwap()AI/Pine compatibilityta.wma()wma()AI/Pine compatibilityta.wpr()williams_r()AI/Pine compatibilityTEMA()tema()Common namingVWAP()vwap()Common namingweighted_moving_average()wma()Common namingWMA()wma()Common namingProfessional shared-runtime strategy
version 2;
strategy "HMA Keltner Participation" {
timeframe = M5;
input int trendPeriod = 21 min 5 max 100;
input int channelPeriod = 20 min 5 max 100;
let trend = hma(close, trendPeriod);
let upper = keltner_upper(close, high, low, close, channelPeriod, 1.5);
let momentum = zscore(close, 20);
let buySignal = close > trend
&& rising(trend, 3)
&& close < upper
&& momentum > 0
&& volume_spike(20, 1.5);
buy {
when = buySignal;
entry = ask;
stop = atr_stop(1.5);
target = rr(2.0);
}
plot(trend, color.green, "HMA Trend");
plot(upper, color.cyan, "Keltner Upper");
draw(buySignal);
}Shared behavior: The same source can be compiler-validated as an AUTO candidate or activated exactly in MANUAL, then replayed by Historical Backtest. Arithmetic + - * /, parentheses, and normal precedence remain fail-closed on zero or non-finite division.
What KSL still refuses
- Unknown indicators or functions without tested runtime implementation
- Loops, arrays, imports, arbitrary network/database access, or dynamic execution
- Forming-candle dependencies for strategy conditions
- Silent conversion or substitution of unsupported strategy meaning
- Activation when compiler validation or runtime identity checks fail
An admin registry entry marked Draft is documentation only. It becomes safely convertible only when mapped to an executable native function. A genuinely new indicator requires compiler, runtime, history, replay, and parity tests before this page can advertise it.