Trade When True this is where you put the manual

 

TradeWhenTrue 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. In other words, TradeWhenTrue can also be used with “Black Box”, protected, or TradingApp® 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. TradeWhenTrue can optionally exit any open position, Long or Short, when the user specified True/False condition changes from True to False.

Companion Strategies: TradeWhenTrue works in combination with any of its companion "For All Strategies" apps, which can also be found on the TradingApp® Store, listed below.


The OnLineHelp Input: If set to True, the User Manual for this App 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.

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 Emeralds YouTube Channel

Prerequisites:TradeStation V9.1 Update 24 or later 2

General:TradeWhenTruecan be used in:
  • optimization
  • live-trading.
  • on an unlimited number of trading charts at the same time.
Note: it 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.

Inserting TradeWhenTrue Multiple Times On the Same Chart

TradeWhenTrue can be repeatedly inserted on the same chart, but only the top most TradeWhenTrue strategy will have any impact on the trades.This limitation is changed when using StartAndStop, and including TradeWhenTrue capability along with all the other companion strategy capabilities shown in the table above. StartAndStop can be inserted up to 10 times on a chart with unique TradeWhenTrue conditions for each time it is inserted, and all the TradeWhenTrue 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:

Input Comments: You will notice that many 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 comment text between them, or you can type over the text between the curly braces to create your own comment.



Inputs: Continued

TradeWhenTrue 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.

1. 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.

2. 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.

3. 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 backtesting, such as for Range, Momentum, Renko, Kase, Kagi, 3-Line Break and Point & Figure bars.

4. 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

TheTradeWhenConditionIsTrue 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.
  • 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 TradeWhenTrue, I see a window pop-up similar to that shown below, explaining that I must move this strategy to the TOP of the Strategy List.
Cause: TradeWhenTrue must be at the TOP OF THE LIST of the strategies shown on the Strategies Tab of the Format Analysis Techniques & Strategies Window.
Solution: Move TradeWhenTrueto 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 TradeWhenTrue is inserted on the chart alongside other companion ForAllStrategies Apps, like TradeTimeWindow, both need to be at the top of the strategy list above the entry/exit strategies. It is NOT important whether the TradeWhenTrue or TradeTimeWindow 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 Contact Us 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 errorfree, 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

Print   Email