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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        63 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        89 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        47 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        105 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        63 views
        0 likes
        Last Post PaulMohn  
        Working...
        X