Skip to content
  • +1 (331) 256-9097
Contact Us
Ask Question in Our Discord
Download Free Trial
Quagensia
  • Quagensia Software
    • Quagensia N Edition
      • Features
      • Pricing
      • Download Free Trial
      • Request a Demo
    • Quagensia T Edition
      • Features
      • Pricing
      • Download Free Trial
      • Request a Demo
  • Pricing
    • Quagensia N Edition
    • Quagensia T Edition
  • Portal
    • Directory of Point-and-Click Strategies at Quagensia.com
    • Trading Strategy Web Directory
      • Trading Strategies – Courses & Education
      • Trading Strategies – News & Analysis
      • Trading Discussion Forum Directory
    • Trading Strategy Video Directory
    • Strategy Directory – Beyond Quagensia.com
    • Quagensia N Edition-Compatible Third-Party Indicators
    • Content Creator Support Center
  • Support
    • Quagensia Help Documentation
    • Join Us on Discord
    • Discussion Forums
    • Contact Us
  • Company
    • About Us
    • Contact Us
    • The Quagensia Blog
    • Company News
    • Logos and Assets
  • Quagensia Software
    • Quagensia N Edition
      • Features
      • Pricing
      • Download Free Trial
      • Request a Demo
    • Quagensia T Edition
      • Features
      • Pricing
      • Download Free Trial
      • Request a Demo
  • Pricing
    • Quagensia N Edition
    • Quagensia T Edition
  • Portal
    • Directory of Point-and-Click Strategies at Quagensia.com
    • Trading Strategy Web Directory
      • Trading Strategies – Courses & Education
      • Trading Strategies – News & Analysis
      • Trading Discussion Forum Directory
    • Trading Strategy Video Directory
    • Strategy Directory – Beyond Quagensia.com
    • Quagensia N Edition-Compatible Third-Party Indicators
    • Content Creator Support Center
  • Support
    • Quagensia Help Documentation
    • Join Us on Discord
    • Discussion Forums
    • Contact Us
  • Company
    • About Us
    • Contact Us
    • The Quagensia Blog
    • Company News
    • Logos and Assets
Point-and-Click Strategies and Education for NinjaTrader® and TradeStation® > ETFs > U.S. ETFs > SPDR S&P 500 ETF Trust (SPY)

SPY Broke Out of a Narrow Trading Range on 5/17/2023, but Our Backtest Suggested it Wasn’t Bullish for the Open. [Article] (Point-and-Click NinjaTrader® Strategy)

Includes point-and-click strategy for NinjaTrader® which you can download from this page and open in Quagensia® N Edition (for NinjaTrader®).
SPY Broke Out of a Narrow Trading Range on 5/17/2023, but Our Backtest Suggested it Wasn’t Bullish for the Open. [Article] (Point-and-Click NinjaTrader® Strategy)
Quagensia
Quagensia
Thursday, May 18, 2023
SPDR S&P 500 ETF Trust (SPY)
U.S. ETFs
N Edition
Intermediate Users
Free Trial User Can Generate Code
Articles
Breakouts Above a Narrow Trading Range
Free Trial User Can Generate Code
Intermediate Users
News & Analysis

Original Trading Strategy

Discuss on X (x.com, Quagensia)

Peer Reviews, Modifications & Responses

Contribute

Thanks for Sharing!

Trading Strategy Article

Summary: This is the Quagensa N Edition version of the Quagensia T Edition-based article SPY Broke Out of a Narrow Trading Range on 5/17/2023, but Our Backtest Suggests it’s Not Bullish for the Open. [Article] (T Edition) that we published before 2 AM CST on 5/18/2023, and which was meant to be a timely article to aid traders in their decisions regarding what to do when SPY opened this morning. That article included a downloadable Quagensia T Edition strategy that traders could open in Quagensia T Edition, then generate its TradeStation® EasyLanguage® code and backtest the TradeStation® EasyLanguage® strategy in TradeStation® 10. We are now well past the open today so that analysis is now out-of-date, but we wrote this article so that users of Quagensia N Edition and NinjaTrader® would be able to download the Quagensia N Edition version of the strategy. Users can generate its NinjaTrader® NinjaScript® code and backtest it in NinjaTrader®.

This article is written in the past tense because it was written after the market open on 5/18/2023. The details and backtest results are specific to NinjaTrader®. As you will see, the backtest results are comparable to those generated using TradeStation.

SPY’s daily bar on 5/17/2023 clearly broke out of the narrow trading range of its last several bars with multiple factors that made the breakout stand out visually on a chart but readers of our article SPY Broke Out of a Narrow Trading Range on 5/17/2023, but Our Backtest Suggests it’s Not Bullish for the Open. [Article] (T Edition) were advised to beware of buying SPY at the open earlier today with the expectation of riding SPY up for the next several bars. Our analysis in that article was supported by our backtest results in NinjaTrader® as well.

SPY’s breakout on 5/17/2023 had the following characteristics:

  • The previous seven bars traded in a narrow range. The highest open or close was only 0.88% higher than the lowest open or close.
  • The 5/17/2023 bar opened above the open and the close of the previous bar.
  • The 5/17/2023 bar was a clear breakout bar. It closed 1.21% above its previous close and was up 0.70% from its open.

Are the above factors bullish, bearish, or non-predictive? Many technicians would say bullish, but we found that they were actually non-predictive over the last more than 25 years of market data in NinjaTrader®. We created a Quagensia N Edition strategy, generated its NinjaTrader® NinjaScript® code, and backtested the NinjaTrader® NinjaScript® strategy to test a trading idea that enters a long trade on the open of the daily bar that occurs after market action whose characteristics were very similar to those listed above and holds the long trade for the same number of bars as the number of bars in the narrow market range.

Our specific entry criteria were to enter a long trade on the open of the daily bar that occurs directly after the daily bar with the following characteristics:

  • Since the seven bars prior to the 5/17/2023 daily bar traded in a narrow range such that the highest open or close was only 0.88% higher than the lowest open or close, we allowed a minimum of 0.48% and a maximum of 1.28% for this metric for the seven bars prior to the daily bar that was the breakout bar.
  • The daily bar that was the breakout bar must open above the open and the close of the previous daily bar to match this characteristic of the 5/17/2023 bar.
  • The daily bar that was the breakout bar must close between 0.81% and 1.61% above the close of the previous bar since the 5/17/2023 bar’s value for this metric was 1.21%.
  • The daily bar that was the breakout bar must close between 0.30% and 1.10% higher than its open since the 5/17/2023 bar’s value for this metric was 0.70%.
  • A position is not entered if the strategy is already long.

The strategy closes the long position after seven bars, which was the same number of bars that traded in a narrow range prior to the 5/17/2023 bar.

A backtest of this NinjaTrader® NinjaScript® strategy was done over the entire history of daily bars of SPY in NinjaTrader®, which goes back over 25 years, using a commission of $4.95 per trade and a slippage of $0.02 per share. The entry criteria listed above occurred 26 times, with the first trade in the backtest being entered on 7/2/1996 and the last trade being exited on 6/16/2021.

According to this NinjaTrader® NinjaScript® strategy’s backtest results in the NinjaTrader® Strategy Analyzer, this strategy’s backtest indicated that trading these 26 daily breakouts in the past, using the entry rules and exit rule as described, would have actually led to a small loss. By running a backtest, we were able to determine that the breakout of the 5/17/2023 SPY daily bar should not have been considered particularly bullish and should not have been the main reason why a trader entered a long trade when the market opened on Thursday, 5/18/2023 and exited seven bars later. You may have had other valid reasons why you should have bought SPY on the open, but the breakout that was tested with the assumptions and thresholds described in this article should not have been one of them.

We invite you to download the Quagensia N Edition strategy on this page, open it in Quagensia N Edition, generate its NinjaTrader® NinjaScript® strategy code and test it in NinjaTrader® 8 or NinjaTrader® Desktop where you should be able to verify our results. You can explore the effect of tightening or loosening the thresholds for the entry criteria by changing the values of the strategy’s input parameters in NinjaTrader®. Finally, if you have a valid paid license for Quagensia N Edition you can change the Quagensia N Edition strategy’s logic without code to more closely match how you see the market action of the 5/17/2023 SPY breakout.

This article is an example of algorithmic journalism. We invite content creators to use a Quagensia Desktop Application to create their own articles based on tested trading ideas. And we invite traders to use a Quagensia Desktop Application to test their ideas before they trade them.

This trading idea is subject to the disclaimers in our Terms of Service.

How to Get the Quagensia Strategies

The downloadable zip file linked to below contains Quagensia N Edition (for NinjaTrader®) files and/or auxiliary files that were created by us at Quagensia, Inc.:

Download the Zip File

Click the link above to download the zip file and unzip it. If this zip file contains point-and-click Quagensia Trading Strategy files for your edition of the Quagensia Desktop Application, put the point-and-click Quagensia Trading Strategy files into your “My Algos” folder as described in the video Downloading & Importing Third-Party Strategies into Quagensia N Edition (for NinjaTrader®) or Downloading & Importing Third-Party Strategies into Quagensia T Edition (for TradeStation®).

Customize Quagensia Strategies with Your Own Ideas

Tweaking Quagensia Trading Strategies using point-and-click with the Quagensia Desktop Application is easy for non-programmers. If you get stuck you can usually find the answer you need in our online help documentation or you can ask a question in our friendly Discord community.

If you don’t want to tweak a Quagensia Trading Strategy with point-and-click to add your own proprietary trading logic, you can still download a Quagensia Trading Strategy file, open it up in the Quagensia Desktop Application, and generate its code, then backtest and optimize the trading strategy on different instruments, different bar periods (weekly bars, daily bars, hourly bars, 15-minute bars, etc.), or different bar types (time-based bars, volume-based bars, tick-based bars, etc.), and use different start and end dates.

Some tweaks you can make to the Quagensia Trading Strategies you download include:

Modify the entry & exit logic.

  • Add more conditions, remove conditions, or change them by choosing from among a very large number of components, including many exotic indicators.
  • Add or modify stop losses, trailing stops, and profit targets. Make them tighter, less tight, or based on an entirely different calculation.
  • Add or modify time stops. For example, exit after a certain number of bars either unconditionally or only if the post-entry price action did or did not exhibit certain characteristics.

Enhance the output of the strategy to go beyond simply placing orders.

  • Draw lines, shapes, and text on the chart. For instance, you can mark times or prices where each entry or exit condition of a multi-condition entry or exit was true, even if all the necessary entry or exit conditions were not true at the same time so an entry or exit did not occur.
  • Write information to NinjaTrader®’s NinjaScript® Output window or TradeStation®’s EasyLanguage® Print Log window.
  • Write information to a file. You can even output a report that can be opened in Microsoft Excel or consumed by another application that reads comma-delimited, semicolon-delimited, or otherwise character-delimited tabular data files.

Thanks for Sharing!

Watch on YouTube Watch on YouTube
Watch on YouTube Watch on YouTube

Ready to get started?

Download the Quagensia no-code strategy builder free trial and build your trading strategies now.
Download Free Trial

Under a dollar a day.

Priced to be an easy decision for most traders.
See Pricing

Join Us on Discord

Build point-&-click strategies for NinjaTrader® and TradeStation® using Quagensia®. Collaborate with other traders to get and give help, build and backtest strategies together, and grow your skills.
Join Discord

Subscribe to our Newsletter

We'll send you product updates and company news from Quagensia as well as curated lists of Quagensia-enhanced content.
Subscribe

Welcome
Content Creators

Quagensia enables content creators to make interactive content. We invite you to create Quagensia-enhanced content and share it on YouTube and other social media channels. You may submit your high-quality Quagensia-enhanced content for consideration for free inclusion on our website.
Create Quagensia-
Enhanced Content

Screenshots of the Quagensia Strategy

Here’s a screenshot of the Quagensia N Edition Strategy you can open from Quagensia N Edition and add your own proprietary logic to, then backtest on any instruments for which you have market data in NinjaTrader®.
Screenshot for point-and-click trading strategy "SPY Broke Out of a Narrow Trading Range on 5/17/2023, but Our Backtest Suggested it Wasn’t Bullish for the Open. [Article]"

Backtest and Optimize SPY Trading Strategies in NinjaTrader® and TradeStation®

NinjaTrader® instructions: Download NinjaTrader® from the NinjaTrader® home page, then connect to their free daily Kinetick data feed and free daily and intraday Coinbase data feed, then chart SPY for free by entering the symbol SPY, start backtesting and optimizing Quagensia N Edition Trading Strategies for SPY and other instruments for free, and trade them in live markets with NinjaTrader®.
TradeStation® instructions: Contact TradeStation® from the TradeStation® home page to obtain access to TradeStation® 9.5 and TradeStation® 10, then chart SPY by entering the symbol SPY, start backtesting and optimizing Quagensia T Edition Trading Strategies for SPY and other instruments, and trade them in live markets with TradeStation®.

Additional Resources Relevant to This Trading Strategy

TradingView Chart (SPY)
Yahoo Finance Chart (SPY)  |  Overview
Seeking Alpha (SPY)
ETF Database (etfdb.com) (SPY)
Benzinga (SPY)
Investing.com (SPY)
Google Finance (SPY)
finviz (SPY)
msn money (SPY)
TheStreet (SPY)
CNBC (SPY)
Zacks (SPY)
Investor’s Business Daily (SPY)
Economic Calendars (Over 30, All Free-to-Use)
Earnings Calendars (Over 20, All Free-to-Use)
Submit a link to an article, blog post, research report, or other valuable research where Quagensia is mentioned.
Use the “How to Submit Quagensia-Related Links” page linked to above to inform us about an article, blog post, or other valuable research where Quagensia is mentioned. This includes articles and research reports in both the traditional financial press as well as those on high-quality niche trading industry news & analysis websites and blogs that are in keeping with our brand. We will add links to the best articles, blog posts, and research reports both on this page and on other pages on our website, on our social media accounts, in our email newsletter, and in other relevant places.

Discussions Relevant to This Trading Strategy

WARNING: Trading discussion websites, including forums, subreddits, X, and similar discussion websites, often have a lot of profanity and offensive comments.
Discussions Beneath Seeking Alpha Articles about SPY (has a conditional paywall)
$SPY Discussion on X
SPY Discussion on Stocktwits
SPY Discussion on Investing.com
You may need to expand the “Discussions” widget in the bottom right corner of the web page.
SPY Discussion on Yahoo Finance
Exchange-Traded Funds (ETFs) Subreddit (r/ETFs)
Stocks Subreddit (r/Stocks)
StockMarket Subreddit (r/StockMarket)
investing Subreddit (r/investing)
Options Subreddit (r/Options)
Elite Trader Discussion Forum
Daytrading Subreddit (r/Daytrading)
See more discussion options in The Quagensia Trading Discussion Forum Directory.
Submit a link to a discussion where Quagensia is mentioned.
Use the “How to Submit Quagensia-Related Links” page linked to above to inform us about a discussion thread where Quagensia is mentioned. This includes discussions on forums, subreddits, FaceBook groups, X, and anywhere else. We will add links to the best discussion threads both on this page and on other pages on our website, on our social media accounts, in our email newsletter, and in other relevant places.

Related Trading Strategies & Education

SPDR S&P 500 ETF Trust (SPY)

Main Page

U.S. ETFs

Main Page
Instrument List

ETFs

Main Page
Instrument List
Instrument Type List

Browse Trading Strategies & Education by Category

Account Info
Advanced NinjaScript® Strategy Events
Analyze Actual Trades
Breakouts
Button Controls on a NinjaTrader Chart
Chart Patterns
Check Box Controls on a NinjaTrader Chart
Conditional Trading Logic (If… Else If… Else Block)
Conditions
Consecutive Bars are Similar
Copy-and-Paste
Counterfactual Trading
Custom Popup Windows on a NinjaTrader Chart
Custom Quagensia Functions
Data Type Conversion and Rounding Decimal Numbers
Data Types
Draw Something
Experience Level: New, Intermediate, Advanced
File Input/Output
Gap Up/Down
Indicators
Input Parameters
Long-Short Position Reversals
Loops
Math
Media Types
Microsoft Excel
Money Management
New High/Low
News & Analysis
NinjaScript/Advanced Objects
NinjaTrader ATM Strategies
Order, Fill, and Position Info
Other Locations to Paste NinjaScript Code
Price Data
Quick Intros
Raw Code Output Actions
Raw Code Output Expressions
Reports
Session Info
Set a Variable
Sets of Conditions (With ANDs, ORs, and Parentheses)
Strategies Built Into the Quagensia Desktop Application
Strategy Info
Strategy Templates
Submit an Order
Support and Resistance
Text Box Controls on a NinjaTrader Chart
Trend Following
TriggerCustomEvent
Usable in Free Trial?
Utilities
When Advanced NinjaScript Events Occur

Browse Trading Strategies & Education by Instrument Type

Cryptocurrencies
ETFs
Forex
Futures
Multiple Instrument Types
Options
Stocks

Browse Trading Strategies & Education by Watchlist

Cryptocurrencies
FAANG Stocks
MAMAA Stocks
U.S. Equity Indices

Thanks for Sharing!

Watch on YouTube Watch on YouTube
Watch on YouTube Watch on YouTube

Ready to get started?

Download the Quagensia no-code strategy builder free trial and build your trading strategies now.
Download Free Trial

Under a dollar a day.

Priced to be an easy decision for most traders.
See Pricing

Join Us on Discord

Build point-&-click strategies for NinjaTrader® and TradeStation® using Quagensia®. Collaborate with other traders to get and give help, build and backtest strategies together, and grow your skills.
Join Discord

Subscribe to our Newsletter

We'll send you product updates and company news from Quagensia as well as curated lists of Quagensia-enhanced content.
Subscribe

Welcome
Content Creators

Quagensia enables content creators to make interactive content. We invite you to create Quagensia-enhanced content and share it on YouTube and other social media channels. You may submit your high-quality Quagensia-enhanced content for consideration for free inclusion on our website.
Create Quagensia-
Enhanced Content

Videos for New Users

Watch on YouTube Watch on YouTube
Watch on YouTube Watch on YouTube
Watch on YouTube Watch on YouTube
Watch on YouTube Watch on YouTube

Videos for Intermediate Users

Watch on YouTube Watch on YouTube
Watch on YouTube Watch on YouTube

Screenshots

For larger and additional screenshots, see large Quagensia N Edition screenshots (for NinjaTrader®) and large Quagensia T Edition screenshots (for TradeStation®).

For additional screenshots, see the list of Strategies Built into Quagensia N Edition (for NinjaTrader®) and Strategies Built into Quagensia T Edition (for TradeStation®). Select a built-in strategy that interests you and scroll down for the screenshot. Then scroll up to the top of the page and click the “Overview” link to watch the video on how to use that built-in strategy.

This is a screenshot of the point-and-click trading strategy you will build in Quagensia N Edition (for NinjaTrader®) if you follow along with the video titled Create NinjaTrader® Strategies Using Point-&-Click with Quagensia N Edition – Full Tutorial.

This is a screenshot of the point-and-click trading strategy you will build in Quagensia N Edition (for NinjaTrader®) if you follow along with the video titled "Introduction to Quagensia N Edition".

Click the gear icon that appears when you place your mouse pointer over the location to which you would like to add trading logic. A context menu will appear with filtered options to choose from.

Click the gear icon that appears when you place your mouse pointer over the location to which you would like to add trading logic. A context menu will appear with filtered options to choose from.

Quagensia N Edition

  • Features
  • Pricing
  • Download Free Trial

Quagensia T Edition

  • Features
  • Pricing
  • Download Free Trial

Trading Strategy Portal

  • Directory of Strategies at Quagensia.com
  • Trading Strategy Web Directory
  • Trading Strategies – Courses & Education
  • Trading Strategies – News & Analysis
  • Trading Strategy Video Directory
  • Strategy Directory – Beyond Quagensia.com
  • Trading Discussion Forum Directory
  • Content Creator Support Center

Support

  • Quagensia Help Documentation
  • Discussion Forums
  • Contact Us

Company

  • About Us
  • Contact Us
  • The Quagensia Blog
  • Company News
  • Logos and Assets
  • Terms of Service
  • Privacy Policy
  • Cookie Policy
  • DMCA Policy
  • Forums Code of Conduct
  • Quagensia Desktop Application EULA
  • Site Map

Follow Us

Youtube X-twitter Facebook-f Linkedin

Thanks for Sharing!

Join Us on Discord
Subscribe to our Newsletter

DISCLAIMER REGARDING THE RISKS OF TRADING AND INVESTING

Trading and investing in the financial markets can involve a high degree of risk of financial losses, including losing all of your initial investment or even more than your initial investment. For this reason, you should not invest or trade with money that you cannot afford to lose. The use of leverage can work for you or against you and is highly unsuitable for many investors. The trading of futures, forex, contracts for difference (CFDs), options, and cryptocurrencies is highly unsuitable for many investors. Neither trading nor investing is suitable for all people. Most traders lose money. Before deciding to trade or invest in the financial markets you should carefully consider your financial objectives, level of experience, and risk appetite. Past performance, whether actual or hypothetical, is not necessarily indicative of future results. You must be aware of the many risks associated with trading and investing and be willing to accept them in order to trade or invest in the financial markets. You should seek advice from a qualified independent financial advisor if you have any questions, doubts, or points of confusion regarding these many risks.

DISCLAIMER REGARDING HYPOTHETICAL PERFORMANCE RESULTS

Hypothetical performance results have many inherent limitations, some of which are described below. No representation is being made that any account will or is likely to achieve profits or losses similar to those shown. In fact, there are frequently sharp differences between hypothetical performance results and the actual results subsequently achieved by any particular trading program.

One of the limitations of hypothetical performance results is that they are generally prepared with the benefit of hindsight. In addition, hypothetical trading does not involve financial risk, and no hypothetical trading record can completely account for the impact of financial risk in actual trading. For example, the ability to withstand losses or to adhere to a particular trading program in spite of trading losses are material points which can also adversely affect actual trading results. There are numerous other factors related to the markets in general or to the implementation of any specific trading program which cannot be fully accounted for in the preparation of hypothetical performance results, all of which can adversely affect actual trading results.

DISCLAIMER REGARDING TESTIMONIALS

Testimonials appearing on this website may not be representative of other clients or customers and are not a guarantee of future performance or success.

IMPORTANT LEGAL INFORMATION REGARDING TRADEMARKS AND COPYRIGHTS

Quagensia® N Edition and Quagensia® T Edition are products of Quagensia, Inc., a company which has no affiliation with either NinjaTrader, LLC or TradeStation Technologies, Inc. Neither NinjaTrader, LLC, nor TradeStation Technologies, Inc., nor have any of their respective affiliates endorsed, recommended, or approved Quagensia® N Edition or Quagensia® T Edition. NinjaTrader® and NinjaScript® are registered trademarks of NinjaTrader, LLC. TradeStation®, EasyLanguage®, and Portfolio Maestro® are registered trademarks of TradeStation Technologies, Inc. Bloomberg® and Bloomberg Terminal® are registered trademarks of Bloomberg Finance L.P. Refinitiv® and Refinitiv Eikon® are registered trademarks of Refinitiv or its affiliates. MATLAB® is a registered trademark of The MathWorks, Inc.

All trademarks and copyrights are the property of their respective owners.

Copyright © 2023-2026 Quagensia, Inc. All rights reserved. Quagensia® is a trademark or registered trademark of Quagensia, Inc in the United States, the European Union, China, Japan, and other countries.