Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ADX Strategy not working

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

    ADX Strategy not working

    Hello,

    I have created a code and one of the conditions is that it enters a position when the ADX exceeds the 45 level. During backtesting it works great, but when live testing it doesn't. Please find below my code and attached screenshot of the trades the strategy took live. I have marked the short entries in red and the longs in green. My CalculateOnBarClose() is set to true.

    PHP Code:
     if (ADX(MyADX)[0] > 45
                    && ATR(MyATR)[0] < MyATRLevel                                    
                        && CrossBelow(RSI(MyRSI, 1).Avg, MyLowerLevel, 1)    
                            && Position.MarketPosition == MarketPosition.Flat)  
                {    
                    Print(MyATRLevel);
                    MyPositionSize = (int) (myRiskAmount / 0.002);
                    EnterLong(MyPositionSize, "Enter long");                            // Enter long
                } 
    
    Any ideas?

    Thanks.
    Attached Files

    #2
    Hello Bruin813,

    Thank you for writing in and welcome to the NinjaTrader Support Forum!

    I notice that there is a (D) next to the name of your strategy on the chart. This would mean that the strategy is disabled.

    Have you enabled the strategy when you have added it to the chart?

    Right-click on your chart and select Strategies.

    Select your strategy and ensure the Enabled option within the General category is set to True. Then, click OK.

    Please let me know if your strategy still has not traded when ensuring it was enabled.
    Last edited by NinjaTrader_ZacharyG; 07-23-2016, 12:10 PM.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Dear Zachary,

      Thanks for the quick response.

      The strategy has been working last week. The screenshot is from today, so that explains why the strategy is disabled.

      Comment


        #4
        Hello,

        Did anyone of the support team had a chance to look at my question?

        Thanks.

        Comment


          #5
          Hello Bruin813,

          What debugging steps have you already done with your strategy?

          Have you added print statements to your strategy to check if your conditions are becoming true in real-time?

          In the strategy add prints that print the values of every variable used in every condition that places an order along with the time of that bar.

          This will print to the output window.

          Below I am providing a link to a video that demonstrates adding prints to a script to get further information about the behavior of the script.



          Are you seeing your conditions becoming true but the strategy not entering?
          Zachary G.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          649 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          370 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          109 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          574 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          576 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X