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