Rules and Plays

How to automate your trades on a per-asset basis


In Guerrilla, there are two types of tactics; rules and plays.

Rules

A rule fundamentally consists of a trigger condition, an order template, and an asset on which the rule will be applied. Here is what you really need to know:

Rule = Asset + Rule Template

Rule Template = Trigger Condition + Order Template

Below is an example of a rule template which can be created on Guerrilla:

If price touches VWAP, buy 200 shares @ market

In this rule template example, the trigger condition is “If price touches VWAP”, while the order template is “buy 200 shares @ market”

To create a rule for an asset such as AAPL, the rule template can be applied through the following means:

  1. Dragging the rule template from the Tactics Library onto the AAPL chart window (in the future, this should work for any window in which AAPL is the selected asset)
  2. Clicking the rule template from a context menu generated by right-clicking within a window in which AAPL is the selected asset
  3. Clicking a button which has been bounded to this rule template
  4. Pressing a hotkey which has been bounded to this rule template when the active window has AAPL as the selected asset
  5. Applying the rule template to a bench which contains AAPL (Work in Progress)

Thereafter, the trigger condition part of the rule is constantly evaluated by the app on every AAPL price change (thousand times per second!). When the trigger condition is satisfied by the market, the bounded order template within the rule is executed, and an order to buy 200 shares of AAPL is sent to the currently active broker. If the order template has the “Confirm before execution” checkbox ticked, the order will not be sent. Instead, a prompt is presented to the trader to manually approve the order before it sent the broker. This gives you flexibility around the level of automation you want from Guerrilla.

Plays

A play is a combination of multiple rules triggered in a sequential order. For instance, a simplified Opening Range Breakout play on AAPL will consist of the following rules pre-defined in the following order by the trader:

  1. If price crosses above open price, buy 200 shares of AAPL @ market
  2. If price increases by $0.50, exit 50% of AAPL position
  3. If price closes below 9EMA - 15mins, exit 100% of AAPL position
  4. If position value reduces by 5%, exit 100% of AAPL position

This play allows the trader to automatically open a position on a price breakout, and manage risk simulataneously on both the upside and the downside. This presents flexibility and allows the trader more creativity compared to traditional tools such as trailing stops and bracket orders.

Conditional Plays (WIP)

A conditional play binds a trigger condition with an existing play or a sequential order of rules. For instance, the above example can be used a conditional play like so:

If time >= 9:35am ET, apply “Opening Range Breakout play” to AAPL

This conditional play is valuable if the trader relies on the 5-minutes timeframe to assess Opening Range Breakout opportunities. It prevents the play from executing prior to the closure of the first 5-minute candle.

At the moment, conditional plays are a work in progess and not available in the latest version of Guerrilla.