Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Use Indicator Levels for Order Entry

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

    Use Indicator Levels for Order Entry

    I am new to writing strategies. I want to enter a long position if a bar opens above an indicator level, in this case I am using a variant of the ADX indicator.

    Am I checking the levels correctly? No orders are placed when I try to optimize the strategy.

    Here's my code snippet:

    _ADXVMA_Alerts_v01_5 adxvma = _ADXVMA_Alerts_v01_5(iPeriods, bConservative);

    ManageOrders();

    if (Position.MarketPosition != MarketPosition.Flat) return;

    if (Rising(adxvma) && (CrossAbove(Open[0], adxvma.Rising, 0))) {
    GoLong();
    }
    else if (Falling(adxvma) && (CrossBelow(Open[0], adxvma.Falling, 0))) {
    GoShort();
    }

    This works if I only use the first part of the if statement: Falling(adxvma).

    I will be adding more conditions so I need to learn the best way to test for these indicator levels.

    Thanks,

    Ned

    #2
    Hello Ned,

    Thank you for your post.

    I see no issue with your logic. Please try adding Print() when the conditions are tru and print the Time[0] to compare on the chart if you are truly seeing a rising or falling and cross condition at the same time.

    For information on Print() please visit the following link: http://www.ninjatrader.com/support/h.../nt7/print.htm
    This will provide information in the Output window (Tools > Output).
    For information on Time please visit the following link: http://www.ninjatrader.com/support/h...s/nt7/time.htm

    Please let me know if you have any questions.

    Comment


      #3
      Originally posted by nedrob519 View Post
      I am new to writing strategies. I want to enter a long position if a bar opens above an indicator level, in this case I am using a variant of the ADX indicator.

      Am I checking the levels correctly? No orders are placed when I try to optimize the strategy.

      Here's my code snippet:

      _ADXVMA_Alerts_v01_5 adxvma = _ADXVMA_Alerts_v01_5(iPeriods, bConservative);

      ManageOrders();

      if (Position.MarketPosition != MarketPosition.Flat) return;

      if (Rising(adxvma) && (CrossAbove(Open[0], adxvma.Rising, 0))) {
      GoLong();
      }
      else if (Falling(adxvma) && (CrossBelow(Open[0], adxvma.Falling, 0))) {
      GoShort();
      }

      This works if I only use the first part of the if statement: Falling(adxvma).

      I will be adding more conditions so I need to learn the best way to test for these indicator levels.

      Thanks,

      Ned
      To optimize parameters, they must be parameters. Where, and how have you exposed, as public, the parameters that you want to optimize?

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      648 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      572 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X