MultiCharts .NET: A Profit Giveback Exit with an Activation Threshold
A trailing exit need not operate from the first profitable tick. A two-stage exit first waits for a meaningful favorable excursion, then limits the amount of open profit surrendered. This separates activation from protection and makes the exit easier to audit.
Example and state
For a long position entered at 100, use an activation of 1.80 points and a giveback of 0.60 points. Track the maximum observed profit in points since the actual fill. A peak of 2.20 activates protection; a decline to 1.60 requests an exit. For shorts reverse the price difference. The illustration shows eight hypothetical observations, with the dashed line at 1.80 points, green peak at 2.20 and red exit signal at 1.60. Each horizontal grid interval represents 0.60 points.

Illustrative favorable excursion and subsequent giveback; not market data.
PowerLanguage .NET implementation
In a SignalObject, maintain per-position state in CalcBar. Create a market exit order for the appropriate side using the platform order factory in Create, and send it when the exit flag is raised. The following C# fragment is the decision kernel, not a standalone signal. Initialize peakProfit to zero on confirmed entry, update it with Math.Max(peakProfit, currentProfit), and clear state only on confirmed flat or reversal. Use actual average entry price, not the signal close. Do not reset the peak every bar.
if (peakProfit >= activation && currentProfit <= peakProfit - giveback)
exitRequested = true;
Use a separate pending-exit flag to avoid repeated requests, and reconcile rejected orders. With close-only calculation, currentProfit is based on the close; intrabar calculation requires a consistent tick stream and careful historical fill settings. Never use a bar high to assume an earlier peak occurred before a low on the same bar without intrabar evidence.
Testing and limitations
Test an excursion below activation, equality at activation, equality at the exit threshold, gaps through the threshold, short trades, reversals and partial fills. For scale-ins either reset the excursion on quantity changes or explicitly define a weighted cost basis policy. Compare close-only and intrabar results with commissions and slippage. This is an illustrative kernel, not compiled or backtested. A market exit can fill far beyond the threshold; maintain independent catastrophic risk controls. Trading can cause substantial losses.
For integration with existing order handling: Custom MultiCharts .NET strategy Development Services.