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 argusthome, 03-08-2026, 10:06 AM
      0 responses
      66 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      41 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      24 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      27 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      53 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X