Prevent repeated entries during the same breakout episode
A strategy that simply checks whether price is above resistance can enter again immediately after a stop or profit exit. A one-shot state gate distinguishes the first qualifying breakout from a continuing condition. This MultiCharts .NET example treats an episode as an uninterrupted sequence of closes above a rolling reference, not a fixed-price breakout.
State transitions
At each completed bar, calculate the highest high of the preceding 20 bars, excluding the current bar. When close is at or below that reference, arm the gate. On the first subsequent close strictly above the reference, consume the gate. Further qualifying closes cannot trigger another entry until the condition becomes false again. In a simplified fixed-level illustration at 100, closes 99, 102, 103, 101, 99 and 102 produce entry events at the second and sixth observations. The real code updates its reference each bar, so episode boundaries may differ from this fixed-level picture.

Illustrative state transitions using a fixed level for clarity. Not historical prices.
PowerLanguage .NET implementation
// SignalObject members; use bar-close calculation.
private bool armed = true;
private IOrderMarket entry;
protected override void Create()
{
entry = OrderCreator.MarketNextBar(
new SOrderParameters(Contracts.Default,
EOrderAction.Buy));
}
protected override void StartCalc()
{
armed = true;
}
protected override void CalcBar()
{
// Set sufficient MaxBarsBack for 20 prior bars.
double level = Bars.High[1];
for (int i = 2; i <= 20; i++)
level = Math.Max(level, Bars.High[i]);
if (Bars.Close[0] <= level)
armed = true;
else if (armed)
{
armed = false;
// Entry fragment: apply flat-position and
// pending-order guards before sending.
entry.Send();
}
}
Use the SignalObject template and standard platform namespaces, including PowerLanguage and PowerLanguage.Strategy where required. Configure bar-close calculation without intrabar order generation, and adequate MaxBarsBack. The code illustrates the state transition and market-next-bar order API. Before live use, require a flat strategy position, no working entry, and an explicit contract quantity. Consume the gate even when an entry is blocked by an existing position if the intention is one attempt per episode. Reconstruct the gate after a restart; a reset at StartCalc alone is not persistent live state. A rejection does not automatically rearm the gate.
Exit design and testing
For a controlled experiment, use the same protective stop and 10-bar trailing channel exit in both the unrestricted and gated variants. Configure the protective orders separately and reconcile actual fills, partial fills and rejected orders. Compare repeated entries, exposure, net return after costs and drawdown in trending and sideways periods. Include cases where a rolling level rises above the close without a large price reversal, since that can rearm the strategy. This entry fragment is not a complete strategy and has not been compiled or backtested here. Market orders may fill away from the signal price, and leveraged trading can cause substantial losses.
For custom execution and strategy rules, see Custom MultiCharts .NET strategy Development Services.