Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategies ignore conditions and filters

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Strategies ignore conditions and filters

    I have code for both a long and a short in which I have noticed when live or even in the backtest at times it will completely ignore the parameters of the strategy and take a trade. I had to separate the two strategies because when they were in one file, NT8 would completely ignore either the short side or the long side the entire time. A bit confused because it seems to be fine on paper but don't know why conditions are straight up being ignored when the condition is set to all.

    The main issue I have noticed is that it will take a long when in a downtrend. In what I have coded, price needs to close above linear regression, linear intercept and the wave line. Additionally, linear regression needs to close above the intercept and wave line. As I was writing this post, it took a long with this exact issue.

    To provide a better filter, I also include a BBMACD and Stochastic in which it seems to ignore those filters as well.

    In terms of the input lengths on long I provide it is:
    BBPX: 21
    LIX: 12
    LRX: 12
    MFPX: 8
    MSMPX: 9
    MSPX: 17
    SDX: 3
    SKX: 8
    SMX: 4
    ZOMX: 18
    Attached Files

    #2
    Hello VinnyJalapeno,

    Thanks for your post.

    A NinjaScript strategy will not place an order unless the condition to place an order becomes true.

    I see that you have not added prints to the script to understand how the logic in the script is evaluating. To understand why the script is behaving as it is, such as placing orders or not placing orders 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).

    Also, enable TraceOrders which will let us know if any orders are being ignored and not being submitted when the condition to place the orders is evaluating as true.

    Below is a link to a forum post that demonstrates how to use prints to understand behavior.
    https://ninjatrader.com/support/foru...121#post791121​​
    <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


      #3
      I unlocked my long version and added Trace Order along with printing code. It did not change any of my results and seemed to have messed with the trades a bit more. NinjaScript output did not provide any insight as to why the trades were being taken. As I once said before I can visually see what the issue is and I can see that my code is not even coded to set to allow that. I am not an advanced coder and use the StrategyBuilder a lot in which it's basic coding is still being violated.
      Script violates the basic rule of taking a long when it is in a clear downtrend and all indicators are going down when the basic inputs would require a close to be higher than x indicator. This really isn't a complicated script...
      Attached Files

      Comment


        #4
        Hello VinnyJalapeno,

        Thanks for your note.

        Adding debugging prints to the script and enabling TraceOrders will not change the results of your strategy.

        Debugging prints will allow you to see if/when all of your conditions used to place the trade is becoming true or not. This allows you to confirm if the strategy is submitting orders when the condition to do so it true or not.

        Enabling TraceOrders will tell you if any orders are being ignored and not being submitted when the condition to place the orders is evaluating as true. The debugging prints would tell you if the conditions to place the orders is true.

        Are you seeing in the NinjaScript Output window that trades are being placed when all of the conditions to place the trade are not true? If so, please share the NinjaScript Output prints showing that an order was placed but the conditions to place the order were not true and the exact time this occurred in the output.

        When the output from the output window appears and you see that the conditions to place a trade are false but an order was placed, save this by right-clicking the output window and selecting Save As... -> give the output file a name and save -> then attach the output to your reply along with the exact time it occurred.

        You could add another print to the script inside the condition to place the order, after you Entry order method, to confirm if that condition was triggered.

        Note that it is against our policy to debug a custom script on your behalf. It would be up to you to debug your custom strategy. I can assist by demonstrating how to use TraceOrders, create specific prints you are having trouble with creating, looking at the output window to understand the behavior of a script, and assist with analyzing the output from your script and provide insight about the specific behavior of your inquiry.

        <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 NullPointStrategies, Today, 05:17 AM
        0 responses
        20 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        119 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        63 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        41 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        45 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X