Hello. Could someone assist me in creating a strategy using NinjaTrader 8 Builder that enters trades precisely at the crossover point of two moving averages? I'm new to this, and I greatly appreciate any guidance and support.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Assistance Needed for Precise Entry Strategy in NinjaTrader 8 Builder
Collapse
X
-
Assistance Needed for Precise Entry Strategy in NinjaTrader 8 Builder
Hello. Could someone assist me in creating a strategy using NinjaTrader 8 Builder that enters trades precisely at the crossover point of two moving averages? I'm new to this, and I greatly appreciate any guidance and support.
Tags: None
-
Hello teabubble,
Thanks for your post.
This could be accomplished by creating a CrossAbove() or CrossBelow() condition in your script and running the script using a Calculate mode of Calculate.OnPriceChange or Calculate.OnEachTick.
Calculate.OnPriceChange or Calculate.OnEachTick would allow the strategy to process logic intrabar for each change in price or each incoming tick. This means that the moment the crossover occurs and order would be placed.
See the help guide documentation below for more information.
Conditions: Creating Crossover Conditions:
Actions: https://ninjatrader.com/support/help...t8/actions.htm
Calculate: https://ninjatrader.com/support/help.../calculate.htm
Below is a link to a forum post with helpful information about getting started with NinjaScript.
https://ninjatrader.com/support/foru...040#post786040
I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript:
https://ninjatrader.com/support/help..._resources.htm
If you are new to C#, to get a basic foundation for the concepts and syntax used in NinjaScript I would recommend this section of articles in our help guide first:
https://ninjatrader.com/support/help...g_concepts.htm
And the MSDN (Microsft Developers Network) C# Language Reference.
https://ninjatrader.com/support/help...erence_wip.htm<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
-
Hello. I was able to execute trades in both directions using my strategy, but I noticed that the trades were being executed about 5 to 6 ticks away from the actual crossover points. Could you please guide me on how to adjust my strategy so that it buys and sells at the exact crossover point or just one tick away? Your assistance would be greatly appreciated.
Comment
-
Hello teabubble,
Thanks for your notes.
Something you could consider trying is adding a 1-tick secondary data series to the script and submitting orders to that 1-tick secondary series.
See this forum thread for more information about intrabar granularity: http://ninjatrader.com/support/forum...297#post491297
Note that if you are running the strategy live, the order fills would be determined according to market dynamics which is not something that could be avoided.
When backtesting a strategy, order fills are not determined by market dynamics. These are filled based on logical rules from processing historical data.
When in historical data (backtesting), only the Open, High, Low, and Close will be available and there will be no intra-bar data. This means actions cannot happen intra-bar, fills cannot happen intra-bar. All prices and actions come from and occur when the bar closes as this is all the information that is known.
Because of this, OnBarUpdate will only update 'On bar close' as it does not have the intra-bar information necessary for 'On price change' or 'On each tick' and the script will not have the intra-bar information to accurately fill an order at the exact price and time.
Adding intrabar granularity to a script and enabling Tick Replay when backtesting could help improve the accuracy of a backtest.
Please reference the SampleIntrabarBacktest example and the following Help Guide links for more information.
SampleIntrabarBacktest 'Backtesting NinjaScript Strategies with an intrabar granularity' - https://ninjatrader.com/support/helpGuides/nt8/backtesting_ninjascript_strate.htm
TickReplay — https://ninjatrader.com/support/help...ick_replay.htm
Developing for Tick Replay -
https://ninjatrader.com/support/helpGuides/nt8/developing_for__tick_replay.htm?zoom_highlightsub= developing+for+tick+replay
Please review the help guide document on the differences on real-time vs backtest (historical).
<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
94 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
49 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
31 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
34 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
70 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment