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 CarlTrading, Yesterday, 09:41 PM
      1 response
      20 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, Today, 02:41 AM
      0 responses
      6 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, Yesterday, 11:44 PM
      0 responses
      17 views
      0 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      33 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      32 views
      0 likes
      Last Post CarlTrading  
      Working...
      X