π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.
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 / Hold2. Supported Lua Syntax
The strategy builder supports a subset of LUA.
β
Supported commands
localvariable declarationsNumeric arithmetic:
+ - * /Comparisons:
> < >= <= ==Boolean logic:
and,orConditional blocks:
if / elseif / endSingle-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
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.
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)
ev)The global ev table provides context about the current bar event.
Fields
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