Emerald product-development portfolio
Controlling Automated TradeStation Strategies Without Rewriting Their Code
How Emerald’s Start and Stop Trading strategy adds practical trading boundaries to built-in, custom, and black-box strategies.
An automated trading strategy may perform exactly as programmed and still trade at times when its owner would prefer that it stop.
Perhaps the strategy should stop after reaching a daily profit target or loss limit. Perhaps it should trade only during certain hours, on selected days of the week, or during particular months. Perhaps every open position should be closed before the market closes to avoid carrying it overnight.
Making those changes ordinarily requires modifying the strategy’s EasyLanguage code. That may be inconvenient, expensive, or impossible—particularly when the strategy is a proprietary or “black-box” product whose source code is unavailable.
Emerald Trading Technologies developed Start and Stop Trading to solve that problem.
A collection of controls, without rewriting the underlying strategy
Start and Stop Trading is not an entry strategy. It is a collection of independently enabled features that work alongside one or more automated TradeStation strategies.
Most of its features act as a supervisory layer—a form of traffic control that places boundaries around when trading is permitted or requires an exit. Depending on the settings selected by the user, it can:
- Stop one strategy after its specified daily profit target or loss limit is reached.
- Stop multiple strategies trading in the same account when their combined profit or loss reaches an account-wide threshold.
- Permit trading only during designated intraday time windows.
- Permit trading only on selected days of the week or during selected months.
- Exit an open position at a specified time or shortly before the market close.
- Allow trading only while a specified condition remains true.
Trade When True is the important exception. Rather than merely placing an outside boundary around the strategy, it adds a separately defined True-or-False condition that can change when the underlying strategy’s entries are permitted and can optionally trigger an exit when that condition becomes false. It still accomplishes this without rewriting or requiring access to the original strategy code.
Because these controls operate separately from the underlying entry strategy, they can work with TradeStation’s built-in strategies, custom EasyLanguage strategies, and certain protected or black-box strategies whose source code cannot be examined or altered.
It was designed for historical back-testing, optimization, and live automated trading.
Account-wide limits and single-strategy limits solve different problems
The Daily Profit Target and Daily Stop Loss features apply to one strategy. When its specified threshold is reached, that strategy can exit and be prevented from re-entering for the day.
The account-wide versions monitor the combined result of multiple strategies trading in the same account. They can shut down those strategies together when their collective profit or collective loss reaches the user-defined threshold. That distinction matters when several individually acceptable strategies create an unacceptable combined exposure or daily result.
Why “stop after losing $300” is not a complete specification
The request sounds simple. In practice, automated trading requires additional definitions. Does the $300 apply to the entire position or to each share or contract? Should the limit be expressed in dollars, ticks, or in relation to the instrument’s Average True Range? Should an open position be closed when the limit is reached? If so, should the exit occur at a bar close, at the next bar open, or through a special order issued shortly before a specified time?
The correct behavior also depends on the chart’s bar type and interval. A strategy operating on one-minute bars does not evaluate market activity in the same way as one operating on five-minute, tick, volume, or range bars.
Back-testing and live trading may also behave differently. For example, an exit that appears to occur at the market close during a historical test may reach the exchange too late during live trading, leaving the trader with an unintended overnight position. Start and Stop Trading therefore includes provisions for issuing exits before the market close or another designated time.
Those provisions introduce further considerations, including TradeStation’s order-placement settings, the accuracy of the computer’s clock, and synchronization between the strategy’s calculated position and the actual brokerage position.
“Allow this strategy to trade only between 9:45 a.m. and 2:00 p.m. Stop trading for the day after a $500 total-position profit or a $300 total-position loss. Close any remaining position before the market closes, and do not permit another entry that day.”
Working with multiple trading windows
A trader might allow activity from 10:00 a.m. until noon and again from 1:30 p.m. until 2:00 p.m. Overlapping or adjacent windows can be consolidated, while windows may also extend across midnight, weekends, or the end of the year.
These capabilities make the product flexible, but they also demonstrate why careful input validation is essential. Certain combinations can unintentionally create an unrestricted 24-hour, seven-day, or twelve-month window. The software checks for incomplete or conflicting settings and can display an explanatory error rather than silently proceeding with an invalid configuration.
How an AI-guided interface could reduce the learning curve
The underlying product is powerful, but configuring it requires the user to understand both trading intentions and TradeStation terminology. An AI-guided front end could reduce that learning curve without replacing David Cohn’s tested EasyLanguage logic.
Instead of presenting technical input names, an assistant could ask whether the customer is back-testing, simulating, or trading live; identify the chart and bar interval; clarify whether limits are measured in dollars, ticks, or Average True Range; and ask whether positions may remain open overnight.
After collecting the answers, it could present a plain-language confirmation, generate the corresponding settings, flag incompatible choices, explain differences between historical and live behavior, and provide a checklist for entering and verifying the configuration in TradeStation.
The trader—not the AI—would still choose the profit target, risk limit, and permitted trading periods. Any live-trading change should require review and explicit human approval.
What this product demonstrates
The visible request may be short: “Do not let this strategy trade outside these boundaries.” The engineering task is considerably larger. It requires anticipating chart types, time formats, bar behavior, overnight sessions, market holidays, live-order timing, strategy synchronization, conflicting inputs, and differences between historical testing and actual execution.
That distinction remains important in an era when AI can quickly produce code. Producing code is not the same as identifying every condition the code must handle—or determining whether it will behave as intended when exposed to a live market.
Start and Stop Trading demonstrates Emerald Trading Technologies’ approach: understand the operational requirement, identify the exceptions and failure modes, and build controls around the realities of TradeStation.
Discuss your requirements
Need additional control over an automated strategy?
If you need to restrict when a TradeStation strategy may trade, prevent unwanted re-entry, manage time-based exits, or add controls to a strategy whose source code cannot be modified, contact David Cohn to discuss whether this product or a customized EasyLanguage solution may meet your requirements.
Start a conversation