VERVIEWThe Start and Stop Trading strategy offers the unique capability of preventing automated entry/exit strategies from trading when some condition is met, WITHOUT requiring code changes to the entry/exit strategies. WITHOUT requiring code changes means the Trade When True strategy can also be used with “Black Box”, protected, or TradingApp store strategies, where you cannot see or directly access the strategy code.
The Start and Stop Trading strategy exits any open position, Long or Short, and prevents trades after the exit condition is met.
The Start and Stop Trading strategy is all the companion “ForAllStrategies” strategies, listed below, combined into a single strategy to provide a volume discount.
Companion Strategies: The Start and Stop Trading strategy combines together all the "For All Strategies" strategies, listed in the table below, into a single strategy. It also works in combination with any of its companion "For All Strategies" strategies.
DAILY PROFIT TARGET Exit at specified profit target and prevent re-entry
DAILY STOP LOSS Exit at specified stop loss and prevent re-entry
TRADE TIME WINDOW Limit trading to specified intraday time windows
TRADE DAY WINDOW Limit trading to specific days of week
TRADE MONTH WINDOW Limit trading to specific months
EXIT TIME OF DAY Exit at specified time and prevent re-entry
EXIT AT MARKET CLOSE Exit near Market Close and prevent re-entry
TRADE WHEN TRUE Allow trading when an EasyLanguage True/False statement is TRUE
START AND STOP TRADING All strategies above combined into one
Training Videos: A video explaining how to use the Daily Profit Target / Daily Stop Loss strategies, and the companion Trade Time Window, Trade Day Window, and Trade Month Window strategies can be found on the Emerald Trading Technologies YouTube Channel ( Google "Emerald Trading Technologies YouTube" ).
Prerequisites: TradeStation V9.1 Update 24 or later
GENERAL
The Start and Stop Trading strategy can be used in back-testing, optimization, and live-trading. The Start and Stop Trading strategy can be used on an unlimited number of trading charts at the same time.
The Start and Stop Trading strategy does not make entries - it only exits. It works alongside entry/exit strategies inserted on the same chart: Built-in, custom, or even "Black Box" strategies, such as TradingApp Store strategies you subscribe to, where you cannot see the source code.
Cautions/Limitations
This strategy is designed for use on any bar type. However, when using any of the Trade Window capabilities, such as Trade Time Window, Trade Day Window or Trade Month Window, for accurate back-testing results time-based charts are recommended. Time based charts include second bars, minute bars, daily, weekly and monthly bars. Non-time based bars, such as such as Volume, Ticks, Range, Momentum, Renko, Kase, Kagi, 3-Line Break or Point & Figure, may cause strange or incorrect results, because these bar types do not close at regular time intervals. Daily bars may be used when setting trading month windows. Please read the specific Cautions and Limitation for each different section of Inputs.
The OnLineHelp Input: If set to True, the User Manual for this strategy is displayed in a separate browser window. You can move and enlarge this browser window and also save a PDF copy of the User Manual to your local PC from the browser window.
Input Comments: You will notice that most Inputs have comments to the right of the Input value surrounded by curly braces, like: { Comments … }, as shown in the image below. The purpose of these comments is to explain how to set the Input value. You can change the Input value without changing the comment, but if you delete either the left or right curly brace, { or }, the comment text will become part of the Input and you will see an error. You can remove the comment by deleting the curly braces and all the text between them, or you can type over the text between the curly braces to create your own comments.
DAILY PROFIT TARGET Detailed Instructions on Use and Example
General for Daily Profit Target
The Daily Profit Target strategy exits at the open of the next bar after the specified daily profit target is hit or exceeded. It does not exit within the bar. The Daily Profit Target strategy is designed for use on intraday second-based or minute-based bars.
Cautions/Limitations
This strategy is designed for use on intraday second and minute-based charts: Such as 20-second bars, 1-minute bars, 5-minute bars, etc. Use of any other bar types may case strange or incorrect results.
Inputs
The Daily Profit Target strategy has Inputs which:
• Are numerical so they can be used in an optimization
• Allows the daily profit target to be specified:
o On a Position or Per Share/Per Contract Basis
o As a number of Ticks, Dollars or number of the Daily Bar Average True Ranges
o If a Daily Bar Average True Range is used the number of days to use in the Average can be specified
• The Daily Bar Average True Range is only available when using minute-based bars or Daily bars
o The addition of Daily bars to the chart is not required
• Displays this help information when using the strategy
The Inputs are:
1. DailyProfitTgt_Amount: Specify the amount of the daily profit target. Setting this to zero(0) or a negative value turns this strategy off. The type of the amount, ticks, dollars or number of daily bar average true ranges is defined by the Input: ProfitTgtAmountType_TicksOrDollarsOrATR
2. ProfitTgtAmountType_TicksOrDollarsOrATR: Defines the type for the first Input: DailyProfitTgt_Amount. If set to -1, the daily profit target amount is the number of ticks. If set to 0, the amount is dollars. If set to greater than zero the amount is the number of daily bar average true ranges.
3. ProfitTgtAmountBasis_PositionOrPerShare: Specifies if the amount is for the entire position or on a per share or per contract basis.
Daily Profit Target Usage Examples
Example 1
The daily profit target is 10 ticks per share. For stocks, this would typically be 10 pennies per share.
• DailyProfitTgt_Amount: 10
• ProfitTgtAmountType_TicksOrDollarsOrATR: -1
• ProfitTgtAmountBasis_PositionOrPerShare: 1
Example 2
For the ES-mini Futures contract: The daily profit target is 10 ticks, or 10 * $12.50 - $125, for the entire position.
• DailyProfitTgt_Amount: 10
• ProfitTgtAmountType_TicksOrDollarsOrATR: -1
• ProfitTgtAmountBasis_PositionOrPerShare: 0
Example 3
The daily profit target is $500 for the entire position, regardless of the number of shares being traded
• DailyProfitTgt_Amount: 500
• ProfitTgtAmountType_TicksOrDollarsOrATR: 0
• ProfitTgtAmountBasis_PositionOrPerShare: 0
Example 4
The daily profit target is 15% of the Daily Bar Average True Range ( average length - 8 ) on a per share basis.
• DailyProfitTgt_Amount: 0.15
• ProfitTgtAmountType_TicksOrDollarsOrATR: 8
• ProfitTgtAmountBasis_PositionOrPerShare: 1
Example 5
The daily profit target is 22% of the Daily Bar Average True Range ( average length - 15 ) on a per share basis.
• DailyProfitTgt_Amount: 0.22
• ProfitTgtAmountType_TicksOrDollarsOrATR: 15
• ProfitTgtAmountBasis_PositionOrPerShare: 1
Example 6
Turn off this strategy so it has no impact on trading
• DailyProfitTgt_Amount: -1
• ProfitTgtAmountType_TicksOrDollarsOrATR: 0
• ProfitTgtAmountBasis_PositionOrPerShare: 0
DAILY STOP LOSS Detailed Instructions on Use and Examples
General
The Daily Stop Loss strategy exits at the open of the next bar after the specified Daily Stop Loss is hit or exceeded. It does not exit within the bar. The Daily Stop Loss strategy is designed for use on intraday second-based or minute-based bars.
Inputs
The Daily Stop Loss strategy has Inputs which:
• Are numerical so they can be used in an optimization
• Allows the Daily Stop Loss to be specified:
o On a Position or Per Share/Per Contract Basis
o As a number of Ticks, Dollars or number of the Daily Bar Average True Ranges
o If a Daily Bar Average True Range is used the number of days to use in the Average can be specified
• The Daily Bar Average True Range is only available when using minute-based bars or Daily bars
o The addition of Daily bars to the chart is not required
• Displays this help information when using the strategy
The Inputs are:
1. DailyStopLoss_Amount: Specify the amount of the daily stop loss. Setting this to zero(0) or a negative value turns this strategy off. The type of the amount, ticks, dollars or number of daily bar average true ranges is defined by the Input: StopLossAmountType_TicksOrDollarsOrATR
2. StopLossAmountType_TicksOrDollarsOrATR: Defines the type for the first Input: DailyStopLoss_Amount. If set to -1, the Daily Stop Loss amount is the number of ticks. If set to 0, the amount is dollars. If set to greater than zero the amount is the number of daily bar average true ranges.
3. StopLossAmountBasis_PositionOrPerShare: Specifies if the amount is for the entire position or on a per share or per contract basis.
Daily Stop Loss Usage Examples
Example 1
The daily Stop Loss is 8 ticks per share. For stocks, this would typically be 8 pennies per share.
• DailyStopLoss_Amount: 8
• StopLossAmountType_TicksOrDollarsOrATR: -1
• StopLossAmountBasis_PositionOrPerShare: 1
Example 2
For the ES-mini Futures contract: The daily Stop Loss is 12 ticks, or 12 * $12.50 = $150, per contract
• DailyStopLoss_Amount: 12
• StopLossAmountType_TicksOrDollarsOrATR: -1
• StopLossAmountBasis_PositionOrPerShare: -1
Example 3
The daily Stop Loss is $300 for the entire position, regardless of the number of shares being traded
• DailyStopLoss_Amount: 300
• StopLossAmountType_TicksOrDollarsOrATR: 0
• StopLossAmountBasis_PositionOrPerShare: 0
Example 4
The daily Stop Loss is 25% of the Daily Bar Average True Range ( average length = 9 ) on a per share basis.
• DailyStopLoss_Amount: 0.25
• StopLossAmountType_TicksOrDollarsOrATR: 9
• StopLossAmountBasis_PositionOrPerShare: 1
Example 5
The daily Stop Loss is 43% of the Daily Bar Average True Range ( average length = 13 ) on a per share basis.
• DailyStopLoss_Amount: 0.43
• StopLossAmountType_TicksOrDollarsOrATR: 13
• StopLossAmountBasis_PositionOrPerShare: 1
Example 6
Turn off this strategy so it has no impact on trading
• DailyStopLoss_Amount: -1
• StopLossAmountType_TicksOrDollarsOrATR: 0
• StopLossAmountBasis_PositionOrPerShare: 0
EXIT AT MARKET CLOSE Detailed Instructions On Use and Examples
General
The Exit At Market Close strategy can exit so many seconds before the Market Close or Session End time, even when using non-time based intraday bars, such as Tick, Volume, Range, Momentum, Kase, etc., or when using any time-based bars, such as 10-seconds or 5-minutes. This feature of exiting within several seconds of the Market Close only works in LIVE TRADING when real-time ticks( trades ) are occurring. When an exit occurs in LIVE TRADING, you will be notified by "MARKET CLOSE EXIT" appearing in large letters across the chart. They will remain on the chart until the next day. Like the Exit Time Of Day strategy, the Exit At Market Close strategy is NOT required to run on each tick or trade ( Intrabar Order Generation can be disabled ).
The Exit At Market Close strategy is similar to the companion Exit Time Of Day strategy, except it does NOT allow you to specify the exit time, which is always the Market Close or Session End time. This strategy is aimed at allowing a reliable exit very close to the Market Close ( within a few seconds ) to prevent carrying overnight positions for automated strategy trading.
The Exit At Market Close strategy can be used in back-testing, optimization, and live-trading. The Exit At Market Close strategy can be used on an unlimited number of trading charts at the same time.
The Exit At Market Close strategy does not make entries - it only exits. It works alongside entry/exit strategies inserted on the same chart: Built-in, custom, or even "Black Box" strategies, such as TradingApp Store strategies you subscribe to, where you cannot see the source code.
In historical back-testing, the Exit At Market Close strategy exits at the bar Close of the Market Close or Session End time or the first bar Close after this if no bar closes exactly at the Market Close. In LIVE TRADING, if the ExitSecondsBeforeMarketClose Input is set to a positive value, the exit will occur that many seconds before the Market Close or Session End time. If ExitSecondsBeforeMarketClose is NOT set to a positive value ( zero or negative ) the exit order may be issued after the Market Close, resulting in an overnight position in LIVE TRADING. This strategy is best suited for intraday second-based or minute-based bars, but It can be used for other intraday bar types.
Cautions/Limitations
1. This strategy must run on at least one bar Close during the current day the exit is to occur on when real-time ticks ( trades ) are occurring. The bar Close must occur prior to the exit time. For this reason, this strategy does NOT work on Daily, Weekly, or Monthly Bar charts. A run-time error will be issued for Daily, Weekly or Monthly bar charts. It may also not work correctly on non-time based bars, such as Tick or Range, if there are no bar Closes during the day ( when real-time ticks are arriving ) before the exit time.
2. It is important that your local PC Time be accurate, within a second or two of the exact time, as there will be times when your local PC clock is used to exit the position when the ExitSecondsBeforeMarketClose Input is set to a positive value. You can correct your local PC clock using “time.is” on the Internet.
Strategy Settings
When the ExitSecondsBeforeMarketClose Input is set to a positive value, special orders, not regular strategy orders, are used to exit an open position. For these special orders to be issued requires you to Enable order placement objects on the General Tab of the Strategy Properties Window, as shown below.
Because special orders are used to exit an open position, the strategy position may get out of sync after the exit. This may cause a Strategy Automation Warning window to pop-up and prompt you to take action. You may be able to automatically eliminate the warning window/prompt using either the Strategy AutoSync Unlimited or Strategy AutoSync Smart Limit Order Fill TradingApp Store products. Or you can avoid the warning window/prompt by first enabling the strategy to "Adopt the real-world position" on the Automation Tab of the Strategy Properties Window ( see image on next page ). Then immediately after the exit, manually refresh the chart to sync up the strategy with the flat position. To refresh the chart click on an open area of the chart to select it. Then hold down the CONTROL key and press the "R" key. This will cause the strategy to rerun from the beginning of the chart, syncing it up with the flat position.
Inputs
The Exit At Market Close strategy Inputs are:
1. ExitSecondsBeforeMarketClose: If the ExitBeforeMarketCloseEveryDay Input is set to a non-zero value, then setting this input to zero(0) or a negative value means this strategy will issue an exit order on the first bar Close which is equal to or greater than the Market Close or Session End time. In LIVE TRADING this can result in an overnight position. Setting it to a value greater than zero(0) means that in LIVE TRADING, when real-time ticks ( trades ) are occurring, it will exit any open position ExitSecondsBeforeMarketClose seconds before the Market Close ( or Session End Time ). For example, if the Market Close was 4:00 PM, and ExitSecondsBeforeMarketClose was set to 5, any open position, Long or Short, would be exited 5 seconds before the 4:00 PM Market Close at 3:59:55 PM. Setting this to a value of one(1) to exit 1 second before Market Close can be done, but is not recommended, as you risk overnight positions. For historical bars, this Input typically has no impact unless 1-second bars are used.
2. ExitBeforeMarketCloseEveryDay: If the ExitSecondsBeforeMarketClose Input is set to greater than zero(0), setting this input to zero(0) means that exiting just before the Market Close will ONLY occur when a trading window ends on the Market Close time, and the Trading Window strategy Inputs have been set to exit an open position at the end of the trade window. In this mode this strategy works in a special way with the companion Trading Window strategies inserted on the same chart: the TradeTimeWindow strategy, TradeDayWindow strategy and the TradeMonthWindow strategy. ( Note the Exit Time Of Day strategy does NOT work like this. ) For example, if a Trade Time Window was set from 2:00 PM until 4:00 PM, since 4:00 PM is the Market Close, any open position would be exited ExitSecondsBeforeMarketClose seconds before the Market Close. For example, if ExitSecondsBeforeMarketClose were set to 7, then exit would occur 7 seconds before the Market Close at 3:59:53 PM. If the Trade Day Window Inputs were set to allow trading on Tuesday through Thursday, there will be NO Market Close exits on Tuesday or Wednesday. However, on Thursday, the last day in the trading day window, any open position will be exited ExitSecondsBeforeMarketClose seconds before the Market Close. Likewise, if the Trade Month Window Inputs were set to allow trading from March through June, then on the last trading day of June any open position would be exited ExitSecondsBeforeMarketClose seconds before the Market Close. However, there would be no Market Close exits for any other days within the Trade Month Window. If ExitBeforeMarketCloseEveryDay is set to a non-zero value, such as 1 or -5, then Market Close exits will occur every day there is an open position to exit, regardless of the Input settings of other companion "ForAllStrategies" inserted on the same chart.
Exit At Market Close Usage Examples
Example 1
The exit will occur 15 seconds before the Market Close on each day there is an open position at this time. If you are trading stocks where the Market Close is at 4:00:00 PM, then exit would occur at 3:59:45 PM. Note that in historical back-testing you will see exits on the close of the bar at the Market Close.
• ExitSecondsBeforeMarketClose: 15
• ExitBeforeMarketCloseEveryDay: 1 - Exit each day
• Any intraday day bar type.
Example 2
The exit will occur 15 seconds before the Market Close only on days when a trading window ends on the Market Close time and when exiting an open position at the end of the trading window has also been specified. For example, say you are also using the TradeDayWindow strategy where you specified the trading day window to be from Tuesday through Thursday, and that any open position at the end of the trading window on Thursday is to be exited. In this case, any open position on Thursday ONLY would be exited 15 seconds before the Market Close at 3:59:45 PM. Note if you had NO trading window strategies inserted on the same chart, then Exit At Market Close will make no exits. Note that in historical back-testing you will see exits on the close of the bar at the Market Close.
• ExitSecondsBeforeMarketClose: 15
• ExitBeforeMarketCloseEveryDay: 0 - Exit only on days when the trading window ends on the Market Close and exiting the position at the end of the trading window has been specified.
• BarType: Any intraday day bar type.
Example 3
The exit will NOMINALLY occur 1 second before the 4:00 PM Market Close at 3:59:59 PM. This may not reliably exit the position before the Market Close as this is "cutting it very close". If the exit order is received after the Market Close you will remain in a position overnight. It is recommended you thoroughly test this in LIVE TRADING in the Simulation Mode prior to actual LIVE TRADING to verify these exits work reliably. When setting ExitSecondsBeforeMarketClose to a value greater than zero(0), it is best if the strategy an obtain a real-time ( LIVE TRADING ) time stamp for a bar Close on the same day prior to the actual exit time. If the strategy is started up, but no LIVE TRADING bar Close occurs prior to the exit time, your local PC time clock will be used instead to establish the correct time. If your local PC time is incorrect the exit time will be incorrect ( you can the correct time using "time.is" on the Internet ). Note that in historical back-testing you will see exits on the close of the bar at the Market Close.
• ExitSecondsBeforeMarketClose: 1
• ExitBeforeMarketCloseEveryDay: 1 - Exit each day
• BarType: Any intraday bar type
Example 4
No exit just before the Market Close in LIVE trading. Exit orders will be issued right at the Market Close, which can result in overnight positions when LIVE TRADING. You will see exits at the Market Close in historical back-testing ( or if no bars close exactly at the Market Close, then on the first bar close which occurs after the Market Close ). For example, if you are using 1-minute bars, then in historical back-testing you will see exits at the bar Close of the 4:00 PM bar. If using Range bars, and no Range bar closed exactly at 4:00 PM, then you will see an exit at the close of the next day’s first bar.
• ExitSecondsBeforeMarketClose: 0 – No exit will occur before the Market Close. This can result in overnight positions in LIVE TRADING.
• ExitBeforeMarketCloseEveryDay: 1
• BarType: Any intraday bar type
Example 5
Turn the strategy off so there are no exits in historical back-testing or LIVE TRADING.
• ExitSecondsBeforeMarketClose: 0
• ExitBeforeMarketCloseEveryDay: 0
• BarType: Any intraday bar type
Exit Time Of Day DETAILED INSTRUCTIONS ON USE AND EXAMPLES
General
The Exit Time Of Day strategy can be tailored to exit so many seconds before the specified EndOfDayExitTime, even when using non-time based intraday bars, such as Tick, Volume, Range, Momentum, Kase, etc., or when using any time-based bars, such as 10-seconds or 5-minutes. This feature only works in LIVE TRADING when real-time ticks( trades ) are occurring. When an exit occurs in LIVE TRADING, you will be notified by "END OF DAY EXIT" appearing in large letters across the chart. They will remain on the chart until the next day. Like the Exit At Market Close strategy, the Exit Time Of Day strategy is NOT required to run on each tick or trade ( Intrabar Order Generation can be disabled ).
The Exit Time Of Day strategy is similar to the companion Exit At Market Close strategy, except it allows you to specify the exit time, where the Exit At Market Close strategy uses the Market Close or Session End time. The Exit Time Of Day strategy also fixes major issues with exiting near the Market Close for automated strategy trading to avoid being caught in an overnight position. For more information see the Exit At Market Close strategy instructions.
The Exit Time Of Day strategy exits at the open of the next bar after the exit time is hit or exceeded if the ExitSecondsBeforeEndOfDayTime Input is set to zero(0) or less. It does not exit within the bar. If the ExitSecondsBeforeEndOfDayTime Input is set to a positive value, the exit will occur that many seconds before the exit time specified in the ExitEndOfDayTime Input is hit. The Exit Time Of Day strategy is best suited for intraday second-based or minute-based bars, but It can be used for other intraday bar types.
Cautions/Limitations
1. This strategy must run on at least one bar Close during the current day the exit is to occur on when real-time ticks ( trades ) are occurring. The bar Close must occur prior to the exit time. For this reason, this strategy may not work correctly on strategies running only on the bar Closes of Daily, Weekly, or Monthly Bar charts. It may also not work correctly on non-time based bars, such as Tick or Range, if there are no bar Closes during the day ( when real-time ticks are arriving ) before the exit time.
2. It is important that your local PC Time be accurate, within a second or two of the exact time, as there will be times when your local PC clock is used to exit the position when the ExitSecondsBeforeEndOfDayTime Input is set to a positive value. You can correct your local PC clock using “time.is” on the Internet.
Strategy Settings
When the ExitSecondsBeforeEndOfDayTime Input is set to a positive value, special orders, not regular strategy orders, are used to exit an open position. For these special orders to be issued requires you to Enable order placement objects on the General Tab of the Strategy Properties Window, as shown below.
Because special orders are used to exit an open position, the strategy position may get out of sync after the exit. This may cause a Strategy Automation Warning window to pop-up and prompt you to take action. You may be able to automatically eliminate the warning window/prompt using either the Strategy AutoSync Unlimited or Strategy AutoSync Smart Limit Order Fill TradingApp Store products. Or you can avoid the warning window/prompt by first enabling the strategy to "Adopt the real-world position" on the Automation Tab of the Strategy Properties Window ( see image on next page ). Then immediately after the exit, manually refresh the chart to sync up the strategy with the flat position. To refresh the chart click on an open area of the chart to select it. Then hold down the CONTROL key and press the "R" key. This will cause the strategy to rerun from the beginning of the chart, syncing it up with the flat position.
Inputs
The Inputs are:
1. ExitEndOfDayTime: Setting the Input to -1 turns this strategy off. Setting it to a value of 0 or greater turns this strategy on. Times are specified in the TradeStation standard 24-hour military HHMM time format: 3:30 AM is 330, 9:30 AM is 930, noon is 1200, 2:30 PM is 1430, 8:30 PM is 2030, 11:45 PM is 2345 and midnight is 0 ( NOT 2400 ).
2. ExitSecondsBeforeEndOfDayTime: Setting the Input to zero(0) or less disables it. If set to zero(0) this strategy is designed for use on intraday minute-based bars with the strategy running on the bar Closes. Using any other bar types may result in incorrect or strange behavior. However, you are not prohibited from using this with other bar types. Note this feature does NOT work in back-testing. It only works in Live trading when real-time ticks ( trades ) are occurring. For example, if the ExitEndOfDayTime was set to 1600 ( 4:00 PM, typical Market Close time for stocks ), and ExitSecondsBeforeEndOfDayTime was set to 10, in back-testing on 1-minute bars you would only see exits occur at the open of the next bar after the 4:00 PM bar Close, which may be the open of the first bar of the next day. However, in Live Trading you would see an exit occur 10-seconds before 4:00 PM.
Exit Time Of Day Usage Examples
Example 1
The exit will occur at the next bar open after 1400 ( 2:00 PM ) is hit or exceeded. Assuming 5-minute bars were being used, the exit would be seen at the open of the 2:05 PM bar.
• ExitEndOfDayTime: 1400
• ExitSecondsBeforeEndOfDayTime: 0
• BarType: A 5-minute bar chart
Example 2
The exit will occur 5 seconds before 1400 ( 2:00 PM ) or at 1:59:55 PM when LIVE TRADING ( NOT in back-testing ). The ExitSecondsBeforeEndOfDayTime Input is ignored in back-testing. This will work for any intraday bar type. When setting ExitSecondsBeforeEndOfDayTime to a value greater than zero (0), it is best if the strategy can obtain a real-time time stamp for a bar Close on the same day prior to the actual exit time. If the strategy is first started on the day of the exit, but no real-time bar Close occurs prior to the exit time, your local PC time clock will be used instead to establish the correct time. If your local PC time is incorrect ( you can the correct time using "time.is" on the Internet ) the exit time will be incorrect.
• ExitEndOfDayTime: 1400
• ExitSecondsBeforeEndOfDayTime: 5
• BarType: Any intraday bar type, such as 5-minute bar chart or a non-time based bar, like Tick, Volume, Momentum, Range, Renko, Kagi, 3-Line Break, Kase, and Point & Figure
Example 3
The exit will occur at the next bar open after 1559 ( 3:59 PM ) is hit or exceeded. Assuming 1-minute bars were being used, the exit would be seen at the open of the 4:00 PM bar, 1 minute before the Market Close for stocks.
• ExitEndOfDayTime: 1559
• ExitSecondsBeforeEndOfDayTime: 0
• BarType: A 1-minute bar chart
Example 4
The exit will occur at the next bar open after 1600 ( 4:00 PM - Market Close for stocks ) is hit or exceeded. This will NOT reliably exit the position at the Market Close of 4:00 PM ( for stocks ) because it may arrive at the Exchange just after the Market Close, meaning you would carry an overnight position, and the exit would become effective the next day at the Market Open. This is NOT recommended if you want to avoid carrying overnight positions.
• ExitEndOfDayTime: 1600 ( Market Close for stocks )
• ExitSecondsBeforeEndOfDayTime: 0
• BarType: A 1-minute bar chart
Example 5
The exit will occur 3 seconds before 1600( 4:00 PM - Market Close for stocks ) in LIVE TRADING. The ExitSecondsBeforeEndOfDayTime Input is ignored in back-testing. This should reliably exit the position before the Market Close for any intraday bar type, as long your local PC clock time is very accurate or the strategy is able to run on a real-time bar Close prior the exit time, as explained in Example (2) above.
• ExitEndOfDayTime: 1600 ( Market Close for stocks )
• ExitSecondsBeforeEndOfDayTime: 3
• BarType: Any intraday bar type
Example 6
The exit will NOMINALLY occur 1 second before 1600( 4:00 PM - Market Close for stocks ) in LIVE TRADING. The ExitSecondsBeforeEndOfDayTime Input is ignored in back-testing. This may not reliably exit the position before the Market Close as this is "cutting it very close". It is recommended you thoroughly test this in the Simulation Mode prior to live trading this to verify the exits occur reliably before the Market Close. Note that caveats explained in Example (2).
• ExitEndOfDayTime: 1600 ( Market Close for stocks )
• ExitSecondsBeforeEndOfDayTime: 1
• BarType: Any intraday bar type
Example 7
The exit will occur at the next bar open after 1046 ( 10:46 AM ) is hit or exceeded. Assuming 5-minute bars were being used, the exit would occur at the open of the 10:55 AM bar, because it would not be until the close of the 10:50 AM bar that the exit time was exceeded.
• ExitEndOfDayTime: 1046
• ExitSecondsBeforeEndOfDayTime: 0
• BarType: A 5-minute bar chart
Example 8
The exit will occur at the next bar open after 1046 ( 10:46 AM ) is hit or exceeded. Because Range bars are being used, which do not have specified time intervals, all we can say is the exit would occur some time after 10:46 AM.
• ExitEndOfDayTime: 1046
• ExitSecondsBeforeEndOfDayTime: 0
• BarType: A Range bar chart
Example 9
The exit will occur 1 second before 1046( 10:45:59 AM ) in LIVE TRADING. The ExitSecondsBeforeEndOfDayTime Input is ignored in back-testing. Because the ExitSecondsBeforeEndOfDayTime Input was set to a value greater than zero(0), this should work reliably for any bar type. See the caveats explained in Example (2).
• ExitEndOfDayTime: 1046
• ExitSecondsBeforeEndOfDayTime: 1
• BarType: A Range bar chart
Example 10
Turn this strategy off so it has no impact on trading.
• ExitEndOfDayTime: -1
• BarType: Any intraday bar type
TRADE TIME WINDOW Detailed Instructions on Use and Examples
General
The Trade Time Window strategy offers the unique capability of preventing entry/exit strategies from trading outside a specified time window, WITHOUT requiring code changes to the entry/exit strategies.
The Trade Time Window strategy can be used in back-testing, optimization, and live-trading. The Trade Time Window strategy can be used on an unlimited number of trading charts at the same time.
The Trade Time Window strategy does not make entries - it only exits. It works alongside entry/exit strategies inserted on the same chart: Built-in, custom, or even "Black Box" strategies, such as TradingApp Store strategies you subscribe to, where you cannot see the source code.
The Trade Time Window strategy exits at the end of the trading time window either at the bar Close or at the open of the first bar after the trading time window end time. It does not exit within the bar. The Trade Time Window strategy is designed for use on intraday minute-based bars.
When defining trading time windows, you can specify windows which span midnight. For example, you could define the trading time window to begin at 10:00 PM and end at 4:00 AM.
Creating Multiple Trading Time Windows
You can insert the Trade Time Window strategy repeatedly on a chart to create multiple trading time windows. For example, you could insert it twice to set 10:00 AM until 12:00 Noon and 1:30 PM until 2:00 PM as separate trading time windows. In this scenario trading would be allowed from 10:00 AM until 12:00 Noon and from 1:30 PM until 2:00 PM. Trading would be prevented the rest of the time. However, if you set the trading time windows to 10:00 AM until 11:00 AM and 10:45 AM until 2:00 PM, the overlapping trading time windows would be combined or “consolidated” into a single trading time window from 10:00 AM until 2:00 PM. In this scenario trading would be allowed from 10:00 AM until 2:00 PM, and would be prevented the rest of the time. Likewise, any adjacent trading time windows will be combined into a single trading time window. For example, if you inserted the Trade Time Window strategy twice on the chart and set one trading time window from 10:00 AM until 11:00 AM and the second trading time window from 11:00 AM until 2:00 PM, then a single combined trading time window from 10:00 AM until 2:00 PM would be created. Note that adjacent time windows end and begin at exactly the same time. Note that if the window ending and beginning times have only 1-minute between them they are not considered adjacent windows and will not be combined. For example, the two time windows of 10:00 AM until 10:59 AM and 11:00 AM until 2:00 PM would NOT be combined into a single time window. There is no limit on the number of time windows which can be combined up to the total number of time windows. It is possible to combine all the time windows into a single time window providing all the time windows overlap or are adjacent.
When a trading time window spans midnight, you can carry overnight positions within the trading time window. For example, if you set the trading time window to be from 11:00 AM until 10:00 AM, this window begins at 11:00 AM and continues past midnight until 10:00 AM the following day. Time windows which span midnight always have a beginning or start times which are greater than the end time.
Time windows which span midnight can be combined with time windows which precede or follow them. For example, the two time windows of 11:30 AM until 2:00 PM and 2:00 PM until 10:00 AM will be combined into a single time window from 11:30 AM until 10:00 AM.
Multiple time windows can be combined into a 24-hour or continuous time window. For example, the 3 time windows: 9:30 AM until 3:00 PM, 2:30 PM until 11:00 PM, and 11:00 PM until 9:45 AM, will combine into a single 24-hour window. A 24-hour time window is effectively no time window, because trading is allowed at all times. Depending on the Inputs settings which are explained next, 24-hour time windows may be ignored or cause a run-time error to be thrown and the strategies aborted. 24-hour time windows may also occur during optimization of time windows.
Cautions/Limitations
1. This strategy is designed for use on intraday minute-based charts: Such as 1-minute bars, 5-minute bars, etc. Use of any other bar types may case strange or incorrect results. Using second-based bars may also cause issues, especially if the second-based bars do not divide evenly into a 1-minute bar. For example, 13-second bars do not divide evenly into a 1-minute bar.
2. Do not use this strategy to exit at the Market Close in Live Trading: This strategy can exit exactly at the Market Close in Back-testing if the last bar of the trading time window is also the last bar of the day. However, to reliably exit at the Market Close in Live Trading requires using the companion ExitAtMarketClose or ExitTimeOfDay strategy. See Example 5.
3. Limit of 50 time windows: To create multiple trading time windows this strategy must be inserted on the chart repeatedly for each unique trading time window required. This strategy is limited to being inserted 50 times on a chart. In other words, you are limited to defining no more than 50 trading time windows.
4. Exiting on the bar Close for Gap-type strategies: If the ExitPosAtEndOfTradeTimeWindowOnBarClose Input is set to something other than zero(0), then it will exit at the bar Close price at the end of the trading time window. This option may not work when using "Gap-type" strategies which run on bar Opens, causing run-time errors to be thrown and the strategies turned off. See Example 2.
Inputs
The Trade Time Window strategy has nine(9) Inputs which:
• Are numerical so they can be used in an optimization
• Allow you to easily define a trading window start and end time, and optimize the start and end times
• Work for time windows which span midnight
• Intelligently combine overlapping trading time windows when the strategy is repeatedly inserted on the chart to create multiple trading time windows
• Allows you to optionally exit an open position when the trade window end time is hit
• Allows you to precisely exit at the bar Close at the end of the trade time window, or exit at the following bar Open.
• Displays this help information when using the strategy
The Inputs are:
3. TradeStartTime: Specify the time when the trade time window begins - when entries may first occur. Times are specified in the TradeStation standard 24-hour military HHMM time format: 3:30 AM is 330, 9:30 AM is 930, noon is 1200, 2:30 PM is 1430, 8:30 PM is 2030, 11:45 PM is 2345 and midnight is 0 ( NOT 2400 ). Setting this to -1 turns this strategy off.
4. TradeEndTime: Specify when the trade time window ends – when exits may occur. Uses the TradeStation standard 24-hour HHMM format. Setting this to -1 turns this Input off. To define a trading time window, EITHER the TradeEndTime Input must be set, or the AddMinutesToOptimizeTradeEndTime Input must be set, but NOT both.
5. AddMinutesToOptimizeTradeStartTime: This is added to the TradeStartTime value to set a trade window starting time. This input is typically used to optimize the TradeStartTime. To optimize the TradeStartTime, first set the TradeStartTime to a fixed value ( don’t optimize its value ). Then optimize this Input. For example, to optimize the Trading Window Start Time from 9:30 AM until 11:30 AM in ½ hour steps, set the TradeStartTime to 930, and set the AddMinutesToOptimizeTradeStartTime Start / End / Increment Optimization values of
0 / 120 / 30. Positive values increase the TradeStartTime and negative values decrease it. Setting
this to zero(0) turns this off.
6. AddMinutesToOptimizeTradeEndTime: This value is added to the TradeStartTime value to set a trade window ending time. This input is typically used to optimize the TradeEndTime. To optimize the TradeEndTime, turn it off by setting its value to -1. Then optimize this Input. For example, to optimize the Trading Window End Time from 10:30 AM to 12:30 PM in ½ hour steps with the TradeStartTime set to 9:30 AM, set the TradeEndTime to -1 ( turn it off ) and set the AddMinutesToOptimizeTradeEndTime Start / End / Increment Optimization values of 60 / 180 / 30. Use only positive values. Setting this to zero(0) turns this off.
7. ExitPositionAtEndOfTradeTimeWindow: If set to something other than zero(0), closes out any open position at the end of the trade time window.
8. ExitPosAtEndOfTradeTimeWindowOnBarClose: If set to zero(0) exits at the open of the bar following the trade time window. If set to something other than zero(0), then it will exit at the bar Close price at the end of the trade time window. This option may not work when using "gap-type" strategies which run on bar Opens. For example, if the trade time window ends at 2:00 PM and 5-minute bars are being used, if this value is set to zero(0) the exit will occur at the open of the 2:05 PM bar. If this value is set to one(1) the exit will occur at the bar Closing price on the 2:00 PM bar.
9. Ignore24HourTimeWindow: If set to a non-zero value any 24-hour time window, which is an around-the-clock time window, created by combining multiple overlapping time windows, or due to an optimization, or due to Input settings, will be ignored. A 24-hour time window means that trading can occur at any time, so it is effectively NOT a time window. If this Input is set to a zero(0) value 24-hour time windows will NOT be ignored and will cause an error to be thrown and the strategies to be aborted. Note that for stocks trading regular Market hours ( a regular session ), from 9:30 AM to 4:00 PM Eastern Time, a 24-hour window is defined if the TradeStartTime and TradeEndTime Inputs are set to the session begin and end times of 9:30 AM and 4:00 PM. If this happens a run-time error message will be thrown, like shown below.
When multiple overlapping time windows are combined to form a 24-hour window you will see an error message displayed on a pop-up form, like shown on the next page. Trades may be shown on a back-test, but as soon as the OK button is clicked on the Form the strategies will be aborted.
10. IgnoreSameTradeStartAndEndTimes: If set to a non-zero value, and the TradeStartTime and TradeEndTime Inputs are set to identical values, the time window is treated like a 24-hour time window and ignored. If this Input is set to zero(0), then a run-time error will be thrown and the strategies aborted.
11. OnLineHelp: If set to True, displays this information in a Window when the strategy starts up
Input Comments:
You will notice that most Inputs have comments to the right of the Input value surrounded by curly braces, like: { Comment }, as shown in the image below.
The purpose of these comments is to explain how to set the Input value. You can change the Input value without changing the comment, but if you delete either the left or right curly brace, { or }, the comment text will become part of the Input and you will see an error. You can remove the comment by deleting the curly braces and all the text between them, or you can type over the text between the curly braces to create your own comment.
Error Checking Inputs
The Trading Time Window strategy inputs are error checked and if an error is detected a run-time error will be issued with an explanatory message (as shown below ), or a Form will pop-up displaying the error message with an OK button at the bottom, and the strategies aborted ( turned off ). You will have to turn the strategies back on and reset the Inputs to clear the error and have the strategies run.
Input errors checked for are:
• Incomplete settings, such as the TradeStartTime Input is set ( to a value greater than 0 ), but the TradeEndTime Input is not set.
• Setting the same values for TradeStartTime and TradeEndTime Inputs. This is further explained in the preceding section on Inputs.
• Setting the TradeStartTime and TradeEndTime Inputs to create a 24-hour time window. This is further explained in the preceding section on Inputs.
• Creating a 24-hour time window when multiple overlapping time windows are combined. This is further explained in the preceding section on Inputs.
Usage Examples
Example 1
A one hour trading time window from 9:30 to 10:30 AM. Entries can only occur between 9:30 AM and 10:29 AM. Entries will be allowed to occur beginning at the next bar open after 9:30 AM is hit or exceeded at a bar Close. Stop and Limit entries within the bar may occur. If there is an open position ( Long or Short ) at 10:30 AM it will NOT be exited.
• TradeStartTime: 930
• TradeEndTime: 1030
• AddMinutesToOptimizeTradeStartTime: 0
• AddMinutesToOptimizeTradeEndTime: 0
• ExitPositionAtEndOfTradeTimeWindow: 0
• ExitPosAtEndOfTradeTimeWindowOnBarClose: 1
Example 2
"Gap-type" entry/exit strategy which runs on bar Opens. Regular strategies run on bar Closes. This requires the ExitPosAtEndOfTradeTimeWindowOnBarClose Input be set to zero(0). 1-hour trading time window from 9:30 to 10:30 AM. Entries can only occur between 9:30 AM and 10:29 AM. Entries will be allowed to occur beginning at the next bar open after 9:30 AM is hit or exceeded at a bar Close. Stop and Limit entries within the bar may occur. If there is an open position ( Long or Short ) at 10:30 AM it will NOT be exited.
• TradeStartTime: 930
• TradeEndTime: 1030
• AddMinutesToOptimizeTradeStartTime: 0
• AddMinutesToOptimizeTradeEndTime: 0
• ExitPositionAtEndOfTradeTimeWindow: 0
• ExitPosAtEndOfTradeTimeWindowOnBarClose: 0. This may have to be set to zero(0) for a "gap-type" strategy if you see errors when the strategy runs causing all the strategies to shut down.
Example 3
75-minute trading time window from 9:45 to 11:00 AM. Entries can only occur between 9:45 AM and 10:59 AM. Entries will be allowed to occur at the next bar open after 9:45 AM is hit or exceeded at a bar Close. Stop and Limit entries within the bar may occur. If there is an open position ( Long or Short ) at 11:00 AM it WILL be exited at the first bar open after 11:00 AM is hit or exceeded.
• TradeStartTime: 945
• TradeEndTime: 1100
• AddMinutesToOptimizeTradeStartTime: 0
• AddMinutesToOptimizeTradeEndTime: 0
• ExitPositionAtEndOfTradeTimeWindow: 1
• ExitPosAtEndOfTradeTimeWindowOnBarClose: 1
Example 4
Near full day trading time window from 9:30 AM until 15:59 PM ( 1-minute before Market Close ). Assumes a 1-minute bar chart. For 1-minute bars the first bar of the day closes at 9:31 AM. Entries will be allowed between the open of the 9:32 AM bar and the close of the 15:59 PM bar. Entries will be allowed to occur at the 9:32 AM bar open. Stop and Limit entries within the bar may occur. If there is an open position ( Long or Short ) at 11:00 AM it WILL be exited at the first bar open after 11:00 AM is hit or exceeded.
• TradeStartTime: 930
• TradeEndTime: 1559
• AddMinutesToOptimizeTradeStartTime: 0
• AddMinutesToOptimizeTradeEndTime: 0
• ExitPositionAtEndOfTradeTimeWindow: 1
• ExitPosAtEndOfTradeTimeWindowOnBarClose: 1
Example 5
Full day trading time window from 9:30 AM until 16:00 PM ( Market Close ). Exit on 4:00 PM bar Close. This is not recommended as exiting exactly at the Market Close is unreliable. For more information see the companion ExitAtMarketClose or ExitTimeOfDay Strategy instructions.
• TradeStartTime: 930
• TradeEndTime: 1600
• AddMinutesToOptimizeTradeStartTime: 0
• AddMinutesToOptimizeTradeEndTime: 0
• ExitPositionAtEndOfTradeTimeWindow: 1
• ExitPosAtEndOfTradeTimeWindowOnBarClose: 1
Example 6
Trading time window from 11:00 PM until 2:00 AM - spans midnight. Exit on 2:00 AM bar Close.
• TradeStartTime: 2300
• TradeEndTime: 200
• AddMinutesToOptimizeTradeStartTime: 0
• AddMinutesToOptimizeTradeEndTime: 0
• ExitPositionAtEndOfTradeTimeWindow: 1
• ExitPosAtEndOfTradeTimeWindowOnBarClose: 1
Example 7
Strategy inserted twice on chart with 2 overlapping trading time windows from 10:00 to 11:00 AM and 10:45 AM to 12:00 PM ( Noon ). The 2 time windows will be combined to a single window of 10:00 AM until 12:00 PM ( Noon ). The exit at the end of the first window ( 11:00 AM ) will be ignored when combining time windows.
Settings for first strategy: 10:00 to 11:00 AM with exit at 11:00 AM:
• TradeStartTime: 1000
• TradeEndTime: 1100
• AddMinutesToOptimizeTradeStartTime: 0
• AddMinutesToOptimizeTradeEndTime: 0
• ExitPositionAtEndOfTradeTimeWindow: 1 ( This will be ignored when combined with an overlapping window that extends beyond this window's ending time )
• ExitPosAtEndOfTradeTimeWindowOnBarClose: 1
Settings for second strategy: 10:45 AM - 12:00 PM with exit at 12:00 PM:
• TradeStartTime: 1045
• TradeEndTime: 1200
• AddMinutesToOptimizeTradeStartTime: 0
• AddMinutesToOptimizeTradeEndTime: 0
• ExitPositionAtEndOfTradeTimeWindow: 1
• ExitPosAtEndOfTradeTimeWindowOnBarClose: 1
Example 8
Turn off this strategy so it has no impact on trading by setting the start time to -1.
• TradeStartTime: -1
• TradeEndTime: -1
• AddMinutesToOptimizeTradeStartTime: 0
• AddMinutesToOptimizeTradeEndTime: 0
• ExitPositionAtEndOfTradeTimeWindow: 0
• ExitPosAtEndOfTradeTimeWindowOnBarClose: 1
Example 9
Optimize a strategy to determine how it performs in each 30-minute window during regular Market hours, beginning at 9:30 AM and ending at 4:00 PM. The first 30-minute window is from 9:30 - 10:00 AM, the second 30-minute window is from 10:00 - 10:30 AM and so forth until the last 30-minute window from 3:30 - 4:00 PM.
• TradeStartTime: 930
• TradeEndTime: -1 ( turn this off for no conflict with AddMinutesToOptimizeTradeEndTime )
• AddMinutesToOptimizeTradeStartTime: Optimization: Start / End / Increment: 0 / 360 / 30
• AddMinutesToOptimizeTradeEndTime: : 30
• ExitPositionAtEndOfTradeTimeWindow: 1
• ExitPosAtEndOfTradeTimeWindowOnBarClose: 1
Example 10
Optimize a strategy to determine how it performs in each 15-Minute, 30-minute, 45-minute and 1 hour window during regular Market hours, beginning at 9:30 AM and ending at 4:00 PM.
• TradeStartTime: 930
• TradeEndTime: -1 ( turn this off for no conflict with AddMinutesToOptimizeTradeEndTime )
• AddMinutesToOptimizeTradeStartTime: Optimization: Start / End / Increment: 0 / 330 / 15
• AddMinutesToOptimizeTradeEndTime: Optimization: Start / End / Increment: 15 / 60 / 15
• ExitPositionAtEndOfTradeTimeWindow: 1
• ExitPosAtEndOfTradeTimeWindowOnBarClose: 1
TRADE DAY WINDOW Detailed Instructions on Use and Examples
General
The Trade Day Window strategy can be used in back-testing, optimization, and live-trading. The Trade Day Window strategy can be used on an unlimited number of trading charts at the same time.
The Trade Day Window strategy does not make entries - it only exits. It works alongside entry/exit strategies inserted on the same chart: Built-in, custom, or even "Black Box" strategies, such as TradingApp Store strategies you subscribe to, where you cannot see the source code.
The Trade Day Window strategy exits at the end of the trading day window either at the bar Close or at the open of the first bar after the end day of the trading day window. It does not exit within the bar. The Trade Day Window strategy is designed for use on intraday minute-based bars or Daily bars.
When defining trading day windows, you can specify windows which span the weekend. For example, you could define the trading day window to begin on Thursday and end on Tuesday. Also when defining trading day windows, you can specify the same day as the start and end day, so that trading is only allowed on this day.
Look ahead algorithms are used to enter at the beginning of days for trading day windows and to account for US Market Holidays when possible. TradeStation does not allow you to directly look ahead ( when strategies are typically running on bar Closes ) to see the next bar Date and Time, so rather exotic coding logic is required to look ahead, depending on the bar type and bar interval. Half-trading days, such as the day before or after Thanksgiving, and Christmas Eve, are not accounted for. For example, if using Daily bars with a trading day window set to Monday through Tuesday, you will see entry at the beginning of the Monday Daily bar, and exit at the close of the Tuesday Daily bar, or at the open of the Wednesday Daily bar, depending on the settings of the ExitPositionAtEndOfTradeDayWindow and ExitPosAtEndOfTradeDayWindowOnBarClose Inputs. For example, if using Daily bars with a trading day window of Tuesday through Wednesday, and ExitPositionAtEndOfTradeDayWindow is set to exit at the end of the trading day window and ExitPosAtEndOfTradeDayWindowOnBarClose is set to exit at the bar Close, if look ahead logic sees that Wednesday is a holiday, exit will occur at the close of the Tuesday Daily bar. Look ahead is generally reliable, but there may be some scenarios where it does not work perfectly.
Creating Multiple Trading Day Windows
You can insert the Trade Day Window strategy repeatedly on a chart to create multiple trading day windows. For example, you could insert it twice to set Monday and Wednesday as separate trading day windows. In this scenario trading would be allowed on Monday and Wednesday, and prevented on Tuesday, Thursday or Friday. However, if you set the trading day windows to Monday and Tuesday, the adjacent trading day windows would be combined or “consolidated” into a single trading day window from Monday through Tuesday. In this scenario trading would be allowed on Monday and Tuesday, and prevented on Wednesday through Friday. Likewise, any adjacent trading day windows will be combined into a single trading day window. For example, if you inserted the Trade Day Window strategy twice on the chart and set one trading day window from Monday through Tuesday and the second trading day window from Wednesday through Thursday, then a single combined trading day window from Monday through Thursday would be created. Note that Monday and Friday are considered as adjacent days when trading stocks. So if the first trading day window was Friday and the second trading day window was Monday, the two trading day windows would be combined into a single trading day window, from Friday through Monday.
When a trading day window spans multiple days, you can carry overnight positions within the trading day window. For example, if you set the trading day window to be from Monday through Wednesday, you can carry overnight positions on Monday and Tuesday. On Wednesday, any open position could be exited at the end of the day. If you do NOT want overnight positions, you need to use the ExitTimeOfDay or ExitAtMarketClose strategy in combination with the Trade Day Window strategy.
If you create a single trading window which spans the entire week, or multiple adjacent trading day windows which when combined span the entire week, such as starting on Monday ( Sunday for Futures or Forex ) and ending on Friday, or starting on Wednesday and ending on Tuesday ( spanning the weekend ) then effectively there is no trading day window, as trading is allowed for all days of the week. This may happen when optimizing the Trade Day Window strategy Inputs, or when using multiple trading day windows. Depending on the setting for the Ignore7DayTradingWindow Input, this scenario will either be ignored or a run-time error will be thrown and the strategy aborted. This is further explained in the Inputs section.
Cautions/Limitations
1. This strategy is designed for use on intraday minute-based or Daily bar charts: Such as 1-minute bars, 5-minute bars, Daily bars, etc Use of any other bar types may case strange or incorrect results. Using second-based bars may also cause issues, especially if the second-based bars do not divide evenly into a 1-minute bar. For example, 13-second bars do not divide evenly into a 1-minute bar.
2. Do not use this strategy to exit at the Market Close in Live Trading: This strategy can exit exactly at the Market Close in historical Back-testing on the last bar of the last day of the trading day window. However, to reliably exit at the Market Close in Live Trading requires using the companion ExitAtMarketClose or ExitTimeOfDay strategy. See Example 3.
3. Limit of 4 Day windows: To create multiple trading day windows this strategy must be inserted on the chart repeatedly for each unique trading day window required. This strategy is limited to being inserted 4 times on a chart. In other words, you are limited to defining no more than 4 trading day windows. Since adjacent trading day windows are combined as explained on the prior page, you cannot define more than three(3) non-adjacent trading day windows.
4. Exiting on the bar Close for Gap-type strategies: If the ExitOnBarClose Input is set to something other than zero(0), then it will exit at the bar Close price at the end of the trade Day window. This option may not work when using "Gap-type" strategies which run on bar Opens, causing run-time errors to be thrown and the strategies turned off.
Inputs
The Trade Day Window strategy has six(6) Inputs which:
• Are numerical so they can be used in an optimization
• Allow you to easily define a trading window start and end days, and optimize the start and end days
• Work for trading day windows which span weekends
• Intelligently combine ( “consolidate” ) adjacent and overlapping trading day windows when the strategy is repeatedly inserted on the chart to create multiple trading day windows
• Allows you to optionally exit an open position when the end day of the trading day window is hit
• Allows you to precisely exit at the bar Close at the end of the trading day window, or exit at the following bar Open.
• Can ignore when a 7-day trading day window is created or issue a run-time error and abort the strategy.
The Inputs are:
1. TradeStartDay: Specify when the trading day window starts: The first day when entries may first occur. Setting this to -1 turns this strategy off. Sunday= 0, Monday = 1, Tuesday = 2, … Friday = 5. There is no trading on Saturday.
2. TradeEndDay: Specify when the trading day window ends: The last day when trading may occur.
3. AddDaysToOptimizeTradeEndDay: This value is added to the TradeStartDay value to set a trade window end day. This input is typically used to optimize the TradeEndDay. To optimize the TradeEndDay, turn it off by setting its value to -1. Then optimize this Input. For example, to optimize the Trading Window End Day from Monday to Wednesday in steps of 1 day with the TradeStartDay set to Monday, set the TradeEndDay to -1 ( turn it off ) and set the AddDaysToOptimizeTradeEndDay Start / End / Increment Optimization values of 1 / 3 / 1. Use only positive values. Setting this to zero(0) turns this off. The minimum value = 1 and the maximum value = 5.
4. ExitPositionAtEndOfTradeDayWindow: If set to something other than zero(0), closes out any open position at the open of the last bar of the last day in the trade day window.
5. ExitPosAtEndOfTradeDayWindowOnBarClose: If set to zero(0) exits at the open of the bar following the daily trade window. If set to something other than zero(0), then it will exit at the bar Close of the last bar of the day. This option may not work when using "Gap-type" strategies which run on bar Opens. For example, if the trade day window ends on Wednesday and 5-minute bars are being used, if this value is set to zero(0) the exit will occur at the open of the first bar on Thursday. If this value is set to one(1) the exit will occur at the bar Closing price on the 4:00 PM bar ( at Market Close ). Note that exits which occur exactly at the Market Close work fine in back-testing, but do not work reliably in LIVE TRADING, where the exit may not occur before the Market Close, leaving you in an overnight position.
6. Ignore7DayTradingWindow: If set to 0 (default) and a 7-day trading day window is either entered in the Inputs, or results from the combining multiple adjacent trading day windows, or when optimizing trading day windows, a Form may pop-up notifying you of this issue, like shown below. The strategy will run and you may see trades appear on the chart, but as soon as the OK button is clicked at the bottom of the Form the strategy will abort. Or you may see a run-time error message appear which causes the strategy to immediately abort. If this input is set to anything other than zero(0), then 7-day trading windows are ignored, as if no trading day window was specified. . Consider using this Input setting when optimizing the Trade Day Window strategy Inputs to avoid the optimization aborting.
Error Checking Inputs
The Trading Day Window strategy inputs are error checked and if an error is detected a run-time error will be issued with an explanatory message, as shown below, and the strategies aborted ( turned off ). You will have to turn the strategies back on and reset the Inputs to clear the error and have the strategies run.
Input errors checked for are:
• Incomplete settings, such as the TradeStartDay Input is set ( to a value greater than or equal to zero(0) ), but the TradeEndDay Input is not set.
• Attempting to set a 7-day trading window by setting the TradeStartDay to Monday ( Sunday for Futures or Forex ) and the TradeEndDay set to Friday, or for a trading day window which spans the weekend, such as from Wednesday through Tuesday. Note that a 7-day trading day window is effectively no trading day window, as trading is allowed on all days.
• Using Weekly or Monthly bars when setting Trading Day windows
• A 7-day trading window emerging when combining adjacent trading day windows or when optimizing the Trade Day Window strategy Inputs.
Trade Day Window Usage Examples
Example 1
Allow trading only on Monday: Do not exit an open position at the end of the day. Entries and exits can occur any time after the first bar of Monday. If there is an open position at the Market Close on Monday, it will remain open.
• TradeStartDay: 1
• TradeEndDay: 1
• AddDaysToOptimizeTradeEndDay: 0
• ExitPositionAtEndOfTradeDayWindow: 0
• ExitPosAtEndOfTradeDayWindowOnBarClose: 0
Example 2
Allow trading only on Monday: Exit an open position at the end of the day. Entries and exits can occur any time after the first bar of Monday. If there is an open position ( long or short ) it will be exited at the open of the last bar of day on Monday.
• TradeStartDay: 1
• TradeEndDay: 1
• AddDaysToOptimizeTradeEndDay: 0
• ExitPositionAtEndOfTradeDayWindow: 1
• ExitPosAtEndOfTradeDayWindowOnBarClose: 0
Example 3
Same as Example 2 above, but exits any open position on the bar Close of the last bar of the day on Monday.
• TradeStartDay: 1
• TradeEndDay: 1
• AddDaysToOptimizeTradeEndDay: 0
• ExitPositionAtEndOfTradeDayWindow: 1
• ExitPosAtEndOfTradeDayWindowOnBarClose: 1: If a "Gap-type" entry/exit strategy is being used which runs on bar Opens, this Input may have to be set to zero(0).
Example 4
Allow trading only on Tuesday and Wednesday: Exit any open position at the open of the last bar of the day on Wednesday.
• TradeStartDay: 2
• TradeEndDay: 3
• AddDaysToOptimizeTradeEndDay: 0
• ExitPositionAtEndOfTradeDayWindow: 1
• ExitPosAtEndOfTradeDayWindowOnBarClose: 0
Example 5
Same as Example 4 above, but exits any open position on the bar Close of the last bar of the day on Wednesday.
• TradeStartDay: 2
• TradeEndDay: 3
• AddDaysToOptimizeTradeEndDay: 0
• ExitPositionAtEndOfTradeDayWindow: 1
• ExitPosAtEndOfTradeDayWindowOnBarClose: 1
Example 6
Allow trading Thursday through Monday ( trade window spans the weekend ): Exit any open position at the open of the last bar of the day on Monday.
• TradeStartDay: 4
• TradeEndDay: 1
• AddDaysToOptimizeTradeEndDay: 0
• ExitPositionAtEndOfTradeDayWindow: 1
• ExitPosAtEndOfTradeDayWindowOnBarClose: 0
Example 7
Trade Thursday through Monday: Exit any open position at the open of the last bar of the day on Monday. If this is a Future or Forex symbol, it will trade on Sunday evening.
• TradeStartDay: 4
• TradeEndDay: 1
• AddDaysToOptimizeTradeEndDay: 0
• ExitPositionAtEndOfTradeDayWindow: 1
• ExitPosAtEndOfTradeDayWindowOnBarClose: 0
Example 8
Allow Futures or Forex trading on Sunday evening: Trade only on Sunday evening. Exit any open position at open of the last bar before midnight.
• TradeStartDay: 0
• TradeEndDay: 0
• AddDaysToOptimizeTradeEndDay: 0
• ExitPositionAtEndOfTradeDayWindow: 1
• ExitPosAtEndOfTradeDayWindowOnBarClose: 0
Example 9
Allow trading Monday through Thursday. Do NOT exit any open position at Thursday close.
• TradeStartDay: 1
• TradeEndDay: 4
• AddDaysToOptimizeTradeEndDay: 0
• ExitPositionAtEndOfTradeDayWindow: 0
• ExitPosAtEndOfTradeDayWindowOnBarClose: 0
Example 10
Optimize the trading day window to start on Monday and increase in 1 day steps until Thursday ( a duration of 4 days ).
• TradeStartDay: 1
• TradeEndDay: -1 ( turn off so NO conflict with AddDaysToOptimizeTradeEndDay )
• AddDaysToOptimizeTradeEndDay: Optimize Start / End / Increment: 1 / 4 / 1. Note the starting value of 1 for the trading day window to start and end with Monday. Think of this value as being the trading window duration in days. So you cannot have a duration of 0 days. If you want to trade for only 1 day, then the duration is 1.
• ExitPositionAtEndOfTradeDayWindow: 0
• ExitPosAtEndOfTradeDayWindowOnBarClose: 0
Example 11
Turn off this strategy so it has no impact on trading by setting the Trade Start and End Day to -1
• TradeStartDay: -1
• TradeEndDay: -1
• AddDaysToOptimizeTradeEndDay: 0
• ExitPositionAtEndOfTradeDayWindow: 0
• ExitPosAtEndOfTradeDayWindowOnBarClose: 0
TRADE MONTH WINDOW Detailed Instructions on Use and Examples
General
The Trade Month Window strategy can be used in back-testing, optimization, and live-trading. The Trade Month Window strategy can be used on an unlimited number of trading charts at the same time.
The Trade Month Window strategy does not make entries - it only exits. It works alongside entry/exit strategies inserted on the same chart: Built-in, custom, or even "Black Box" strategies, such as TradingApp Store strategies you subscribe to, where you cannot see the source code.
The Trade Month Window strategy exits at the end of the trading month window either at the bar Close or at the open of the first bar after the end day of the trading month window. It does not exit within the bar. The Trade Month Window strategy is designed for use on intraday minute-based bars, Daily, Weekly or Monthly bars.
When defining trading month windows, you can specify windows which span the year end. For example, you could define the trading month window to begin on October and end on February. Also when defining trading month windows, you can specify the same start and end month, like February. This means that trading will only be limited to this single month.
Look ahead algorithms are used to enter at the beginning of months for trading month windows and to account for US Market Holidays when possible. TradeStation does not allow you to directly look ahead ( when strategies are typically running on bar Closes ) to see the next bar Date and Time, so rather exotic coding logic is required to look ahead, depending on the bar type and bar interval. For example, if using Monthly bars with a trading month window set from January through February, you will see entry at the beginning of the January Monthly bar, and exit at the close of the February Monthly bar, or at the open of the March Monthly bar, depending on the settings of the ExitPositionAtEndOfTradeMonthWindow and ExitPosAtEndOfTradeMonthWindowOnBarClose Inputs. Look ahead is generally reliable, but there may be some scenarios where it does not work perfectly.
Creating Multiple Trading Month Windows
You can insert the Trade Month Window strategy repeatedly on a chart to create multiple trading month windows. For example, you could insert it twice to set January and March as separate trading month windows. In this scenario trading would be allowed during January and March, and prevented during the rest of the months. However, if you set the trading month windows to January and February, the adjacent trading month windows would be combined or “consolidated” into a single trading month window from January through February. In this scenario trading would be allowed on January and February, and prevented from March through December. Likewise, any adjacent trading month windows will be combined into a single trading month window. For example, if you inserted the Trade Month Window strategy twice on the chart and set one trading month window from January through March and the second trading month window from April through July, then a single combined trading month window from January through July would be created. Note that January and December are considered as adjacent months. So if the first trading month window was December and the second trading month window was January, the two trading month windows would be combined into a single trading month window, from December through January.
When a trading month window spans multiple months, you can carry overnight positions within the trading month window. For example, if you set the trading month window to be from January to January ( a single month ), you can carry overnight positions until the last day of the Month. On the last day of the month, any open position could be exited at the end of the month. If you do NOT want overnight positions, you need to use Daily or intraday bars and the ExitTimeOfDay or ExitAtMarketClose strategy in combination with the Trade Month Window strategy.
If you create a single trading window which spans the entire year, or multiple adjacent trading month windows which when combined span the entire year, such as starting on January and ending on December, or starting on July and ending on June ( spanning the year-end ) then effectively there is no trading month window, as trading is allowed for all months of the week. This may happen when optimizing the Trade Month Window strategy Inputs, or when using multiple trading month windows. Depending on the setting for the Ignore12MonthTradingWindow Input, this scenario will either be ignored or a run-time error will be thrown and the strategy aborted. This is further explained in the Inputs section.
Cautions/Limitations
5. This strategy is designed for use on time-based bars: Intraday minute-based, Daily, Weekly or Monthly bar charts: Such as 5-minute bars, Daily bars, etc. Use of any other bar types may case strange or incorrect results. Using second-based bars may also cause issues, especially if the second-based bars do not divide evenly into a 1-minute bar. For example, 13-second bars do not divide evenly into a 1-minute bar.
6. Do not use this strategy to exit at the Market Close in Live Trading: This strategy can exit exactly at the Market Close on the last day of the last month in the trading month window in historical Back-testing. However, to reliably exit at the Market Close in Live Trading requires using the companion ExitAtMarketClose or ExitTimeOfDay strategy. See Example 3.
7. Limit of 7 Month windows: To create multiple trading month windows this strategy must be inserted on the chart repeatedly for each unique trading month window required. This strategy is limited to being inserted 7 times on a chart. In other words, you are limited to defining no more than 7 trading month windows. Since adjacent trading month windows are combined as explained on the prior page, you cannot define more than six(6) non-adjacent trading day windows.
8. Exiting on the bar Close for Gap-type strategies: If the ExitOnBarClose Input is set to something other than zero(0), then it will exit at the bar Close price at the end of the trade month window. This option may not work when using "Gap-type" strategies which run on bar Opens, causing run-time errors to be thrown and the strategies turned off.
Inputs
The Trade Month Window strategy has six(6) Inputs which:
• Are numerical so they can be used in an optimization
• Allows easily defining a trading window start / end months, and optimize the start and end months
• Work for trading Month windows which span the year end
• Intelligently combine overlapping trading Month windows when the strategy is repeatedly inserted on the chart to create multiple trading Month windows
• Allows you to optionally exit an open position when the end day of the trading Month window is hit
• Allows you to precisely exit at the bar Close at the end of the trading Month window, or exit at the following bar Open.
• Can ignore when a 12-month trading month window is created or issue a run-time error and abort the strategy.
The Inputs are:
1. TradeStartMonth: Specify when the trading month window starts: The first month when entries may first occur. Setting this to zero(0) or a negative value turns this strategy off. January = 1 and December = 12.
2. TradeEndMonth: Specify when the trading month window ends: The last month when trading may occur.
3. AddMonthsToOptimizeTradeEndMonth: This value is added to the TradeStartMonth value to set a trade window end month. This input is typically used to optimize the TradeEndMonth. To optimize the TradeEndMonth, turn it off by setting its value to -1. Then optimize this Input. For example, to optimize the Trading Window End Month from March to July in steps of 1 month with the TradeStartMonth set to March, set the TradeEndMonth to -1 ( turn it off ) and set the AddMonthsToOptimizeTradeEndMonth Start / End / Increment Optimization values of 1 / 4 / 1. Use only positive values. Setting this to zero(0) turns this off. The minimum value = 1 and the maximum value = 12.
4. ExitPositionAtEndOfTradeMonthWindow: If set to something other than zero(0), closes out any open position at the end of the trading month window. For Intraday minute-based bars, any open position ( Long or Short ) is exited on the open of the last bar of the last day of the trading month window. For Daily bars, an open position is exited at the open of the first day of the new month beyond the trading month window.
5. ExitPosAtEndOfTradeMonthWindowOnBarClose: If set to zero(0) exits at the open of the first bar following the monthly trade window. If set to something other than zero(0), then it will exit at the bar Close on the last bar of the monthly trade window. This option may not work when using "Gap-type" strategies which run on bar Opens. For example, if the trade month window ends on March and Daily bars are being used, if this value is set to zero(0) the exit will occur at the open of the first Daily bar in April. If this value is set to one(1) the exit will occur at the bar Closing price on the last March Daily bar ( at the Market Close ). Note that exits which occur exactly at the Market Close work fine in historical Back-testing, but do not work reliably in LIVE TRADING, where the exit may not occur before the Market Close, leaving you in an overnight position.
6. Ignore12MonthTradingWindow: If set to 0 (default) and a 12-month trading month window is either entered in the Inputs, or results from the combining multiple adjacent trading month windows, or when optimizing trading month windows, a Form may pop-up notifying you of this issue, like shown below. The strategy will run and you may see trades appear on the chart, but as soon as the OK button is clicked at the bottom of the Form the strategy will abort. Or you may see a run-time error message appear which causes the strategy to immediately abort. If this input is set to anything other than zero(0), then 12-month trading windows are ignored, as if no trading month window was specified. Consider using this Input setting when optimizing the Trade Month Window strategy Inputs to avoid the optimization aborting.
Error Checking Inputs
The Trading Month Window strategy inputs are error checked and if an error is detected a run-time error will be issued with an explanatory message, as shown below, and the strategies aborted ( turned off ). You will have to turn the strategies back on and reset the Inputs to clear the error and have the strategies run.
Input errors checked for are:
• Incomplete settings, such as the TradeStartMonth Input is set ( to a value greater than 0 ), but the TradeEndMonth Input is not set.
• Attempting to set a 12-month trading window by setting the TradeStartMonth to January and the TradeEndMonth set to December, or a trading month window which spans the year end, such as the TradeStartMonth to April and the TradeEndMonth to March ( spanning the year end ). Note that a 12-month trading month window is effectively no trading month window, as trading is allowed on all months.
• A 12-month trading window emerging when combining adjacent trading month windows or when optimizing the Trade Month Window strategy Inputs.
Trade Month Window Usage Examples
Example 1
Trade only during January. Do not exit an open position at the end of January.
• TradeStartMonth: 1
• TradeEndMonth: 1
• AddMonthsToOptimizeTradeEndMonth: 0
• ExitPositionAtEndOfTradeMonthWindow: 0
• ExitPosAtEndOfTradeMonthWindowOnBarClose: 0
Example 2
Trade only during January. Exit any open position at the end of January at the bar open of the first bar in February
• TradeStartMonth: 1
• TradeEndMonth: 1
• AddMonthsToOptimizeTradeEndMonth: 0
• ExitPositionAtEndOfTradeMonthWindow: 1
• ExitPosAtEndOfTradeMonthWindowOnBarClose: 0
Example 3
Same as Example 2 above, but exit at the bar Close of the last bar in January.
• TradeStartMonth: 1
• TradeEndMonth: 1
• AddMonthsToOptimizeTradeEndMonth: 0
• ExitPositionAtEndOfTradeMonthWindow: 1
• ExitPosAtEndOfTradeMonthWindowOnBarClose: 1: If a "Gap-type" entry/exit strategy is being used which runs on bar Opens, this Input may have to be set to zero(0).
Example 4
Trade only during February and March. Exit any open position at the end of March.
• TradeStartMonth: 2
• TradeEndMonth: 3
• AddMonthsToOptimizeTradeEndMonth: 0
• ExitPositionAtEndOfTradeMonthWindow: 1
• ExitPosAtEndOfTradeMonthWindowOnBarClose: 0
Example 5
Trade only from November through February ( crosses a year boundary ). Exit any open position at the end of February.
• TradeStartMonth: 11
• TradeEndMonth: 2
• AddMonthsToOptimizeTradeEndMonth: 0
• ExitPositionAtEndOfTradeMonthWindow: 1
• ExitPosAtEndOfTradeMonthWindowOnBarClose: 0
Example 6
Strategy inserted twice on chart with 2 trade month windows from March through April and July through October.
Settings for first Strategy: Trade Month Window from March through April with exit at end of April:
• TradeStartMonth: 3
• TradeEndMonth: 4
• AddMonthsToOptimizeTradeEndMonth: 0
• ExitPositionAtEndOfTradeMonthWindow: 1
• ExitPosAtEndOfTradeMonthWindowOnBarClose: 0
Settings for second Strategy: Trade Month Window from July through October with exit at end of October:
• TradeStartMonth: 7
• TradeEndMonth: 10
• AddMonthsToOptimizeTradeEndMonth: 0
• ExitPositionAtEndOfTradeMonthWindow: 1
• ExitPosAtEndOfTradeMonthWindowOnBarClose: 0
Example 7
Optimize the trading month window to start on October and increase in 1 month steps until March ( a duration of 6 months ) of the following year.
• TradeStartMonth: 10
• TradeEndMonth: -1 ( turn this off so NO conflict with AddMonthsToOptimizeTradeEndMonth )
• AddMonthsToOptimizeTradeEndMonth: Optimization Start / End / Increment: 1 / 6 / 1. Note the starting value of 1 for the trading month window to start and end with October. Think of this value as being the trading window duration in months. So you cannot have a duration of 0 months. If you want to trade for only 1 month, then the duration is 1.
• ExitPositionAtEndOfTradeMonthWindow: 0
• ExitPosAtEndOfTradeMonthWindowOnBarClose: 0
Example 8
Turn off this strategy so it has no impact on trading by setting the Trade Start Month to 0.
• TradeStartMonth: 0
• TradeEndMonth: 0
• AddMonthsToOptimizeTradeEndMonth: 0
• ExitPositionAtEndOfTradeMonthWindow: 0
• ExitPosAtEndOfTradeMonthWindowOnBarClose: 0
TRADE WHEN TRUE Detailed Instructions on Use and Examples
General
The Trade When True strategy offers the unique capability of controlling when automated entry/exit strategies trade based on a user-specified True/False condition, WITHOUT requiring code changes to the entry/exit strategies. The user-specified True/False condition is a single line EasyLanguage True/False statement, which offers almost unlimited capability in terms of defining conditions under which trading may occur.
The Trade When True strategy can optionally exit any open position, Long or Short, when the user-specified True/False condition changes from True to False.
The Trade When True strategy can be used in back-testing, optimization, and live-trading. The Trade When True strategy can be used on an unlimited number of trading charts at the same time.
The Trade When True strategy does not make entries - it only exits. It works alongside entry/exit strategies inserted on the same chart: Built-in, custom, protected and "Black Box" strategies, such as TradingApp Store strategies you subscribe to, where you cannot see the source code.
Creating Multiple Trade When True Conditions
The Start and Stop Trading strategy can be inserted up to 10 times on a chart with unique Trade When True conditions for each time it is inserted, and all the Trade When True conditions are combined. This allows one to define 10 separate sets of rules that are ANDED together. This means that when all the rules return True at the same time, trading is allowed. But if any single rule returns False, then trading is not allowed.
Inputs
The Trade When True strategy has only four(4) user-friendly Inputs which are described below. Detailed Usage Examples are provided on the next page to further explain their operation.
4. TradeWhenConditionIsTrue: This is a single line EasyLanguage True/False statement. The statement can be as simple as just the word TRUE or FALSE, or it can be a lengthy EasyLanguage Statement which uses built-in or custom functions, like: Time >= 1200 and Time <= 1500 and EntriesToday( Date ) < 3 and Average( Close, 10 ) < XAverage( Low, 5 ) and MyCustomFunction > 10. For long EasyLanguage statements that are longer than display you can type them in, or create them in a separate document and copy and paste them in place. You can use your left and right arrow keys to move along a lengthy EasyLanguage statement that is too long to fully display.
If you enter an invalid EasyLanguage statement, a small window will pop-up saying this is an Invalid expression, as shown below. You will then need to re-enter a valid EasyLanguage statement.
Any valid single line EasyLanguage True/False Statement is acceptable. What can be done in a single line EasyLanguage statement can be amazing, and may be mostly limited by your imagination or knowledge of EasyLanguage. And if you want to enter a True/False condition which cannot be calculated in a single line statement, you can create ( or have created for you ) a custom Function which returns True/False values.
5. ExitPositionWhenTradeConditionIsFalse: When set to zero(0) any open position is left open when the TradeWhenConditionIsTrue shifts from True to False. When set to any non-zero value any open position is immediately with a Market order at the next bar Open.
6. ExitPosOnBarCloseWhenTradeConditionIsFalse: When set to zero(0) this is disabled. When set to a non-zero value this is enabled, causing an exit to occur at the current bar Close, rather than at the Open of the next bar. Note this only causes an exit to occur at the bar Close if ExitPositionWhenTradeConditionIsFalse is set to a non-zero value to cause an exit. This is provided for use with most price-based bars where exit at the bar Close is recommended for accurate back-testing, such as for Range, Momentum, Renko, Kase, Kagi, 3-Line Break and Point & Figure bars.
7. OnLineHelp: If set to True, displays this User Manual ( this information ) ins a separate browser window that can be moved and enlarged.
Usage Examples
Example 1
The TradeWhenConditionIsTrue is set to “TRUE”. This results in NO change to the strategy trades because the condition is always true. Note the other Inputs have no impact for this scenario.
• TradeWhenConditionIsTrue: True
• ExitPositionWhenTradeConditionIsFalse: 0 ( Disabled )
• ExitPosOnBarCloseWhenTradeConditionIsFalse: 0 ( Disabled )
Example 2
Same as Example 1, except TradeWhenConditionIsTrue is set to “FALSE”. This results in ALL strategy trades being blocked - NO strategy trades will be seen because the condition is always false. Note the other Inputs have no impact for this scenario.
• TradeWhenConditionIsTrue: False
• ExitPositionWhenTradeConditionIsFalse: 0 ( Disabled )
• ExitPosOnBarCloseWhenTradeConditionIsFalse: 0 ( Disabled )
Example 3
The TradeWhenConditionIsTrue is set to “Time >= 1200 and Time <= 1500”. This is an EasyLanguage statement which returns the True value only when the chart Time is 1200 ( Noon ) or greater and when the chart Time is 1500 ( 3 PM ) or less. In other words, a True value is only returned when the chart Time is between Noon and 3 PM. For all remaining times a False value is returned. This results in strategy entries only being allowed from Noon until the 3 PM bar. Because ExitPositionWhenTradeConditionIsFalse is set to zero(0), any open position at 3:00 PM will not be exited then. The position will remain open until the strategy exits it.
• TradeWhenConditionIsTrue: Time >= 1200 and Time <= 1500
• ExitPositionWhenTradeConditionIsFalse: 0 ( Disabled )
• ExitPosOnBarCloseWhenTradeConditionIsFalse: 0 ( Disabled )
Example 4
Same as Example 3, except ExitPositionWhenTradeConditionIsFalse is set to 1 ( Enabled ). This causes any open position at 3:00 PM to be immediately exited with a Market order at following bar Open.
• TradeWhenConditionIsTrue: Time >= 1200 and Time <= 1500
• ExitPositionWhenTradeConditionIsFalse: 1 ( Enabled )
• ExitPosOnBarCloseWhenTradeConditionIsFalse: 0 ( Disabled )
Example 5
Same as Example 4, except ExitPosOnBarCloseWhenTradeConditionIsFalse is set to 1 ( Enabled ). This causes any open position at 3:00 PM to be immediately exited at the 3 PM bar Close.
• TradeWhenConditionIsTrue: Time >= 1200 and Time <= 1500
• ExitPositionWhenTradeConditionIsFalse: 1 ( Enabled )
• ExitPosOnBarCloseWhenTradeConditionIsFalse: 1 ( Enabled )
Example 6
Same as Example 5, except ExitPositionWhenTradeConditionIsFalse is set to 0 ( Disabled ). Because ExitPositionWhenTradeConditionIsFalse is set to zero(0), any open position at 3:00 PM will not be exited then, even though ExitPosOnBarCloseWhenTradeConditionIsFalse is set to 1 ( Enabled ). So ExitPosOnBarCloseWhenTradeConditionIsFalse has NO effect unless ExitPositionWhenTradeConditionIsFalse is Enabled.
• TradeWhenConditionIsTrue: Time >= 1200 and Time <= 1500
• ExitPositionWhenTradeConditionIsFalse: 0 ( Disabled )
• ExitPosOnBarCloseWhenTradeConditionIsFalse: 1 ( Enabled )
Example 7
The TradeWhenConditionIsTrue is set to “Average( Close, 9 ) > XAverage( Close, 18 )”. This is an EasyLanguage statement which returns the True value only when the 9 bar simple moving average, calculated using the built-in Simple Average function: Average( Close, 9 ), is above the 18 bar exponential moving average, calculated using the built-in Exponential Average function:
XAverage( Close, 18 ). Because ExitPositionWhenTradeConditionIsFalse is set to 1 ( Enabled ) any open position at 3:00 PM will be exited at the following bar Open with a Market order.
• TradeWhenConditionIsTrue: Average( Close, 9 ) > XAverage( Close, 18 )
• ExitPositionWhenTradeConditionIsFalse: 1 ( Enabled )
• ExitPosOnBarCloseWhenTradeConditionIsFalse: 0 ( Disabled )
Example EasyLanguage True/False statements
• Time >= 1200 and Time <= 1500 and EntriesToday( Date ) < 3 and Average( Close, 10 ) < XAverage( Low, 5 ): Returns True when the chart time is between Noon and 3 PM and when the number of entries today is less than 3 and when a simple 10-bar average of bar Close values is less than a 5-bar exponential average of bar Lows.
• FastK( 14 ) > FastD( 12 ) and ADX( 20 ) > 30: Returns True when a 14-bar Stochastic Fast K is above a 12-bar Stochastic FastD and the ADX is above 30.
Example EasyLanguage True/False statements: Continued
• MarketPosition = 1 and OpenPositionProfit + 100 >= MaxPositionProfit and OpenPositionProfit > 200 and BarsSinceEntry >= 3 and Close > Close[1] and High = DailyHigh: Returns True when in a Long position and the current open position profit at the current bar Close + 100 is greater than or equal to the maximum position profit for this trade and the open position profit is greater than 200 and it has been at least 3 bars since entry occurred and the current bar Close is greater than the Close of 1 bar ago and the current bar High is equal to the highest high of this day.
• CountIf( Close > Open, 5 ) >= 4 and Close > Open: Returns True when 4 out of the last bars have closed above the open ( up bars ) and the current bar Close is greater than the Open ( up bar ).
• ( ( Average( High, 10 ) - Low ) / Low ) * 100 > 1.5: Returns True when the 10-bar High average is 1.5% above the current bar Low.
Trouble Shooting
Problem: When I turn on the Start and Stop Trading strategy I see a window pop-up as shown below, explaining that I must move this strategy to the TOP of the Strategy List.
Cause: The Start and Stop Trading strategy must be at the TOP OF THE LIST of the strategies shown on the Strategies Tab of the Format Analysis Techniques & Strategies Window.
Solution: To move the strategy to the top of the strategy list:
1. Right click on an open area of the chart. A drop-down menu will appear.
2. Left click on Format Strategies and the Format Analysis Techniques & Strategies Window will open displaying the strategies
3. Left click on this strategy - it will highlight in blue, as shown below:
4. Repeatedly left click on the Move Up Button on the right side to move the strategy to the top of the list, as shown below:
If the Start and Stop Trading strategy is inserted on the chart alongside other companion strategies, like the Start and Stop Trading strategy, both need to be at the top of the strategy list above the entry/exit strategies. It is NOT important whether the Start and Stop Trading or Start and Stop Trading strategy are first or second on the list.
This is covered in the Emerald Trading Technologies YouTube Channel video.
CONTACT US
If there are enhancements or issues you would like to discuss please email us at
This email address is being protected from spambots. You need JavaScript enabled to view it. or call us at 567-455-6389.
DISCLAIMER
Neither TradeStation Technologies nor any of its affiliates has reviewed, certified, endorsed, approved, disapproved or recommended, and neither does or will review, certify, endorse, approve, disapprove, or recommend any product that offers training, education or consulting regarding the use of EasyLanguage.
Emerald Trading Technologies, Inc., its employees, affiliates and agents (EMERALD) are NOT soliciting or offering securities, security derivatives, investment products/services or trading/investment advice. Investment in securities involves substantial risks and should not be undertaken without understanding all the risks related to the sale and purchase of securities. You have sole responsibility for determining the appropriateness of, when and on what terms to engage in any trading transactions. When investing in securities, YOU CAN LOSE MONEY, INCLUDING MORE THAN YOUR PRINCIPAL.
The software described herein is designed to be a tool to assist you trading. THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EMERALD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; FINANCIAL OR NON-FINANCIAL LOSSES, OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS software, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Without limiting the foregoing, EMERALD makes no warranty that 1) the software will meet your requirements, 2) the software will be uninterrupted, timely, secure or error-free, 3) the results that may be obtained from the use of the software will be effective, accurate or reliable, 4) the quality of the software will meet your expectations, and 5) any errors in the software will be corrected. This software and its documentation could include technical or other mistakes, inaccuracies or typographical errors.
EMERALD may make changes to the software or documentation without notice. The documentation may be out of date and EMERALD makes no commitment to update such materials. EMERALD assumes no responsibility for errors or omissions in the software or documentation. In no event shall EMERALD be liable to you or any third parties for any special, punitive, incidental, indirect or consequential damages of any kind, or any damages whatsoever, including, without limitation, those resulting from loss of use, data or profits, financial or non-financial losses, whether or not EMERALD has been advised of the possibility of such damages, and on any theory of liability, arising out of or in connection with the use of this software. The use of this software is done at your own discretion and risk and with agreement that you will be solely responsible for any damage to your computer system or loss of data that results from such activities. No advice or information, whether oral or written, obtained by you from EMERALD shall create any warranty for this software.
The Start and Stop Trading strategy offers the unique capability of preventing automated entry/exit strategies from trading when some condition is met, WITHOUT requiring code changes to the entry/exit strategies. WITHOUT requiring code changes means the Trade When True strategy can also be used with “Black Box”, protected, or TradingApp store strategies, where you cannot see or directly access the strategy code.
The Start and Stop Trading strategy exits any open position, Long or Short, and prevents trades after the exit condition is met.
The Start and Stop Trading strategy is all the companion “ForAllStrategies” strategies, listed below, combined into a single strategy to provide a volume discount.
Companion Strategies: The Start and Stop Trading strategy combines together all the "For All Strategies" strategies, listed in the table below, into a single strategy. It also works in combination with any of its companion "For All Strategies" strategies.
DAILY PROFIT TARGET Exit at specified profit target and prevent re-entry
DAILY STOP LOSS Exit at specified stop loss and prevent re-entry
TRADE TIME WINDOW Limit trading to specified intraday time windows
TRADE DAY WINDOW Limit trading to specific days of week
TRADE MONTH WINDOW Limit trading to specific months
EXIT TIME OF DAY Exit at specified time and prevent re-entry
EXIT AT MARKET CLOSE Exit near Market Close and prevent re-entry
TRADE WHEN TRUE Allow trading when an EasyLanguage True/False statement is TRUE
START AND STOP TRADING All strategies above combined into one
- Have you written a strategy which you would like to quickly modify and explore?
- Maybe the strategy is a TradeStation TradingApp® Store Strategy and even if you could alter it, you don’t have access to the code?
- Do you want to avoid paying a developer and sharing your idea with them?
TradeWhenTrue and one line of code in EasyLanguage
® may be all you need!