Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom Indicator using Stochastics() values

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

    Custom Indicator using Stochastics() values

    Hi,

    I am unsuccessful at creating a custom indicator which uses compared Stochastics values. In the protected override void OnBarUpdate() section I do the following comparison in order to print a down arrow on my charts. This doesn't work.

    if ( Stochastics(7,14,3).K[0] < Stochastics(7,14,3).K[1] )

    Troubleshooting reveals that...

    if ( Stochastics(7,14,3).K[0] < 79 ) will print arrows on the charts.
    if ( Stochastics(7,14,3).K[1] < 79 ) won't print arrows on the charts.

    Looks like Ninjascript completely ignores the condition when the %K parameter is not set to .K[0]

    How do I go about making this work?

    - MarcusPlexus





    }

    #2
    MarcusPlexus, please add this line to the very beginning of your OnBarUpdate() section:
    Code:
    protected override void OnBarUpdate()
    {
        if (CurrentBar < 2)
            return;
        
        // all your other code goes here
    }
    I believe you are running into an issue where there actually aren't enough bars on the chart, and if so, there should be an error in the logs (right-most tab of Control Center) about accessing an invalid index.
    Last edited by NinjaTrader_Austin; 08-26-2010, 04:55 PM. Reason: wrong compare symbol
    AustinNinjaTrader Customer Service

    Comment


      #3
      Yes!!!!!!! That was it!

      Many thanks!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      27 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      117 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      69 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      226 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      417 views
      0 likes
      Last Post CaptainJack  
      Working...
      X