TTM SQUEEZE ANALYTICSanalyticsfortraders.com/wp-content/.../2016/01/ttm...TTM_Squeeze retain...

13
TTM SQUEEZE ANALYTICS DOCUMENTATION

Transcript of TTM SQUEEZE ANALYTICSanalyticsfortraders.com/wp-content/.../2016/01/ttm...TTM_Squeeze retain...

  • TTM SQUEEZE ANALYTICS

    DOCUMENTATION

  • www.analyticsfortraders.com | Table of Contents 2

    TABLE OF CONTENTS

    Introduction ........................................................................................................... 3

    Import .................................................................................................................... 4

    Configuration ......................................................................................................... 5

    Trade Visualization & Metrics ............................................................................. 6

    PnL Visualization & Metrics ................................................................................. 7

    Trade Size Visualization & Metrics....................................................................... 8

    Legend ................................................................................................................... 9

    Input Parameters ................................................................................................. 10

    Legal .................................................................................................................... 13

  • www.analyticsfortraders.com | Introduction 3

    INTRODUCTION

    This documentation covers importing, configuration, and usage of the TTM Squeeze Analytics package. The

    relevant information pertaining to the platform, version, and date of this documentation are as follows:

    Platform: thinkorswim®

    Build: 1880.16

    Date: 12/30/2015

    You can download and install the thinkorswim® platform for FREE here:

    https://www.thinkorswim.com/t/trading.html?webpage=clientApplication&displayFormat=hide

    or

    https://www.tdameritrade.com/tools-and-platforms/thinkorswim/features.page

    The TTM Squeeze Analytics package provides the following functionality:

    Trade visualization

    Entry, Target, Stop Loss, and Exit

    Dynamic Backtesting via Date Range Specification

    Value at Risk, Current Trailing Stop, Current PnL, and Average Trade Duration

    Net PnL, Transaction Cost, Win/Loss Probability, and Reward/Risk

    Maximum Gain and Average Gain

    Maximum Loss and Average Loss

    Expected Value per Trade

    Sizing Configurability

    Risk Management Modeling

    Trailing Stop Configurability

    Information on the TTM Squeeze indicator itself can be found here:

    http://tlc.thinkorswim.com/center/charting/studies/studies-library/T-U/TTM-Squeeze.html

    https://www.thinkorswim.com/t/trading.html?webpage=clientApplication&displayFormat=hidehttps://www.tdameritrade.com/tools-and-platforms/thinkorswim/features.pagehttp://tlc.thinkorswim.com/center/charting/studies/studies-library/T-U/TTM-Squeeze.html

  • www.analyticsfortraders.com | Import 4

    IMPORT

    To import the associated source code into thinkorswim®, from within the platform open the EDIT STUDIES AND

    STRATEGIES window (either via the right-click menu or the hotkey combination CTRL+E) and select IMPORT:

    Locate the source code in the directory in which it resides, and select OPEN:

  • www.analyticsfortraders.com | Configuration 5

    CONFIGURATION

    There are a variety of configurations that can be implemented; the standard implementation is demonstrated in

    the image below:

    This implementation maps three instances of the package fl_ttm_squeeze_analytics and one instance of the study

    TTM_Squeeze to the following chart areas:

  • www.analyticsfortraders.com | Configuration 6

    Because all of the analytics functionality resides within a single program, it is necessary to configure the displayed

    outputs/plots in each of the instances so that the desired visualizations and metrics appear in each corresponding

    chart area. It is also important to ensure that the input parameter values are consistent across instances; a change

    in one instance does not automatically propagate through to the other instances.

    TRADE VISUALIZATION & METRICS

    To configure the PRICE chart area (which will contain trade visualization and metrics) select EDIT PROPERTIES via

    the icon or the right-click menu:

    Toggle i_print_general_labels to YES and enable the SHOW PLOT checkbox for the highlighted plots while disabling

    this property for the remaining plots:

  • www.analyticsfortraders.com | Configuration 7

    PNL VISUALIZATION & METRICS

    To configure the LOWER chart area which will contain PnL visualization and metrics, select EDIT PROPERTIES via

    the icon or the right-click menu:

    Toggle i_print_pnl_labels to YES and enable the SHOW PLOT checkbox for the highlighted plots while disabling this

    property for the remaining plots:

  • www.analyticsfortraders.com | Configuration 8

    TRADE SIZE VISUALIZATION & METRICS

    To configure the LOWER chart area which will contain Sizing visualization and metrics, select EDIT PROPERTIES via

    the icon or the right-click menu:

    Toggle i_print_sizing_labels to YES and enable the SHOW PLOT checkbox for the highlighted plots while disabling

    this property for the remaining plots:

  • www.analyticsfortraders.com | Legend 9

    LEGEND

    The graphic below illustrates the meanings of the various lines and markings used for trade visualization:

  • www.analyticsfortraders.com | Input Parameters 10

    INPUT PARAMETERS

    Context help for all input parameters is available within the platform by clicking the question mark to the right of

    an input as shown below:

    The following table provides an overview of all of the input parameters:

    INPUT PARAMETER CONTEXT HELP

    i_product Toggles whether working with FUTURES or EQUITIES in order to appropriately handle trading cost and margin requirements.

    i_start_date Sets the date for which to initialize active trading (in YYYYMMDD format. Must be a valid date on the chart space, not a weekend or holiday. Set-ups will still be visualized and plotted prior to this date, but the sizing variable will default to 0, resulting in no simulated trades. TO TEST FULL CHART LEAVE AT DEFAULT VALUE: 19000101

    i_end_date Sets the date for which to stop active trading (in YYYYMMDD format. Must be a valid date on the chart space, not a weekend or holiday. Set-ups will still be visualized and plotted after this date, but the sizing variable will default to 0, resulting in no simulated trades. TO TEST FULL CHART LEAVE AT DEFAULT VALUE: 21000101

    i_print_general_labels Toggle general labels.

    i_print_pnl_labels Toggle PnL labels.

    i_print_sizing_lables Toggle sizing labels.

    i_trading_hours Toggle the hours for which to run the system.

    i_trade_discontinuities Toggle whether or not to take trades when price is discontinuous from bar to bar (gaps).

    i_flatten_prior_to_weekend Toggles whether to close trades prior to a weekend or not.

    i_ttm_price Input price for TTM_Squeeze.

    i_ttm_length Input length for TTM_Squeeze.

    i_ttm_nk Input nK for TTM_Squeeze.

    i_ttm_nbb Input nBB for TTM_Squeeze.

    i_ttm_alertline Input alertLine for TTM_Squeeze.

    i_swing_high_low_bars Determines the number of bars making new highs or lows that are required in order to be considered new high/low marks. This is incorporated for use with i_target_type = STRUCTURE and i_stop_type = STRUCTURE.

    i_exit_after_n_bars_if_negative Sets the maximum number of bars to stay in a position prior to flattening (if the PnL is negative for the most recently printed bar).

    i_target_type Target toggle. NONE utilizes TTM_Squeeze to manage exits. STRUCTURE

  • www.analyticsfortraders.com | Input Parameters 11

    utilizes swing highs/lows to manage exits. Signals from TTM_Squeeze retain priority. NOMINAL utilizes a nominal target in TICKS. Signals from TTM_Squeeze retain priority.

    i_target_multiplier For use with i_target_type STRUCTURE. Allows the user to modify the targeted goal by a scalar multiple for a given trade, which by default is the distance between the entry price and the low mark (if long) or the entry price and the high mark (if short).

    i_target_nominal For use with i_target_type NOMINAL. The nominal target in TICKS.

    i_stop_type Stop toggle. NONE utilizes the capital risk inputs to set a stop at liquidating value. STRUCTURE utilizes swing highs/lows to manage exits. Signals from TTM_Squeeze retain priority. NOMINAL utilizes a nominal stop in TICKS. Signals from TTM_Squeeze retain priority.

    i_stop_multiplier For use with i_target_type STRUCTURE. Allows the user to modify the stop for a given trade by a scalar multiple for a given trade, which by default is the low mark (if long) or the high mark (if short).

    i_stop_nominal For use with i_stop_type NOMINAL. The nominal stop in TICKS.

    i_threshold_1 The first level (in % of target terms) at which to enact a stop x.xx% below (again in terms of the target) as specified by the i_trailing_stop_percentage input. For example, if i_threshold_1 = 25% and i_trailing_stop_percentage = 10% then once the price has hit 25% of the target level a stop is enforced should the price retreat back down to the 15% target level (25%-10%=15%). To nullify this input set value to 1.0.

    i_threshold_2 The second level (in % of target terms) at which to enact a stop x.xx% below (again in terms of the target) as specified by the i_trailing_stop_percentage input. The tiered structure of the interim target levels allows for stops to be trailed in step-function style. If i_threshold_1 = 25% and i_threshold_2 = 75% and i_trailing_stop_percentage = 10% then the stop will be adjusted from the 15% target level to the 65% target level once the price hits i_threshold_2. To nullify this input set value to 1.0.

    i_trailing_stop_percentage The percentage (in % of target terms) by which to trail a winning position once it has hit the specified threshold levels. For example, a "25% trailing percentage" waits until the price has hit at least the threshold 1 level and then enforces a protective stop at 25% of the target (i.e. 50%-25%). To nullify this input set value to 0.0.

    i_use_static_trade_size If set to YES then the input for the number of contracts is used to model the trade size for calculation of PnL. If set to NO then the capital, risk tolerance, and margin requirement are used to size up/down positions according to allocable risk.

    i_number_of_contracts The number of contracts to be modeled as traded. For use with i_use_static_trade_size = YES.

    i_max_contracts The maximum number of contracts tradable for a given position. If no max is desired, input high value (i.e. 10,000).

    i_initial_capital For purposes of modeling account growth/decline with dynamic sizing as account value fluctuates.

    i_risk_tolerance The total percentage of capital allocable to risk. For example, if capital = $10,000 and risk tolerance = 5%, then $500 of risk can be taken on a given trade. A risk tolerance of 100% allows for the max number of positions limited by margin requirements.

  • www.analyticsfortraders.com | Input Parameters 12

    i_slippage The amount of slippage AT ENTRY, in TICKS. Exits are assumed to be limit orders.

    i_rt_comm Roundtrip commission cost.

    i_contract_exch_fee Roundtrip exchange fee for the particular contract.

    i_contract_margin_req Margin requirement to apply across the span of the strategy evaluation. If evaluating an equity product, input any value; it will be overwritten by the trade price of the equity automatically.

    A base level of exception handling is incorporated at runtime; however the possibility of errors via the

    misconfiguration of inputs is still possible. Therefore, it is important to ensure that the provided inputs make

    logical as well as contextual sense. If a particular configuration yields an unexpected result or error, check to

    ensure that all inputs are configured appropriately.

    Caught exceptions appear at the upper left hand of the screen. Clicking the encircled “I” will display the associated

    error message. The example below was generated by inputting an initial capital value insufficient to open even a

    single position.

  • www.analyticsfortraders.com | Legal 13

    LEGAL

    The TTM Squeeze Analytics package is protected by:

    Title 17 of the United States Code

    Copyright Act of 1976

    Purchase of TTM Squeeze Analytics is valid for a single-user license.

    Any reproduction and/or distribution without the consent of the publisher is strictly prohibited.