[lwp_divi_breadcrumbs font_icon=”5||divi||400″ use_custom_home_link=”off” link_color=”#000000″ separator_color=”#000000″ current_text_color=”#FFFFFF” admin_label=”Breadcrumbs” module_class=”insight-breadcrumbs” _builder_version=”4.27.0″ _module_preset=”default” global_colors_info=”{}”][/lwp_divi_breadcrumbs]

Market Insights

Bringing you the trading news around the world.

Finding Stocks That Haven’t Broken Down in 2022: TradeStation Tutorial

[showmodule id=”58959″]

Most stocks have been sliding along with the broader market this year, but a handful of names haven’t broken down. Today we’ll consider ways to find them using TradeStation’s desktop platform.

The basic goal is to find companies closer to their 200-day moving averages than the broader market. This can be achieved with a simple custom indicator written in EasyLanguage.

We’ll first explain how to use the calculations. The results are listed at the bottom of the article if you want to skip to them.

Using RadarScreen

Let’s begin by opening RadarScreen, the versatile analytic tool introduced in our previous article.

  • Go to the Apps bar at the top left and click on the RadarScreen logo.
  • Next import all the members of the S&P 500 by clicking on Data → Add Symbol List → S&P 500.
  • It will likely default to 5-minute candles. Change this by clicking on “Symbol” in the column header to select all symbols. Then click on the Timeframe menu and select “Daily”.

This columns display a series of values including the most recent price, “Last.” Next we can add the 200-day moving average:

  • Clicking on Studies → Add Study. A dialog box will appear.
  • Scroll down the list on the left and select “Mov Avg 1 Line.”
  • Click the “Add ->” button in the middle to move it into your current list. Then click the “OK” button on the bottom right.

A new column called “Mov Avg 1 Line” will appear, which must be customized:

  • Right click on the new column header and select Studies → Edit “Mov Avg 1 Line” for All Symbols…
  • A Customize Indicator dialog box will appear. Chose the “Inputs” tab on the left and change Length to 200.
  • Click OK.
RadarScreen, with custom indicator illustrated in today’s article.

Creating a Custom Indicator

The steps above will let you see stocks’ last prices and their 200-day moving averages. However they don’t let us easily compare the two.

We can accomplish this by creating a simple custom indicator. Start by opening the EasyLanguage editor from the Apps button at the top of the desktop. This will open as a new program on your computer. Then follow these steps:

  • In the File menu select New → Indicator
  • Give it the name “Distance from Mov Avg 1 Line”
  • Click OK.

In the editor box that appears, paste this code:

Inputs: Length (200) ; // Ask user for MA length, defaulting to 200
plot1(Last/AverageFC( Close, Length)-1)  ;  // Show price/MA as a decimal

The comments after “//” explain what each line does. First the “Inputs” line will create an option in the same Customize Indicator dialog box used above to change the moving average length. By including (200) in parenthesis, it will default to a length of 200 candles.

The second line does most of the work. Here are the steps it follows:

  • Plot1: Indicators typically output values using the Plot command. Because they can have have multiple outputs, these commands are numbered Plot1, Plot2, etc. In this case, it tells TradeStation to plot the vales in the parenthesis.
  • Inside the parenthesis, the calculation is performed.
  • “Last” is the last price
  • AverageFC calculates a moving average.
    • The parameter Close tells it to use closing prices for the history. (You could also use open, high or low.)
    • “Length” tells it use the value inputted as the length. In this case, it will use 200.
    • In plain language, this means “calculate the average closing price over the last 200 days.”

The “-1” turns the data into a decimal. The only thing left to do is to make RadarScreen display the value as a percentage:

  • Click on File → Properties ..
  • A dialog box will appear. Click on the Grid Style tab. Then set the Category to Percentage and increase the Decimals to 2.
  • Click OK.

Now you’re ready to finish the study. Hit the F3 key to verify it. This will check the code for errors before it runs on the platform.

Return to your RadarScreen and add the new indicator using the previous steps for Mov Avg 1 Line. It may take a minute to load all the values.

Remember you can change the moving average length by right clicking on the “Distance from Mov Avg 1 Line” column header and customizing the indicator. Going to the the Inputs tab, you will notice the same Length from the code above. Altering this will adjust the number of candles used in the moving average.

Pfizer (PFE), daily chart, with 200-day moving average.

Getting the Results

The new column in RadarScreen will show how far each stock is from its 200-day moving average. Double click on the column header to sort results. You can change the width of the column by clicking and dragging on the edges.

Scrolling down the list, you can discover companies within a few percentage points of the average. Some of the notable companies on the list today are shown in the table below:

CompanyDistance from
200-day MA
Industry
Pfizer (PFE)0.2%Pharmaceuticals
Freeport McMoRan (FCX)-0.5%Copper
Verizon Communications (VZ)-2.9%Telecom
Kraft Heinz (KHC)0.5%Consumer Staples
HP (HPQ)1.9%Computers
Johnson & Johnson (JNJ)1.5%Health Care
PepsiCo (PEP)-1.7%Consumer Staples
CVS Health (CVS)-4%Health Care
Broadcom (AVGO)-4.6%Semiconductors
Altria (MO)-1.7%Tobacco
Source: TradeStation data

About the author

David Russell is VP of Market Intelligence at TradeStation Group. Drawing on 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.