Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

i want to add this to my stochastic indicator

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

    i want to add this to my stochastic indicator

    Hey I need help adding this code to my stochastic indicator and making it plot on the chart


    if (CurrentBar < 0)
    return;


    if (K[0] > K[1] & K[0] > k[-1] & D > 50);

    #2
    Hello jamelle29673,

    Thanks for your post.

    The example code you shared could be added to your indicator script in the OnBarUpdate() method.

    The CurrentBar check would ensure that there are bars processing on the chart for the primary data series.

    The other code you shared would be a condition. If K[0] and D[0] are plots, this would be a condition that compared those plot values. You could then set an action to occur for when that condition becomes true.

    See the help guide documentation below for more information.
    CurrentBar: https://ninjatrader.com/support/help...currentbar.htm
    AddPlot: https://ninjatrader.com/support/help...t8/addplot.htm

    Let us know if we may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Here's what I came up with but im getting an error code CS0019. I dont know what im doing wrong.

      if (CurrentBar < 1)
      return;

      if
      ((K[0] > K[1])
      && (K[0] > K[-1])
      && (D > 50));
      {
      Plots[2].Brush = Brushes.Blue;
      Plots[2].Width = 2;
      }
      }

      }


      #region Properties
      [Browsable(false)]
      [XmlIgnore()]
      public Series<double> Kdiv
      {
      get { return Values[2]; }
      }

      Comment


        #4
        Hello jamelle29673,

        Thanks for your note.

        This error message means that you are attempting to compare strings to other objects using relational operators in your script.

        Strings cannot be compared with relational operators (<, >, <=, >=, ==, !=) to other object types. Strings can only be compared to other strings and only through the use of equality operators (==, !=).

        See this help guide for more information about the error code CS0019: https://ninjatrader.com/support/help...nt8/cs0019.htm

        Let us know if we may assist further.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        646 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        367 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
        569 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