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 sjsj2732, Yesterday, 04:31 AM
      0 responses
      30 views
      0 likes
      Last Post sjsj2732  
      Started by NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      286 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      282 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      132 views
      1 like
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      90 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Working...
      X