Skip to main content
Article Contents
Print

Trading & Action Rules

Trading and Action Rules are the work-horses of the Trading Strategies in your Trading Spec. Trading rules signal potential trades when the price, time or other conditions are right. Action rules can display alerts, or update terms whose data persists between ShareScope sessions

Rule Evaluation

If a Trading Strategy is active, then in RuleTrader Test sessions its rules are evaluated once each day, for each share in the currently selected trading list. In Live sessions, its rules are evaluated every few seconds, when new market data arrives, again for each share in the strategy’s trading list.

In back-tests (but not Live sessions) Trading Rules that sell are evaluated before rules that buy shares (to potentially free up cash for any buys). Within those categories, they are evaluated in the order they are listed in the Strategy Rules tab of the Trading Specification Definition dialog. Rules that open or increase positions are evaluated for shares with or without a position, while those that close or decrease positions are obviously only evaluated for shares with a position.

Only long positions are supported by RuleTrader though we expect to support short positions in the near future. So, until then, a buy rule will not (normally) be signalled if there are insufficient funds in the trading account(s) to meet the required trade-size – though see the RuleTrader Live setting: ‘Show buy trade-signals, even if there is insufficient cash for the trade

Note that trading rules won’t be evaluated for a share until it has sufficient price data for the longest statistic or price-channel, in your Spec, to be backfilled. For example, if the channel ‘Backfill period’ (see AutoTrend Settings) is set to 150 days and the longest statistic in your Spec is a 200 day moving average, then the system will wait at least 200 trading days from the day the share was listed, so it has 200 days of price data with which to calculate the average and fill the AutoTrend channels. This behaviour can be overridden (if, for example, you want to trade newly listed shares) by setting the ‘Don’t wait for backfill’ attribute in your Trading Rules (see below).

Rule Triggering

If a Trading Rule’s trigger condition is satisfied then, in Test sessions, a trade is automatically executed at the price defined by the Trade Sizing tab’s ‘Trading style‘ setting. In Live sessions the rule’s signal is displayed in RuleTrader’s ‘Live Status‘ column and the current live mid-price will be displayed in the Trade Entry dialog, if you decide to go ahead with the trade.

You can quickly determine which trading rule was responsible for which trade, by using RuleTrader’s Rule Highlights feature to colour-code trades in the Historical Chart.

Once triggered, no further trading rules are evaluated again that day, for that share. This prevents sells triggering immediately after a buy, or vice-versa, for the same share.

Action Rules, which display alerts or update Persistent Terms, are always evaluated, regardless of the state of the trading rules. However, Action Rules can only be triggered once per day, which makes them useful for counting daily events, or setting daily thresholds.

Shared trading rules may be pasted into this tab, either as copies or as linked rules.

How To Create A Trading or Action Rule

Like all Spec component definitions, Trading and Action Rules are created and edited in the DEfT Wizard, whose integrated instructions will guide you every step of the way. As you define the rule, you’ll be asked to specify:

  • What type of rule it is: A Trading Rule that signals a trade; or an Action Rule that generates an alert; or an Action Rule that sets, resets or updates a Persistent Term, whose data persists between ShareScope and RuleTrader sessions.
  • When the rule is triggered: All rules must specify a condition expression that defines the criteria for triggering the rule. Conditions are either true or false; you can specify which state triggers the rule.
  • What the rule does: For an Action Rule this is a straightforward description of the alert to raise, or the Persistent Term to update. For a Trading Rule, it involves specifying the:
    • Type of trade: e.g. Open Position, Increase Position, Decrease Position, Close Position, Take Profit, or Stop Loss. Stop Loss is the same as Close Position (both types close the whole position), while Take Profit is the same as Decrease Position (both decrease the size of the position).

The reason for having the same types with different names is simply for reporting purposes (specifically, reports that use the Trade Type dimension). This allows you to differentiate between, for example, profits that were from positions closed in an orderly manner, and profits from positions that were closed due to e.g. stop losses.

    • Amount to trade: (i.e. the trade size) this is required for all trade types except Close Position and Stop Loss, which close the entire position. You can use all or a portion of the nominal trade size defined in the Trade Sizing Dashboard tab, or you can define a specific quantity or value (in £) of shares
    • Trading attributes: define additional attributes of the trading rule such as:
      • Beep if triggered: (live sessions only) if selected, your computer beeps if a trading-signal is raised because a trading rule has triggered
      • Don’t wait for backfill: allows this trading rule to be applied immediately, without waiting for sufficient price data to fill your Spec’s longest statistic or price-channel (see above)
      • Target price: In Live sessions, the target price (in the share’s minor currency units) provides an indicative price for the trade in the trade-entry dialog. If it is not provided, then the current mid-price is used (or the last close if the markets have closed).
      • In Test sessions, target price has no effect on the price the rule is traded at, which will always be the close price. Its primary use in tests is to provide a price for the trade-signal, which may then be tested by other rules.
      • Risk-level: Provides a number for the trade-signal that indicates the perceived risk of the trade. This can then be tested by other trading rules and their behaviour modified accordingly.
      • Rule-category: Provides a text label (or multiple labels separated by commas) indicating a category for the rule. Again, this can be tested by other rules, in the trade-signal.
Scroll to Top