Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

If Statements Problem

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

    If Statements Problem

    Dear Ninjatrader-Community,

    I am trying to create an Indicator which assigns values to the input data. Therefore I tried to build an if statement combined with an else if command. The code is correct but it does not show these values when I plot the Indicator on the chart. Can someone help me ?

    the Code :



    protected override void OnBarUpdate()
    {

    if (Close[0] < 27)
    {return ;
    Value[0]=3;
    }

    else if (Close[0] > 28)
    { return;
    Value[0]= 4;
    }


    }

    #2
    Hello muratb35,

    Thank you for the post.

    The reason this code is not working would be the return statements. The word return is meant to stop the code execution at that point and return the method. Code past that point is no longer executed so those won't be needed in this use case.

    if (Close[0] < 27)
    {
    Value[0]=3;
    }

    else if (Close[0] > 28)
    {
    Value[0]= 4;
    }
    You can find some indicator examples in the help guide, you can also see some of the less complex indicators like SMA or EMA for examples of plotting. Here is a link to one example of plotting in the help guide: https://ninjatrader.com/support/help...ored_plots.htm



    I look forward to being of further assistance.

    Comment


      #3
      Thanks Jesse ! This helped me a lot !

      Comment

      Latest Posts

      Collapse

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