Technical Analysis 101 Session 5 Stan Yabroff Val
Technical Analysis 101: Session 5 Stan Yabroff Val Alekseyev
Session 5 § Creating Conditions § Advanced Conditions § Entry Signal Evaluator § Trade System Optimizer
Creating Conditions Overview • Condition Discovery • Writing Conditions Using the Formula Toolbox • Using Parameters • Marking Charts with Conditions • Setting Condition Alerts • Creating More Complex Conditions • Bars. Since, Set. Rst, and IF Statements • Sample Scenarios
Condition Discovery • Determine the studies to use for your conditions (you can refer to studies documentation and help files). • Apply the studies to a chart. • Mark areas on the chart that are bullish or bearish. • Write out events in a simple language, such as: – Fast moving average crosses above the slow moving average – MACD crosses above/below MACDA line – Slow Stochastic %K crosses above/below %D – Price crosses above/below lower or upper Bollinger Bands®
Condition Discovery Bearish Price Action Bullish Price Action
Writing Conditions Using the Formula Toolbox 1. Click the Formula button. 2. On the Conditions tab, click New…. The Create a New Condition window opens. 3. Type a name for the condition in the provided space and click OK.
Writing Conditions Using the Formula Toolbox 4. Click Toolbox. 5. On the Formulas tab, select Studies, then Stochastics, Slow, and then SSK(10, Smo, 3). 6. Click Insert to add the study into the formula. 7. On the Formula Toolbox, click the Special tab. 8. Click XABOVE, and highlight SSD. 9. Click Insert to add the SSD study into the formula.
Using Parameters allow you to better change values in your conditions.
Inserting Parameters into Studies Selectthe entire 1. • Select entire condition 2. Click the Setup… button. • Left-click Setup 3. • Right-click Right Clickthe onvalues to replace with values them to replace parameters. with Parameters
Marking Charts with Conditions 1. Right-click a bar or candlestick chart and select Select conditions for marking Bar/Candl. The Specify Mark. It Conditions window opens. 2. On the window, select the condition in the list on the left. 3. Click the Include button. 4. On the Conditions and Symbols for Marking field, you may change colors and symbols.
Results of Marking a Chart • • • Select entire condition Left-click Setup Right Click on values to replace with Parameters
Setting Condition Alerts
Creating More Complex Conditions Examine the chart to see what studies may yield a good buying or selling opportunity.
Word Condition in English Stochastic %K crosses above %D and MACD crosses above MACDA.
Creating a Condition Formula: SSK(@, Per 1, Smo, Per 2) XABOVE SSD(@, Per 1, Smo, Per 2, Smo, Per 3) AND MACD(@, 13. 000, 26. 000) XABOVE MACDA(@, 13. 000, 26. 000, 9. 000) These two events may not occur on the same exact bar so Bars. Since should be used.
Bars. Since Function 1. Determine which event occurs first. 2. Select that part of the condition. 3. Select the Bars. Since function, and apply it to the selected text. 4. Determine how many bars are allowed.
Visual Check Mark the chart with your condition to see if it meets your criteria.
Set. Rst Function • The first part of the condition remains true until the second part is satisfied. • This function is useful to mark a range of bars. • The function can be used with the condition and within the condition. Set/Reset creates a picture of binary data using two conditions. The first condition is displayed as an up tick on a line graph. The line continues on that level until the secondition is satisfied. The line then returns to its baseline until the first condition occurs again. On a bar graph, the bars change colors to reflect the set and reset conditions. For example: Set. Reset(MACD(@), 13, 26) XABOVE 0, (MACD(@), 13, 26 -MACDA(@), 13, 26, 9))< (MACD(@), 13, 26 MACDA(@), 13, 26, 9))[-1] In this example, on a bar graph, this formula would color bars when MACD crossed above zero and would stop marking the bars when the difference between the MACD and the MACDA trended down.
Set. Rst Function 1. Create a new condition. 2. Select Set. Rst. 3. Modify the @ symbols with condition 1 and condition 2.
View the Results
IF Statement • Conditional statements can be nested. • If (statement, true, false). – Nested If(statement, true, if (statement, true, false). • This statement can be assigned to variables.
Sample Scenarios • Add studies to a chart and examine buy and sell areas. • Determine if you can define the range with Set. Rst. • Place the events in the order they occur, and offset the first event with Bars. Since. • Choose from endless possibilities.
Advanced Conditions Overview • Creating More Complex Conditions • Using Custom Studies to Troubleshoot Conditions • Examples
Creating More Complex Conditions Develop your idea by examining a chart and creating sentences.
Word Condition in English Buy Side: Stochastic %D goes down and then trends up. The current close is greater than the previous bar’s close.
Creating a Condition These two events may not occur on the same exact bar so you need to evaluate the order they will occur. • Event 1: = Set. Rst(SSD(@, 10, Smo, 3) GOINGDOWN , SSD(@, 10, Smo, 3) TURNSUP ) ; • Event 2: = Bars. Since(Set. Rst(SSD(@, 10, Smo, 3) GOINGDOWN , SSD(@, 10, Smo, 3) TURNSUP ) , 1, 40); • Close(@) > Close(@)[-1] AND Event 2 = 1
Visual Check Mark the chart with your condition to see if it meets your criteria.
Using Custom Studies to Troubleshoot Conditions Create a custom study that includes a separate curve for each line in the condition.
Add a Custom Study to the Chart
Create an Opposite Condition Create a condition with the opposite side of the trade. • Event 1: = Set. Rst(SSD(@, 10, Smo, 3) GOINGUP , SSD(@, 10, Smo, 3) TURNSDOWN ) ; • Event 2: = Bars. Since(Set. Rst(SSD(@, 10, Smo, 3) GOINGUP , SSD(@, 10, Smo, 3) TURNSDOWN ) , 1, 40); • Close(@) < Close(@)[-1] AND Event 2 = 1
Add a Condition
Other Examples • Choose three out of the five studies to trigger a signal to be generated. • Use five variables and assign the trigger condition for each variable. You may then add the variables and use an IF statement. • Create endless possibilities.
Entry Signal Evaluator Overview • Summary • Setting Up the Evaluation • Evaluation Definitions • Signal Evaluator Analysis • Signal Analysis Definitions • Strategy Evaluation
Summary The Signal Evaluator can fine-tune entry timing and turn a previously discarded methodology into a profitable one. Main functions: • A trade system may produce poor results when the entry point timing is wrong. Running the entry through the Signal Evaluator can reveal that the entry should be a set number of bars after a condition. It is usually best to analyze the first five bars, including the opening of the first three bars, to improve the results. • The Signal Evaluator provides clues as to where the most profitable exit is. Code within the trade systems formula toolbox is available, so stops can be tightened after a user-defined number of bars.
Setting Up the Evaluation • To open the Signal Evaluator window, click the Signal Evaluator button or click the More button, and then select Entry. Sig Eval. • When the Signal Evaluator window is open, select all the necessary parameters to run the tool. • When using the Wizard, click the New button on the top-left of the screen, and then enter the commodity symbol. Only one issue can be entered at a time.
Evaluation Definitions The following terminology is from the Signal Evaluator test: • Bar Interval of the Commodity: The time frame of the chart being analyzed. • Bar Type: A condition being tested on an individual contract or on active continuation data (where rollover between expirations is based on volumes). • Rollover Info: A window that is based off of a previous choice. If you have chosen to test individual active contracts, you will be prompted to choose to roll over the open position to the following active contract. If you have selected Active Contract, this menu becomes unavailable. When using some indicators, rolling over can distort results due to the price gap between contracts. It is normally best to not roll over when first testing.
Evaluation Definitions • Start and End Value: The database to test. • Going Long Information: When a long entry position has to be tested, you will need to enter the signal (condition) and set the buy price (user value) at which to open the position. Test results will also have to be calculated on that entry price. The Signal Evaluator is not set to understand that if a long and an opposite sell occur, the long has been closed out, indicating that long and short signals can offset each other. Long and short signals should be entered separately. • Going Short: You will be prompted to select the short signal and the sell price. • Bars Out: This tells the system how far to evaluate the results for that signal, after the signal is true. The Signal Evaluator considers closing the position at each bar and evaluating results.
Signal Evaluator Analysis The Gen tab: • Selected Bar Out: Shows the number of bars. • Show: Displays the results. • Sort Entries By: Displays the results as a percentage or a dollar. From the Signal Evaluator window, you will not be able to see which database and time frame have been defined. To check this info, click the Data button. To better understand the Signal Evaluator results based on the relation of the time frame, commodity, and condition, use a single evaluation (a long entry or a short entry).
Signal Evaluator Analysis The Column tab: Selecting Bar Out in the list will be reflected on the main Signal Evaluator window as a bar tab. This gives the reference interval of the analysis. For short-term signals, select the first ten bars. For mediumperiod signals, select every five bars.
Signal Evaluator Analysis The Sum tab: Select which statistics have to be active.
Signal Evaluator Analysis The Commodity list: View which contracts have been selected. If no contracts have been selected, enter the name of the contract in the Commodity list box.
Signal Evaluator Analysis After setting the evaluation parameters, click Start to begin the evaluation. View results in chart or tabular format. The information includes signal analysis that allows you to capture the best bar out to be adopted and the strategy evaluation.
Signal Analysis Definitions Specific trade analysis will be displayed below the statistics. Click the data to view the trading results. • Sum of 15: The total profit or loss in opening a position (long or short) in the specified database. • Average of 15: The average win or loss per trade. • Average for Wins: The average gained for all profitable trades. • Average for Losses: The average of losses for all unprofitable trades. • Draw Down: The maximum loss during the defined interval. • Consecutive Losses: The maximum sequence of unprofitable trades without a profitable trade. Specific trade analysis will be displayed below the statistics. Click the data to view the trading results.
Signal Analysis Definitions • Wins & Losses: The number of wins and losses of all trades. • Accuracy %: The number of winning trades, as a percentage, of the total number of trades. • All Profits/All Losses: The total gain from the winning trades as a percentage of the total losses from the losing trades. • Avg Win/ Avg Loss: The ratio of the average gain for a winning trade to the average loss for a losing trade. • % Remove to Neutral: The number of trades, as a percentage, that would have to be taken out starting with the most extreme. This is to turn a profitable strategy into a losing one and vice versa. The higher number, the better the strategy. • Avg DD Perf Ratio: The annualized profit and average maximum retracement. • Max DD Perf Ratio: The annualized profit/maximum retracement – profit or profit-maximum retracement from a prior peak and a subsequent low.
Draw Down To access the Draw Down, select Draw Down from the Sum tab. The chart shows the maximum loss you can have for the specified period.
Accuracy% To access Accuracy%, select Accuracy% from the Sum tab. The chart shows the accuracy of trades within a specific trading period. The higher the accuracy, the better the condition for opening a position and closing it after a specific number of bars.
% Remove to Neutral To access %Remove to Neutral, select %Remove to Neutral from the Sum tab. The chart details when better profits are most possible, according to this evaluation.
Strategy Evaluation: Profit Curve To access the Profit Curve, click the Profit Curve tab. This curve details the historical behavior and profit of the strategy based on the exit after nineteen bars.
Strategy Evaluation: Distribution To access the Distribution chart, click the Distribution tab. This chart shows the number of trades (every blue bar of the histogram), the profit of the trade at the 19 th bar (x axis), and the percentage (y axis). The chart displays a Gaussian curve with the barycenter of the curve in the positive percentage of the axis.
Strategy Evaluation: Summary To access the Summary, click the Summary tab or the Sum button. This chart shows the summary of the total profit or loss. The y axis details what would have been the percentage profit if you had closed the position at a specified bar, displayed on the x axis.
Strategy Evaluation: Charts of Trades This chart, reflecting what is also available in the tabular format, shows: • An arrow for the opening of each trade. • A blue line for the entry level or price value. To print the results, right-click the Printer button and select Print Shown entries.
Trade System Optimizer Overview • Summary • Commonly-Viewed Statistics • Statistics Glossary • Opening the TSO • Setting Up the TSO • TSO Setup Window • Trading System Alerts
Summary Test results with optimum sets of user-defined parameter values. Trade System Optimizer (TSO) is a module that tests the results of trading systems running different settings and combinations of parameters included in trade signals. All selected parameter combinations are then evaluated. The results of each combination are reported in the TSO window. TSO allows you to determine which set of user-defined parameter values produced the best result (expressed as the best value for the selected Optimize On statistic). Determine the results on a specific trading system applied to defined historical chart data. TSO works only with trade systems containing user-defined parameters (parms). These parameters are required to test combinations and return optimal values.
Commonly-Viewed Statistics These definitions explain how the TSO results are divided, gauged, and calculated. • Profit to Maximum Drawdown: Divides the end profit figure by the largest open drawdown in the sample. – The Profit to Maximum Drawdown does not take the highest profit point and divide it by the largest drawdown after that point. It is possible that a drawdown ratio could be worse than the figure shown. – A top-quality system that could be sold with results published or reviewed by hedge fund publications would need a ratio above ten, which indicates a maximum drawdown of less than 10% of equity. – You could use ratios above five, indicating a 20% fall. The open drawdown and the draw amount should be compared to the closed draw amount. There should not be a large difference between the two. For most systems, except short-term scalping systems, any difference of more than two times the closed drawdown indicates that the money management and stop-loss rules might be too loose.
Commonly-Viewed Statistics • Maximum Draw Duration: Gauges the tolerance of how long you should continue trading on a particular system. This is often overlooked and should be linked to the Consecutive Losses. In the absence of a very high Percentage Remove to Neutral number (above ten), you must take every trade. Otherwise, signals that consequently prove to be successful could be ignored. • Maximum Consecutive Losses: Calculates losses while being on the highest instance. When using the TSO, the Maximum Consecutive Losses could repeat many times. For example, four consecutive losses could occur on ten separate occasions. • Profit/Loss Ratio: Divides the average wins by losses on intraday, scalping, and shortterm systems. A ratio of over three is necessary to prevent profits from being eaten away by slippage and commission. • Percentage Remove to Neutral: Calculates the percentage of the best trades that would need to be removed to bring you back to a zero profit. This figure needs to be greater than ten on intraday and scalping systems. On historical systems, this figure must be greater than five.
Statistics Glossary The following is a terminology of profits and losses. • Total Net Profit: The cumulative profits and losses of open and closed positions. On a chart, green lines indicate profits and red lines indicate losses. • Closed Net Profit: The total profit on closed trades. • Total Trade Count: The total number of buys and sells. If there are multiple exits to a trade, CQG will treat each exit as a trade. • Open Position: The number of long or short contracts. If the number is zero, the total net profit and the closed net profit will have the same value. • Percent Long: The percentage of the total trades that were long trades. • Average Duration: The average number of bars a trade is open. • Average Profit: The average gain of all trades. • Average Wins: The average of all winning trades. • Maximum Wins: The biggest winning trades. • Average Loss: The average of all losing trades.
Statistics Glossary • Maximum Loss: The biggest losing trade. • Max Closed Draw Down: The maximum loss for any string of losing trades (the worst case of a vertical drop between winners). • Max Draw Amount: The largest accumulated loss in equity at any time. • Max Draw Duration: The longest peak-to-peak interval represented on the profit curve. • Max Consecutive Losses: The largest number of consecutive losing trades. • Profit to Max Draw Down: The total net profit and maximum drawdown amount. The higher the figure, the more desirable the outcome. A negative indicator means a zero profit. • Profit Loss Ratio: The average gain on winning trades and the average loss on losing trades. • Percent Winners: The percentage of profitable trades. • Remove to Neutral: The amount of profitable trades that would have to be removed to equal a zero profit.
Opening the TSO Optimize the TSO when a trade system is applied. When the trade system is applied to a chart, right-click the trade system and then select Optimize.
Setting Up the TSO Specify optimization details and learn the details of a TSO run. When the optimize view is opened from a chart, a new TSO run is created. By default, the run is titled Trade System Optimizer - unknown x, and it is based on information taken from: • The chart (symbol, trade system, time interval, time range, and base expression). • The trade system (user-defined parameters and values). The TSO Setup Window: To specify optimization details, click the Specify button.
TSO Setup Window • You can select, create, copy, or delete a TSO run. • The optimizer runs are listed on the Runs window. • To remove a run from the list, highlight a run and click Delete. • To set up parameters, select the Use boxes on the Trade System Parameters window. You can also adjust chart and data information by clicking the Chart type or Chart parameters from the menus. • To edit the bar range, click the Edit button on the Bar Range window, and then type the range.
TSO Setup Window Optimizer Runs Trade System Parameters Chart Information Data Information Statistics
Trade System Parameters The Trade System Parameters window displays all user-defined parameters associated with the selected trade system. • The Start Value displays the figures that were initially set in the trading system. Select the order to run the parameters on the TSO Setup window. The order is noted on the selected Use field check boxes. • The Start Value and End Value determine the range for testing each parameter to find the best combination versus the statistic value. If the Start Value and the End Value are integer numbers, a step of one indicates the optimizer will test every value between the values. A step of five indicates that the optimizer will check start values with an increment of five until an end value is reached.
Statistics to be Optimized Select a statistic to measure the success of the trade system on the Optimize on drop-down menu. On the TSO Setup window, the default statistic on the Optimize on drop-down menu is Total. Net. Profit. The Optimize on statistic is always the first statistic column displayed in the summary result table. The suggested statistic to choose from the menu is the Profit to Max Draw.
Statistics to be Optimized Test parameters based on the following algorithms: • Exhaustive: Evaluates trading system effectiveness for each possible combination of all parameters. The best-found parameter combination reflects the maximum effectiveness. One disadvantage of this calculation is the high request of resources on the network. Select Exhaustive from the drop-down menu if you are using a narrow range of values for their parameters. • Genetic: Evaluates a subset of every combination of parameters. This algorithm searches the most effective combination, according to biological laws. Results are not guaranteed, but the Genetic algorithm takes less time to run than the Exhaustive algorithm. Choose a wide range of values for their parameters, and then select Genetic from the Algorithm menu.
Chart and Data Information Select an interval from the chart parameters section of this window. The Bar Range determines the period of time you want to use the trade system and optimize it. Click the Edit button, and then select the number of bars or the period from a specified date to the ending date. When applicable, you can also select all of the sessions. Chart types: • Bar • Candlestick • Constant volume bar • Fill gap • No gap • Percent bar • TFlow® • Yield
TSO Results Table Settings Customize the display of TSO run results. The Table tab options include: • Sort By: Sorts results by any of the parameters or statistics. The default Sort By value is the same as the Optimize on selection. • Max Best Results: Limits the number of rows included in the results table. If the set number is lower than the total number of steps, only the best results will be shown. The default is set to 100.
TSO Results Table Settings The Display Chart with drop-down menu options include: • No Update: Does not update the chart with optimization results. The display remains idle while the TSO is running. • Current Value: Displays the chart with the value for a particular row. • Best Value: Updates the chart with the best value (if the value changes). • Best for Refresh: Displays the best value within a series of steps. Best for Refresh updates after a series of additional steps. • After Steps: Determines how often the chart is displayed or updated with the results table data. If No Update is selected, After Steps will be unavailable.
TSO Results Table Settings After setting the parameters on the TSO Setup window and the table settings, click the Setup button. The TSO run results are displayed on the main window.
TSO Results Table Settings View run results in a chart by doubleclicking a cell. The best combination of parameters is shown in the first row. The first row is the current step result, regardless of the table sorting preferences. After the run is completed, the current line is no longer visible. As each step runs, the TSO’s progress is reported on the top section of the window, and rows are added to the table. To view specific run results in a chart, double-click a cell. The trade system graph at the bottom reflects the values on the results table.
Customize TSO Results Order and adjust the parameters and statistic columns. To customize the display by specific columns, right-click the top of one of the columns, and then select Customize Columns….
Customize TSO Results Order and adjust the parameters and statistic columns. From the TSO results table, trades can call a chart with optimized parameters to be applied on the active trading system. To set up a trade system with a preferred combination of parameters, right-click a TSO run row and then select Launch Chart with Parameters.
Saving TSO Results Save results as a. txt file, or copy them as a clipboard. To save your TSO results, click the Setup button, and then select Save Results to TXT File… or Copy All Grid to Clipboard.
Disclaimer Trading and investment carry a high level of risk, and CQG, Inc. does not make any recommendations for buying or selling any financial instruments. We offer educational information on ways to use our sophisticated CQG trading tools, but it is up to our customers and other readers to make their own trading and investment decisions or to consult with a registered investment advisor. © 2012 CQG, Inc. All rights reserved worldwide. CQG®, DOMTrader®, Snap. Trader®, TFlow®, TFOBVO®, TFVOL®, and Data Factory™ are trademarks of CQG, Inc.
Stan Yabroff stan@cqg. com Val Alekseyev valekseyev@cqg. com 1 800 -525 -7082 www. cqg. com
- Slides: 75