Add Position Reversal Buttons to a NinjaTrader Chart for a Long-Short Reversal Strategy (Point-and-Click NinjaTrader® Strategy)
Original Trading Strategy
Peer Reviews, Modifications & Responses
Thanks for Sharing!
Trading Strategy Summary
This strategy is like the “Moving Average Crossover Long-Short Reversal with Percentage-Based Profit Target” strategy that is built into Quagensia N Edition, in the “Strategies for New Users” folder of the Algo Explorer on the left side of Quagensia N Edition’s main window, except that it adds buttons to the NinjaTrader® chart upon which this strategy is applied that adds more functionality, including:
1. A “toggle button” that will allow you to manually enable or disable new automated and manual entries. You can start the strategy with this toggle (or “feature flag” on or off by setting the strategy’s “Allow New Entries On Strategy Start?” input parameter to True or False by checking or unchecking its check box at the time you apply it to a chart. When you click this button it sets a Boolean (True or False) Internal Variable to False if it was True and True if it was False, i.e. clicking this button “toggles” the value of the Internal Variable, and it is this Internal Variable that is checked both 1) in the “When Bar Updates” section, and 2) when the two buttons described in points 2 and 3 below are clicked, to determine if a new position can be entered instead of only exiting the current position.
2. A button labelled “Enter or Reverse to Long (Or Exit Short If Entries Not Allowed)” that exits the strategy’s short position if there is one, and enters a new long position if the “toggle button” described in point 1 above is in its “On” state rather than its “Off” state.
3. A button labelled “Enter or Reverse to Short (Or Exit Long If Entries Not Allowed)” that exits the strategy’s long position if there is one, and enters a new short position if the “toggle button” described in point 1 above is in its “On” state rather than its “Off” state.
4. A button labelled “Flatten Position” that is intended to flatten the strategy’s long or short position if the strategy is in a position.
5. A button labelled “Kill Switch” that when clicked calls the Quagensia N Edition no-code function named “Close Strategy If Strategy’s State Is “Realtime” (Cancels Working Orders, Closes Positions, And Disables Strategy)” which is intended to do what the name implies by calling the NinjaScript® method (i.e. “function”) named “CloseStrategy”. You can learn more about the NinjaScript® “CloseStrategy” method here: https://ninjatrader.com/support/helpGuides/nt8/closestrategy.htm .
*** About the original “Moving Average Crossover Long-Short Reversal with Percentage-Based Profit Target” Quagensia N Edition Strategy upon which this one is based: ***
The “Moving Average Crossover Long-Short Reversal with Percentage-Based Profit Target” Quagensia N Edition Strategy is a moving average crossover strategy that goes long when a fast moving average crosses above a slow moving average and goes short when the fast moving average crosses below the slow moving average.
If the strategy is currently long and the fast moving average crosses below the slow moving average, it will reverse its position from long to short by exiting the long position and entering a short position.
If the strategy is currently short and the fast moving average crosses above the slow moving average, it will reverse its position from short to long by exiting the short position and entering a long position.
The strategy also exits its long or short position when a percentage-based profit target is reached if this strategy’s “Use Profit Target?” input parameter is set to True due to its check box being checked in the NinjaTrader® user interface.
Copyright © 2023-2025 Quagensia, Inc. All rights reserved.
How to Get the Quagensia Strategies
This point-and-click trading strategy is built into Quagensia N Edition (for NinjaTrader®).
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.


