πŸ“˜Syntax & Commands

This sectionsection documents the supported syntax, commands, and primitives available in the memejob strategy engine. It serves as a reference and is not intended to be read linearly.

circle-info

Strategies generated via the LLM-assisted builder must still conform to the syntax and execution model described below.

Below are all the supported syntax, variables and functions available when building trading strategies using the WAKOS / memejob LUA Strategy Builder.

The environment is a sandboxed LUA DSL designed for safe, fast, deterministic backtesting and execution. It is not full LUA.

Not all commands are required for every strategy; most strategies use a small subset of the primitives listed below.

1. Execution Model (Important)

Understanding the execution model is critical before writing strategies.

  • The strategy script is executed once per bar

  • Scripts are stateless by default (no memory across bars)

  • The engine manages: Positions and Order execution

  • Your script expresses intent via return values

Return Values

return 1   -- Buy / Long / Add (DCA)
return -1  -- Exit or Short (engine-defined)
return 0   -- Do nothing / Hold

2. Supported Lua Syntax

The strategy builder supports a subset of LUA.

βœ… Supported commands

  • local variable declarations

  • Numeric arithmetic: + - * /

  • Comparisons: > < >= <= ==

  • Boolean logic: and, or

  • Conditional blocks: if / elseif / end

  • Single-return strategy flow

Example:

❌ Not Supported (by design)

  • Loops (for, while)

  • Functions

  • Tables / arrays

  • Persistent state across bars

  • LUA standard libraries (math.*, string.*, etc.)

3. Core Market Data Variables

All market data variables are instances of ValueWithHistory.

They support:

  • Direct access (close)

  • Historical indexing (close[1], close[2])

Price Variables

Variable
Description

open

Opening price of current bar

high

Highest price of current bar

low

Lowest price of current bar

close

Closing price of current bar

volume

Trading volume of current bar

Example:

4. Derived Price Variables

Calculated prices derived from OHLC values.

Variable
Formula
Description

hl2

(high + low) / 2

Mid price

hlc3

(high + low + close) / 3

Typical price

hlcc4

(high + low + close + close) / 4

Close-weighted price

All support historical indexing.

Example:

5. Bar Event Context (ev)

The global ev table provides context about the current bar event.

Fields

Field
Type
Description

ev.kind

string

Opened, Updated, or Closed

ev.bar_span

number

Bar interval in minutes

Example:

6. Moving Average Indicators (Module MA)

EMA – Exponential Moving Average

Parameters:

  • periods (number, required)

  • window (string | number, optional)

Examples:

Asset-specific EMA:


SMA – Simple Moving Average

Examples:


WMA – Weighted Moving Average

Examples:


MACD – Moving Average Convergence Divergence

Examples:

Note: MACD always uses the primary asset.

Last updated