automated-trading.ch

X Swings Strategy

NinjaTrader 8 Strategy Published 28 Nov 2023 - Updated on 26 Jan 2024
PREMIUM
Summary

The X Swings Strategy is a mechanical trend-following NinjaTrader 8 Strategy. It is a full-auto strategy that can be run on autopilot and can be used to pass propfirms evaluation challenges

We highly recommend joining our discord community by following this invite link discord-invitation

Index
Description

The X Swings strategy is a trend-following strategy that is designed to be run on trendy micro futures instruments such as the MNQ or MCL. The strategy aims to be profitable in the long term by generating a positive expected return determined by a win/loss ratio that is higher than 1.

The strategy can be used on a price based bar-type such as UniRenko or a time based bar-type. Refer to the preferred settings section to check out our suggested parameters for the preferred UniRenko candles

The strategy gets armed when a certain conditions are met:

  • For a long entry :
    • X consecutive higher low swings are observed
  • For a short entry :
    • X consecutive lower high swings are observed

Along with this first condition the strategy will look for a specific setup related to the Point of Control (POC) on the last couple of candles

How the strategy manages its positions:

The strategy has two methods to manage its positions.

  • Dollar Cost Averaging method or a Grid method
  • In this method, each position opened with the strategy can have one of these three scenarios:

    • The price goes in the opposite direction of the trade without a pullback and hits the Stop-Loss target
    • The price goes in the winning direction of the trade and hits the profit target
    • The price chops around and shows hesitation to go in a direction. In this case, the strategy will try to exit the position as fast as possible by a dollar cost averaging method that consists of increasing the position size whenever a price swing is closed on the losing side of the trade.

      This will bring the take profit level closer but will also bring the stop loss level closer to the current price.

      In the same time, the strategy has a maximum risk per trade that cannot be exceeded. The increasing of the psition quantity is managed.

      Furthermore, the strategy has the ability to set the position to breakeven if an opposite signal is dispatched

  • Trailing Stop Method
  • When this method is used, the stop loss of the position will be trailed following the last formed higher low (for a long position) or the last lower high (for a short position)

entry-example
Features

The X swings strategy has a set of unique features:

  • No pending orders are placed: only market orders
  • Full-auto strategy that can be scaled into multiple instances
  • Precise backtesting capabilities following NinjaTrader official best practices to obtain precise entry/exit backtesting on tick level
  • Robust in-house Order management library. Resistant to connection loss and works seamlessly on Rithmic accounts or NinjaTader brokerage accounts
Parameters

We try to keep the parameters to minimum. We only left the most important parameters to be set

General
Backtest Mode This parameter is very important and should be used carefully. This parameter should be set to true (checked) whenever the strategy is run in Historical, Backtest, or Optimization modes. When running the strategy in Live Real-Time mode this parameter should be set to false (unchecked).
Draw POC on Each Bar This parameter will draw the Volume Point of Control as a yellow line on each bar
Swings Merge Ticks This parameter defines the sensitivity to merging successive higher highs and lower lows if they are too close to each other. The threshold set in this parameter is the maximum number of ticks that separate two swings for them to be merged.
Daily TakeProfit The strategy will stop when the daily TakeProfit amount is reached after a position is closed. When set to 0, this parameter is ignored
Daily StopLoss The strategy will stop when the daily StopLoss amount is reached after a position is closed. The value of this parameter is positive. For example if the value is set to 300, the strategy will stop when the Realized PnL is lower or equal to -300$. When set to 0, this parameter is ignored
Swings Period Swings are higher lows,higher highs, lower highs and lower lows. After each price bar close, a swing can be detected. But just after that, the next bar can cancel the swing at the previous bar by creating a new swing of the same type. Or this can happen on the second bar, or the third, etc... The swing period sets how many bars is enough to seperate two swings of the same type. The more you increase this parameter, the more you decrease the number of swings overall. The more you decrease this parameter, the more you increase the number of overall swings. I personally use the value of 3 or 4 for this parameter.
Draw Price Swings This parameter will enable/disable the drawing of swings on the chart. Swings will always be analyzed and processed regardless of this parameter which only affect visibility and render.
Entry Setup
Trade Time This parameter is very important and can be delicate in some cases. This parameter is used to determine the time intervals in which the strategy is allowed to place trades. The time zone that should be used while setting this parameter value should be the Time Zone of the machine on which NinjaTrader is executed. Here are some examples for more clarifications:
  • Machine in New York Time Zone and trade time set to RTH (regular trading hours): 09:30-16:00
  • Machine in Switzerland Time Zone and trade time set to RTH: 15:30-22:00
  • Machine in New York Time Zone and trade time set to both RTH and ETH (extended trading hours) with gaps to avoid volatile periods: 00:01-08:00,09:55-15:55,20:00-23:59
  • In this example, there are two things to notice: Even though the ETH session starts at 6 p.m., the strategy can and should only be started at 8 p.m. to avoid an internal UTC conversion issue. the time intervals should be set in increasing order even though the last interval 20:00-23:59 is the first interval that occurs for a new day session. the time interval were cut at midnight to avoid issues when stepping into a new day
  • Machine in Switzerland Time Zone and trade time set to both RTH and ETH (extended trading hours): 02:00-14:00,15:55-21:55
Entry Mode

This parameter is useful if you already have a directional bias and want to restrict trading to a specific direction long or short

  • Long: Only long trades will be open
  • Short: Only short trades will be open
  • Long & Short: The strategy will open both long and short trades
Trend Swing Count This parameter will set the minimum number of consecutive increasing lower low swings to enter a long trade, and higher high swings to enter short trade
Both HH/LL Trend Condition When enabled, this parameter will require that both higher highs and lower lows satisify the trend condition for long and short entries. For example to enter a long trade and with a Trend Swing Count value of 2, this parameter will require that the last 2 higher highs and the last 2 lower lows are increasing in price. If it was not enabled, only the last 2 lower lows increasing would be sufficient
Enable POC Condition When enabled, this parameter will add the condition of the POC (volume point of control) on one of the last couple of bars. The condition is satisfied whn the POC is above the open price of a bearish candle or below the open price of bullish candle. The other previous parameter Draw POC on Each Bar allows to visualize POCs on each candle
Order Qty This parameter sets the quantity of each order to be traded. In the case of increasing orders, this quantity is also used for each increase. Generally, We would use the values 1 or 2 for this parameter for the MNQ and MES insturments
Order Management
Order Management Strategy
  • Dollar Cost Averaging (Grid): This method will increase the order quantity each time a swing is formed in losing side of the trade, which creates a dollar cost averaging effect on the position average price. We also call this a Grid method
  • Trail Stop on Swings: This method will trail the stop loss of the position each time a swing is formed in the winning direction of the trade
  • None: This selection means the stop loss defined by the Stop Loss Currency parameter will be used
On Opposite Signal
  • Breakeven: This parameter sets the behaviour of the strategy whenever an opposite signal occurs to breakeven
  • Close Position: This parameter sets the behaviour of the strategy whenever an opposite signal occurs to immediately closing the position
  • DoNothing: This parameter sets the behaviour of the strategy whenever an opposite signal occurs to nothing
StopLoss Strategy
  • Bar High Low: When this value is set as the stop loss strategy, the StopLoss price is set to the Imbalance candle low/high levels. The overall StopLoss price will also be determined by the previous Stop Loss Currency parameter. Hence, the position will be closed when any of those StopLoss levels is hit
  • Last Swing: When this value is set as the stop loss strategy, the StopLoss price is set to the previous Price Swing high/low level. The overall StopLoss price will also be determined by the previous Stop Loss Currency parameter. Hence, the position will be closed when any of those StopLoss levels is hit
  • Fixed Currency Value: This selection means only the stop loss defined by the Max Stop Loss Currency parameter will be used
TakeProfit Strategy
  • Fixed Currency Value: This selection means the take profit price will be based on the fixed value of the parameter Take Profit Currency
  • 1:1 Win Loss Ratio: The take profit price will be calculated based on the stop loss price with a 1:1 ratio
  • 0.5:1 Win Loss Ratio: The take profit price will be calculated based on the stop loss price with a ratio
  • 2:1 Win Loss Ratio: The take profit price will be calculated based on the stop loss price with a 2:1 ratio
  • 3:1 Win Loss Ratio: The take profit price will be calculated based on the stop loss price with a 3:1 ratio
  • 4:1 Win Loss Ratio: The take profit price will be calculated based on the stop loss price with a 4:1 ratio
  • 5:1 Win Loss Ratio: The take profit price will be calculated based on the stop loss price with a 5:1 ratio
  • 6:1 Win Loss Ratio: The take profit price will be calculated based on the stop loss price with a 6:1 ratio
Max Stop Loss Currency This sets the max risk in dollars for the open position.
Take Profit Currency This sets the take profit in dollars for the open position. If you use the Fixed Currency Value as a take profit strategy, the value of this parameter will be used. If not, make sure to set this parameter to a high value to not interfer with other ratio based strategies
DCA (Grid) Parameters
Breakeven Profit Shift When the DCA method is selected, this parameter will modify the definition of a breakeven and adds a bit of profit to it. This is useful to cover the cost of commissions when closing the grid in breakeven
Grid Size to Breakeven When the DCA method is selected, this parameter will set the number of order increases required to start consider closing the position in breakeven
Min Ticks To Increase Qty This parameter sets the minimum required number of ticks that separate the current price from the average position price before increasing the quantity of the position. The current price needs to be on the losing side of the position. This created a DCA (dollar cost averaging) effect on the position. You can set this value to 0 or a very big number to disable quantity increase and let the position get closed by either stop-loss or take-profit.
Subscription Vs. One-time Purchase

As I mentioned earlier, the strategy can be downloaded, installed and run in Historical, Playback, and Optimization modes without the need for an active subscription license.

To run the strategy in live Real-Time mode a subscription license is required. I have decided to use the subscription model rather than the one-time purchase model

The one-time purchase model is used by marketers and fake gurus to sell you strategies that they don't use themselves. Their goal is to generate money from selling you the product and thats it. They have no intention to build a long term relationship with their clients nor seriously provide client support or provide custom development service.

By offering the subscription model through my business I aim to build a long relationship with you. you will be able to cancel your subscription at any time with no questions asked. You can also resume/cancel your subscription any time according to your needs and schedule. I will also provide unlimited support and will provide the possibility to answer custom development requests

Also did I mention that by subscribing you get to access all the products catalog, currently available and future ones. :)

To purchase a subscription follow this link to the pricing page Subscribe Now

Download & Installation Instructions

The strategy can be downloaded and run on Backtest, Playback, and Optimization modes for free without the need for an active license that is only required for running the strategy on Live Real-time mode. To download and install the strategy follow the instructions below

  • If you don't already have the UniRenko bar type installed, you can download it from here:
  • Click on the below download button to download the XSwings strategy file
  • This file was downloaded 352 times. Last download was 1 day ago
  • Import the downloaded .zip file into NinjaTrader using the import NinjaScript menu item
  • how to import add on to NinjaTrader
  • Next, open a new chart window with the following settings.
  • image
  • On the new chart settings, make sure you enable the Tick Replay check box
  • If you don't see the Tick Replay check box, go to Tools->Options->Market Data and enable Show Tick Replay
  • image
  • After installing the strategy and opening a new Chart window you should add the strategy to the chart. image
  • After adding the strategy to the chart, the strategy will be run on Historical data loaded in the chart.
  • When the Histocial data run is done, the strategy will switch to Real-Time mode and will add the license panel controls to the Chart Trader Panel
  • Make sure to display the Chart Trader panel on your active NinjaTrader Chart
  • image
  • Copy/Paste your license in the text box as shown in the image below. Your license can be found on the billing main page. Make sure to create an account first or to login
  • Click on the Check License Button
  • image
  • At this step the strategy will check the License and activate/deactivate trading according to the license validity
  • If the license is valid you will see the "Check License" button turned to green, and the next billing cycle displayed next to your email. License check is only required once. Until the next biling cycle date.
  • image
  • At this stage, the strategy is ready to be run in all modes of execution
Frequently Asked Questions
General
Do I need a VPS to run this strategy?

Using a VPS is good but not imperative. I run this strategy on a ~$6 VPS Windows instance on Hetzner. Check out our resources page to get a discount through our affiliate LINK

Can I run multiple instances of this strategy on the same account?

Yes! You can run multiple instances of this strategy on the same account but each instance should be run on a unique instrument

You can't run multiple instances on the same account on the same instrument because as you know NinjaTrader will aggregate orders in one position per instrument per account

Can I use a Trade Copier with this strategy?

Yes! you can use a copier, but a better solution would be to run multiple instances of the strategy. The purchased license allows you to run unlimited instances on multiple machines

Can I use this strategy to pass Apex or any other trader funding program?

Yes! The strategy is designed for that exact purpose. It will work seamlessly on Rithmic, NinjaTrader brokerage, Tradovate or any other provider connected to your NinjaTrader platform

Is this a hands-off, full-automatic strategy or does it need manual intervention and monitoring?

I designed this strategy to be full-automatic strategy. The only manual intervention it needs is to restart it each day

Why should I consider full automated-trading instead of discretionary manual trading?

You should consider full auto-trading over manual trading for many reasons:

  • Trading 24/7: Automated trading strategies don't need to go to the bathroom not it need to take a break
  • Better execution, faster and more precise
  • Eliminate psychology and sentiments
  • Can be scaled to dozens if not hundreds of instances
  • Automated trading can generate truly "passive" income, manual trading is just another "more stressful" job

Can I ask you to modify/add a new feature to this strategy?

Yes, If you have an idea that you believe can improve the performance of this strategy, I will be more then happy to hear from you. Please use the contact page to send me a message

Will I get the source code of the strategy when I download it?

No, the source code of the strategy is protected for copyright reasons

Billing
Can I cancel my subscription at any time?

Yes, you can cancel your subscription from the account page at any time to prevent future payments. We cannot refund the unused portion of your subscription, but you will be able to use your subscription even after cancelling for the remainder of the billing cycle.

Is there a free trial period?

No, we don't offer a trial subscription plan. But you can download and test the strategy in backtest and playback modes before subscribing

What is the refund policy?

We do not offer full or partial refunds, but you may cancel your subscription at any time to stop future payments.

Skeptics
What is your background? Aren't you just another fake trading guru trying to sell me garbage?

I have been a professional software developer since 2010. I have been developing automated trading strategies since 2012, for my self for fun and profit and also been developing strategies for clients all over the world

I have always been invlolved professionaly in the business of Finance and investing, I have worked for trading brokers and investment banking.

I'm not a marketer, and I don't hire someone else to develop my strategies.

If this strategy is profitable why are you selling it?

This strategy has been profitable for me on the long run with ups and downs, especially when it is run on multiple insturments. But the question remains pertinent, why I'm selling it?

The answer is I'm not selling it, I'm renting it to generate an additional income and diversify my different sources of income besides what this strategy can generate. Which you should also do. You should not rely on one source of income to reach financial independance, the key is diversification.

Why the strategy uses Market orders and no Pending orders?

Lets examine pros and cons of pending orders

  • Pros:
    • Best price execution when using limit orders
    • Protection against losses in case of connectivity issues
  • Cons:
    • Can get rejected on high price volatility
    • Delay between request to place the order and when it gets placed. Price volatility can cause the order to be rejected and the price to run away
    • Requires management: any opposite orders need to be canceled
    • Visible to the broker, placed orders can be manipulated

After years of developing strategies I reached the conclusion that market orders are better suited for the context of automated trading.

The main drawback of using pending orders is the fact that they can be rejected which is very hard to manage especially in a volatile environment

In all our strategies, we use market orders even for take profit and stop loss. Lets examine the pros and cons of market orders

  • Pros:
    • Guarantee of execution reagrdless of volatility conditions
    • Invisible to the broker before they get submited
    • No risk of being rejected which means better protection for stop loss
    • Faster execution than pending orders
  • Cons:
    • In the case of the connection being lost with the broker, the strategy will be unable to send market orders

Remark: MIT (market if touched) orders in NinjaTrader are a solid alternative to pending orders if you really want to use pending orders

It is known that backtesting on NinjaTrader is not accurate. How accurate are your backtests?

We are following the NinjaTrader official guide on how to achieve precise intrabar granularity backtesting by using additional tick level DataSeries See here for more info

Don't take my word for it. Test it yourself, at the end of each trading day, run a backtest of the strategy on that day and compare it with the live trades the strategy made during the day.

Release Notes
Release 1.1.0.0 - 26 Jan 2024

  • Updated parameters and functionalities

Release 1.0.0.0 - 28 Nov 2023

  • First Release of the strategy as a free strategy

User Comments & Feedback