I'm trying to develop a strategy using the yellow and blue lines in the attached file. Basically, when the yellow line crosses above the blue line, execute long trades. When crossing down, enter short trades. I guess there are certain times when the yellow line takes awhile to decide if it's going to cross up or down and NT keeps executing and cancelling trades in these spots and loses alot of money. Is there a filter I can add to prevent NT from entering trades during these times? This is trading one contract. Thanks for your help!
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Strategy with Crossing EMA's
Collapse
X
-
Strategy with Crossing EMA's
Hi,
I'm trying to develop a strategy using the yellow and blue lines in the attached file. Basically, when the yellow line crosses above the blue line, execute long trades. When crossing down, enter short trades. I guess there are certain times when the yellow line takes awhile to decide if it's going to cross up or down and NT keeps executing and cancelling trades in these spots and loses alot of money. Is there a filter I can add to prevent NT from entering trades during these times? This is trading one contract. Thanks for your help!Tags: None
-
Hello alnghiem,
Thanks for your post.
A bool could be used to control when trades are made by the strategy. You could create a bool named something like OkToTrade (initially set to false). You would create your order entry condition and set the bool to true. Then you would check if the bool is true and call your entry order method and set the bool to false.
By doing this, the order entry method will only be called to place an order when the bool is true. When the bool is false, the order entry condition will not be called so the strategy will stop placing trades until the bool becomes true. See the attached example script demonstrating this.
Ultimately, To understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.
In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar. Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).
Below is a link to a forum post that demonstrates how to use prints to understand behavior.
https://ninjatrader.com/support/foru...121#post791121
Let us know if we may assist further.Attached Files<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>
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
62 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
134 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
75 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
50 views
0 likes
|
Last Post
|

Comment