Signal-controlled positioning
Signal-controlled positioning switches between two fractions of a security’s target allocation during a historical replay. For example, a security may be fully invested above its 200-day moving average and fully sold below it. Uninvested amounts remain cash; other securities retain their original targets. This strategy operates only in historical simulations and produces no live alerts or broker orders.
Assignment and signal binding
Attach the strategy to the portfolio based strategy, an asset class or a security. It controls the security leaves below that node that belong to the run’s allocation, independently of its watchlist. Own price series evaluates each controlled security separately. Reference security uses the security entered under Reference security ID for all controlled leaves. The reference must be visible to you and have an exchange calendar; cryptocurrencies use daily sessions. Currency pairs cannot serve as references. A reference need not be a hierarchy leaf and is neither purchased nor added to valuation merely because it supplies a signal. Attach separate strategies to asset classes when each should follow its own reference.
Settings and templates
Signal template fills the signal check, entry and exit expressions and both allocation shares. It preserves the binding and reference. The field values are saved and remain editable; the template selection itself is not stored. Switch off Active to save an incomplete draft.
| Template | Entry | Exit | Invested / reduced share |
|---|---|---|---|
| 200-day SMA | PRICE > SMA(200) | PRICE < SMA(200) | 100 / 0 |
| 10-month SMA | PRICE > SMA(10, "M") | PRICE < SMA(10, "M") | 100 / 0 |
| 200-day SMA, checked at month end | PRICE > SMA(200) | PRICE < SMA(200) | 100 / 0 |
| 200-day SMA with 2% band | PRICE > SMA(200) * 1.02 | PRICE < SMA(200) * 0.98 | 100 / 0 |
| 50/200-day SMA crossing | SMA(50) > SMA(200) | SMA(50) < SMA(200) | 100 / 0 |
| 200-day EMA | PRICE > EMA(200) | PRICE < EMA(200) | 100 / 0 |
| 12-month absolute momentum | PRICE > CLOSE(12, "M") | PRICE < CLOSE(12, "M") | 100 / 0 |
| 200-day SMA, reduce to half | PRICE > SMA(200) | PRICE < SMA(200) | 100 / 50 |
| 40-week SMA | PRICE > SMA(40, "W") | PRICE < SMA(40, "W") | 100 / 0 |
| 100-day breakout with volatility filter | PRICE >= HIGHEST(100) AND VOLA(20) < 30 | PRICE <= LOWEST(50) | 100 / 0 |
Both expressions must return true or false and contain at most 500 characters each. Available inputs are PRICE, PREVCLOSE, OPEN, HIGH, LOW, VOLUME and the functions SMA, EMA, RSI, HIGHEST, LOWEST, ZSCORE, MAXDD, ATR, CLOSE, VOLA; an optional second argument counts weeks or months instead of trading days (see below). Fundamental, benchmark and dividend functions are excluded. Missing inputs prevent a decision. The invested share must exceed zero and be at most 100%; the reduced share must be nonnegative and strictly smaller.
Signal check and state
Signal check sets the sessions on which GT decides. Daily close decides on every session. Last weekly session and Last monthly session use the final exchange session of each completed calendar period, accounting for weekends and holidays. A missing final-session quote is logged and the period skipped. A run ending before that session does not evaluate the unfinished period. Periods completed before the first run day provide warm-up only and never trigger retrospective orders.
The signal check does not change what an indicator counts. A period counts trading days unless a second argument names weeks or months: SMA(200) averages 200 daily closes, SMA(40, "W") 40 weekly and SMA(10, "M") ten monthly closes; 'M' in single quotes works as well. Weeks run from Monday to Sunday and months are calendar months; the close of a period is its last close. SMA(10, "M") checked on the last monthly session therefore averages ten month-end closes including the latest, whereas PRICE > SMA(200) with Last monthly session compares the month-end close with the 200-day average and decides only once a month. If a weekly or monthly indicator is checked daily, the running period counts with its latest close. SMA requires one additional earlier observation. Warm-up may precede the opening date. GT keeps 2600 daily closes per instrument and, as for a market trading every day, reckons seven of them per week and 31 per month. At most 1000 daily, 371 weekly and 83 monthly observations are therefore possible: SMA(82, "M") is valid, SMA(83, "M") is not. Automatically filled non-trading days and connector-filled price gaps are excluded from signal observations.
Each run starts with an undetermined state. Entry alone sets it to invested, exit alone to reduced. If neither expression is true the state stays unchanged. If both are true it also stays unchanged, and the beginning of this ambiguous situation is logged. No earlier crossing is required to enter from a cash opening.
Targets, execution and rebalancing
The target combines current equity with the portfolio, class and security weights and the state’s allocation share. Switching to invested buys a deficit only; switching to reduced sells an excess only. Sales include copied opening holdings across multiple custody accounts. Orders execute at the next eligible close after the decision. Ordinary simulation rules apply to costs, taxes, exchange rates and affordability. When free cash cannot cover all purchases, their amounts are reduced proportionally. Outstanding target amounts are retried on up to five subsequent run days. An opposite signal discards that series’ remaining orders; already booked fills remain. The log reports incomplete targets and any state never determined by the end of the run. An optional Portfolio Rebalancing strategy corrects subsequent drift against the scaled targets. Without it, signal orders occur only when the state changes. A leaf with an undetermined state, a change today, a future fill or an outstanding order is frozen for initial purchase and rebalancing. Initial construction waits for an invested state on controlled leaves. Uncontrolled siblings are purchased normally. Uninvested shares remain cash.
Reserve for fees and costs
How much money the strategy invests results from three values multiplied together: the Weighting of the portfolio based strategy on the top level of the tree table, the weightings of asset class and security, and the Invested share (%) of the signal. The weightings of the asset classes always add up to 100%; they merely divide the amount the top level releases. Whatever the top level does not release stays cash. An example with two asset classes, each controlled by its own signal and both invested:
| Node | Weighting | Share of equity |
|---|---|---|
| Portfolio based strategy | 98% | 98% |
| First asset class | 60% | 58.8% |
| Second asset class | 40% | 39.2% |
With 100% on the top level and 100% in the signal, the strategy invests practically the entire equity on entry, across all cash accounts of the environment: if the cash in the security’s currency does not suffice, the simulation converts balances in other currencies. A Swiss franc cushion you set aside for the custody fees is invested along with it. With every purchase the simulation does hold back the custody fees accrued up to the decision, but not the rest of the current billing period. If an entry falls on the billing day or shortly before it, the money for the fee is missing. Because the simulation never overdraws a cash account without a borrowing rate, the replay then stops with «Custody fee calculation failed» and a note about the negative balance. Dividends do flow into the cash account, but for a strategy that trades rarely they are not always enough.
Set the Weighting of the portfolio based strategy to about 98% and leave Invested share (%) at 100%. Around 2% of equity then stays cash on every entry, and this cushion is sized afresh with every signal. Do not reduce both values: 98% at the top and 98% in the signal invest only 96%. You change the top-level weighting directly in its cell of the tree table, in your own portfolio; inside a simulation environment the tree table is read only.
False signals and costs
The daily 200-day SMA is the best known template, but also the most restless. When the price moves sideways around its average for a while, the state often changes several times a month. Every change costs brokerage, for a security in a foreign currency also the markup on the currency conversion, and frequently the position is sold lower and bought back higher. In an example run with an ETF on the S&P 500 from 2004 to 2026 and about USD 100,000 starting capital, this template triggered 154 purchases and sales; the transaction costs alone added up to about USD 30,000. The Historical replay shows every change with its reason. The other templates reduce the number of changes in different ways:
| Template | Behaviour in practice |
|---|---|
| 10-month SMA | Decides only on the last monthly session and therefore typically changes only a few times a year. A good starting point when false signals are a nuisance. |
| 200-day SMA, checked at month end | Uses the familiar 200-day average but decides only once a month; a brief dip below the average in the middle of the month triggers nothing. |
| 40-week SMA | Decides on the last weekly session and so lies between the daily and the monthly variant. |
| 200-day SMA with 2% band | The gap between entry and exit absorbs the small fluctuations around the average that cause most changes of the daily SMA. |
| 12-month absolute momentum | Compares once a month with the price a year earlier and changes very rarely. |
| 50/200-day SMA crossing | Produces few signals but reacts late to a change of trend. |
| 200-day SMA, reduce to half | A false signal moves only half the amount; in exchange the position stays half invested in a downturn as well. |
| 100-day breakout with volatility filter | Buys only on a new high in a calm market phase and sells only on a 50-day low. |
The expressions can also be combined, for example a band checked monthly: entry PRICE > SMA(10, "M") * 1.02, exit PRICE < SMA(10, "M") * 0.98 with Last monthly session.
These notes describe how the templates behave and are no investment advice. Which template would have done better with your securities in the past is shown only by comparing them in your own simulations, and even that says nothing about the future.
Limits and comparisons
Overlapping active exposure signals and overlap with an active Mean Reversion Dip on the same security are refused. A controlled security cannot belong to two asset classes. Security standing orders in the environment must not trade the same securities; cash standing orders remain allowed. Alerts on those instruments remain allowed but do not trade in the replay. A leaf with zero weight can only be sold. There are two ways to compare. The cleanest is a separate portfolio based strategy with its own simulation environment for each scenario. You can also use a single strategy and create one environment per template, all with the same opening date and the same amounts. Keep in mind that an environment keeps only the result of its latest replay, whereas the strategy applies to all of its environments. Choose the template, start the replay of the matching environment and change the template only once that replay is visibly running. Every replay records the strategy valid at its start; the tab Replay settings shows which template it was calculated with. The same hierarchy without the signal serves as a buy-and-hold comparison. This strategy provides no short positions, leveraged products, cash replacement instrument or parameter optimization, and does not promise to reproduce published studies.