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