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 charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      52 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      142 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      160 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      96 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      276 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X