Measuring the Summer Calm With TradeStation’s Custom Functionality
Stocks have enjoyed a calm drift higher since the beginning of May. But just how smooth has the ride been? Today we’ll answer that question using TradeStation’s award-winning platform.
One approach is to measure the amount of time since the S&P 500 last had a significant decline. After all, bearish periods tend to have sharper declines because sellers have more control over the price action.
Let’s begin by asking, “how long has it been since the S&P 500 fell at least 3 percent drop in a single day?” And, “how does it compare with earlier history?
The answer to the first question is that the S&P 500 last had a 3 percent pullback on August 26, 2022, or 453 sessions ago. (Those are trading days, not calendar days.) It’s the longest streak since August 20, 2015, when the index went 949 sessions without a 3 percent pullback. Before that, the longest streak without a 3 percent decline ended on February 26, 2007, after 988 sessions.
From these points data, we might believe that yes, the S&P 500 has gone a relatively “long time” without a “big pullback.” But how did we get this information?
Custom Indicator
The chart above includes a custom indicator called “Bars since X% move,” available for download here. It’s written in TradeStation’s EasyLanguage, which lets customers program a wide range of indicators and strategies (including systems to automate trading).
Traders can import Bars since X% move by double clicking on the “BARS SINCE X MOVE.ELD” file contained in the zip file. It can then be added to charts by clicking Studies → Add Studies… It will use the time interval of the chart. That means it seeks daily moves on daily charts, weekly moves on weekly charts, etc.
By default it looks for positive moves of 5 percent. Users can change this criterion with the Customize Indicator dialog and clicking on the Inputs tab. The threshold input should be changed to “-3” for the analysis performed above. Note: The Color tab can adjust the indicator’s color and the Style tab controls attributes like line thickness.
Using EasyLanguage
Traders can also click the “Edit EasyLanguage” button at the bottom of the same dialog to see the code we’ll now explain.
The first important line is the inputs, which tells TradeStation which values to accept from the user. “(5)” is the default value:
Inputs: threshold(5); // Percentage change threshold as a number, integer or decimal.
It next declares a series of variables. The first stores percentage changes for each bar. The second variable bookmarks when a change of the desired size occurs. The third is used to calculate the period of time between the targeted moves. “(0)” at the end of each variable sets default values of zero:
Vars: pct_cng(0), // Variable to store percentage change of the current bar start_counter(0), // Variable to store the bar number when the desired change occurs output_val(0); // Variable to store the output value (number of bars since the specified change)
The third step is to calculate the percentage change of each bar. Note that close[0] is the closing price of the current bar, while close[1] is the closing price one bar prior.
pct_cng = ((close[0] / close[1]) - 1) * 100;
Coding the Logic
The next section performs the main logic. If the customer is looking for a positive percent move, it looks for a percent move greater than the threshold. For negative thresholds, it seeks moves that are less than the inputted value. When a move of the desired magnitude is detected, it remembers the bar number. (Bars are numbers from older to newer.):
// Handle positive threshold values If threshold > 0 and pct_cng > threshold Then begin start_counter = CurrentBar; end;
// Handle negative threshold values If threshold < 0 and pct_cng < threshold Then begin start_counter = CurrentBar; end;
Returning Data to User
So far, the code looks at each bar to find moves of a certain percent. When such a move is detected, it saves the bar number to the variable start_counter.
The next step is find the distance from that past event to the present time. This next line performs the calculation by finding the simple difference between the saved bar number and the current bar number:
output_val = CurrentBar - start_counter;
Finally, the value is displayed to the user with “Plot.” EasyLanguage can output several values with plot, which is why this code shows “Plot1.” It could also have Plot2, Plot3, etc, if needed:
Plot1(output_val, "Bars since X move");
In conclusion, this indicator uses EasyLanguage to answer a question about the market. It’s one of the many examples of how TradeStation can provide customers with valuable insights. See our educational events for more information and training.
David Russell is Global Head of Market Strategy at TradeStation. Drawing on nearly two decades of experience as a financial journalist and analyst, his background includes equities, emerging markets, fixed-income and derivatives. He previously worked at Bloomberg News, CNBC and E*TRADE Financial.
Russell systematically reviews countless global financial headlines and indicators in search of broad tradable trends that present opportunities repeatedly over time. Customers can expect him to keep them apprised of sector leadership, relative strength and the big stories – especially those overlooked by other commentators. He’s also a big fan of generating leverage with options to limit capital at risk.
Explore Your Next Idea with TradeStation's Trading Simulator https://www.youtube.com/watch?v=Z5QGPHAvanY&ab_channel=TradeStation TradeStation's trading simulator offers a powerful virtual arena for traders to test and refine strategies for stocks, options, and...
https://www.youtube.com/watch?v=4yBLSSrTlmc&list=PLC5ivqitsDCMwr4x_LdBB0wnFXDUYbPiy&index=9&t=97s&ab_channel=TradeStation Create efficient workflows that help you access information and make split-second market decisions with the help of our...
https://www.youtube.com/watch?v=gpLqHiXs6Dc TradeStation is excited to announce new extended trading hours, starting November 11th, 2024, which will allow our clients to access stocks and ETFs starting at 6:00 AM Eastern Time. This early access can help provide you...
Explore the Crossroads Summit
You are leaving TradeStation.com for CrossroadsSummit.com, an exciting new conference that highlights opportunity at the intersection of chaos and innovation. Click the button below to acknowledge that you understand that you are leaving TradeStation.com.
You are leaving TradeStation.com for another company’s website. Click the button below to acknowledge that you understand that you are leaving TradeStation.com.
This event is hosted on YouCanTrade. The information for this event is being provided for informational and educational purposes only.
You are leaving TradeStation Securities and going to YouCanTrade. YouCanTrade is an online media publication service which provides investment educational content, ideas and demonstrations, and does not provide investment or trading advice, research or recommendations. YouCanTrade is not a licensed financial services company or investment adviser and does not offer brokerage services of any kind.
TradeStation Securities, Inc. provides support and training channels hosted on YouCanTrade, its affiliate. Other than these support and training channels, any services offered by YouCanTrade are not sponsored, endorsed, sold or promoted by TradeStation Securities and it makes no representation regarding any YouCanTrade goods or services.
To acknowledge you are leaving TradeStation Securities to go to YouCanTrade, please click