Home › Documentation › Building strategies
Tool

AQ Language & Editor

It opens from Strategies → AQ code editor…. It solves a specific problem: without it, a strategy could only be defined through the combinations of the Mass Test (which is a search space, ambiguous by design). AQ code is the written form of one concrete strategy — unambiguous and reproducible — which the editor turns directly into something testable.

A first look

name:       SMA + RSI crossover
direction:  long

entry:
    SMA(Close, 50) crosses above SMA(Close, 200)
    and RSI(Close, 14) > 50

exit:
    RSI(Close, 14) > 70

takeprofit: 3%
stoploss:   2 x ATR

The editor colors with this very palette: keywords, indicators, sources, numbers, operators.

Structure

  • name: a free-form name for the strategy.
  • direction:long / short (the default direction).
  • entry:conditions joined by and. Repeated = OR; with long/short it mixes directions.
  • exit: exit conditions (optional, repeated = OR).
  • takeprofit:/ stoploss: the targets.

Comments with # or //.

Indicators and operands

  • →With a source: SMA(Close, 50)
  • →Without a source: ATR(14)
  • →A price series: Close[5] (5 bars ago)
  • →Patterns without parentheses: BullishEngulfing
  • →Shift: SMA(Close,20)[1]

The left-hand side of a condition is always an indicator; the right-hand side, an indicator or a number.

Operators

> < = >= <= <> crosses above crosses below

>= / <= include the boundary value; <> means «not equal to». For DayOfYear and the other calendar filters, DayOfYear >= 72 and DayOfYear <= 77 selects the window of days 72 to 77 (both included).

Take Profit / Stop Loss

  • →Percentage: 3%
  • →Amount: $1.5
  • →A multiple of ATR: 2 x ATR
  • →No target: none

The ATR period in TP/SL is ignored (it uses the global one).

Several entries · OR of blocks and long+short reversal

Repeat entry: to join blocks with OR: the strategy enters if any of the blocks holds (each block being an internal and). The same with a repeated exit:. A plain block inherits the strategy's direction:.

Add a direction to the block — entry long: / entry short: — to mix longs and shorts in one single strategy. When a block of the opposite direction to the open position fires, that position is flipped: it closes and opens the opposite one on the same bar (selling and buying the same day).

direction:   long

entry long:   DayOfYear >= 48 and DayOfYear <= 54
entry short:  DayOfYear >= 55 and DayOfYear <= 58

exit:         DayOfYear >= 59 and DayOfYear <= 63

The exit covers only the flat gaps between windows: between a long window and a short one butted together there is no exit, the reversal is fired by the opposite block. The Seasonal Optimizer generates this automatically when it sends a long+short plan to the Portfolio — one strategy, exportable with its reversal to EasyLanguage (TradeStation), MQL5 (MetaTrader 5) and ProRealTime.

The editor

Live coloring
Syntax highlighted token by token with this guide's palette, a gutter with line numbers and a monospaced font.
Check
It validates against the real indicator catalog: it lists the errors with line and column and highlights the exact word in yellow. Click an error → it jumps to that line.
Save / Open
.aq files in C:\AniQuant\estrategias\.
▶
Test

A backtest on the chosen symbol, opening the Strategy Performance Report instantly.

📁
To Portfolio

It sends it to the Portfolio as a concrete strategy → re-test, equity, Survival, Multi-TF and PBO. The whole pipeline.

🔬
To Mass Test

It seeds the indicators as fixed-period rows; the search engine reproduces the strategy (and many more). Widen them into ranges to optimize around it.

🔓
A round trip

And the other way round: from the Mass Test or the Portfolio, right-click → Edit strategy (AQ) opens any strategy as editable code. You discover → you edit → you test or re-export.

Notes: the code describes a single strategy (not ranges); both is interpreted as long; or is treated as and.

Try it yourself

AniQuant can be tried free for 30 days, with every module and no card.

← Previous
Execution costs: commission and slippage
Next →
Export strategies to your platform
More in Building strategies