Separate entry signals from permission to trade

Repeated moving-average crosses during a choppy market can produce clusters of losses. A post-loss cooldown is a stateful entry restriction rather than a new price indicator. In MultiCharts PowerLanguage, it can be implemented by tracking completed trades and the change in closed-trade net profit. The hypothesis is that temporarily withholding entries after a loss may reduce repeated exposure; it may equally miss a profitable recovery.

Define the timing precisely

Use a single-contract long-only strategy with a 10-period simple moving average crossing above a 30-period average as the entry signal. Exit on the opposite crossover or a protective cash stop of 200 account-currency units per contract. Disable pyramiding and intrabar order generation for the signal logic. When a losing completed trade is first observed at bar 20, block entries on that bar and the next three bars, 21 through 23. Bar 24 is the first eligible signal bar, with a market entry scheduled for bar 25 if a fresh crossover occurs. A crossover during the blocked period is discarded, not queued.

Post-Loss Cooldown Gates in PowerLanguage Strategies

Illustrative bar-index timeline: loss detected at bar 20, three subsequent blocked bars, and eligibility restored at bar 24.

PowerLanguage example

Inputs: CooldownBars(3), FastLen(10), SlowLen(30),
        StopCash(200);
Variables: LastTrades(0), LastNet(0), BlockUntil(0),
           FastMA(0), SlowMA(0);

FastMA = Average(Close, FastLen);
SlowMA = Average(Close, SlowLen);

If TotalTrades > LastTrades then begin
    If NetProfit - LastNet < 0 then
        BlockUntil = CurrentBar + CooldownBars;
    LastTrades = TotalTrades;
    LastNet = NetProfit;
end;

If MarketPosition = 0 and CurrentBar > BlockUntil
    and FastMA crosses over SlowMA then
    Buy ("MAEntry") next bar at market;

If MarketPosition = 1 and FastMA crosses under SlowMA then
    Sell ("MAExit") next bar at market;

SetStopContract;
SetStopLoss(StopCash);

Configure one contract in strategy properties and sufficient MaxBarsBack for both averages. TotalTrades counts completed strategy trades; NetProfit represents cumulative closed-trade profit. Their changes allow the signal to detect a newly completed losing trade in this restricted single-position model. CurrentBar is the strategy's bar index, not elapsed wall-clock time. SetStopContract selects per-contract stop calculation; SetStopLoss specifies a monetary amount rather than a number of ticks. The built-in protective stop can operate intrabar even though crossover decisions are evaluated at bar close.

State and execution limitations

The example assumes at most one completed trade between evaluations. If scaling, multiple entries or intrabar calculation are enabled, an aggregate NetProfit change can conceal individual losses; use individual closed-trade records instead. Verify commission settings and whether the reported profit includes the costs relevant to your loss definition. Recalculations reconstruct historical state, which may not match actual broker fills after a restart. A production implementation should reconcile live position and order state before permitting new entries. A session boundary does not reset this cooldown, and nontrading periods do not consume bars.

Testing the hypothesis

Compare cooldown lengths 0, 1, 3 and 5 on identical data with the same entry, exit, commission and slippage settings. Zero still blocks the loss-detection bar; use a separate unrestricted baseline to measure that effect. Record blocked signals, loss streaks, average trade, net return and maximum drawdown. Examine both trending and sideways regimes and reserve an out-of-sample period. Test the boundary bars explicitly and include stop-outs followed by immediate reversals. The code has not been compiled or backtested here. Protective stops do not guarantee a fixed realized loss, particularly during gaps or illiquid markets. Leveraged trading can cause substantial losses.

For customized stateful entry restrictions and execution reconciliation, see Custom MultiCharts strategy Development Services.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.