Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stochastics not being correctly "calculated" in strategy

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

    Stochastics not being correctly "calculated" in strategy

    Sorry if this sounds completely stupid, but I have this simple line of code in a new strategy:

    Code:
    if 
              (Stochastics(7, 14, 3).K[0] > 90)
              {
                DrawDot("Dot"+CurrentBar.ToString(), true, 0, High[0] + (TickSize * 4), Color.Red);
                Print ("Stoch: ");        
                Print (Stochastics(7,14,3).K[0]);
                }
    It's just a basic line to test the functionality and confirm that the numbers are all right. Thing is, they're not. Firstly, no dots appear, even though plenty of bars have a K value higher than 90. And the Output Window displays a variety of Stoch values, but none of them match the actual bars, and several of them are above 90. So somewhere on the chart, I should see some dots, but I do not. 90 days of data and not one dot. If I change the condition to be > 20, then pretty much every bar shows a dot, even those that do not meet the condition (i.e., a Stoch K value of, say, 15). Doesn't make sense, but the strategy is somehow getting/using Stochastic information that's different than the Stochastic values that are being displayed on the chart and in the Data Box.

    What am I doing wrong? I've written dozens of strategies, all using exactly this same syntax (I swear some of them had Stochastics in them), and they've worked great. If I replace Stochastics in this strategy with any other indicator, everything checks out and matches up, and dots are painted exactly where they should be. There aren't any date-related issues, as this CL 02-14 chart is the only one I have open. It's not a sequence issue, as none of the consecutive values that show up in the Output Window match up with any of the consecutive bars on the chart in any combination at any point in time. This problem occurs whether I use the wizard or code it manually, and it happens the same whether it's a minute, range or Renko chart.

    Thanks in advance,
    Gary
    Last edited by hawks67; 01-08-2015, 08:37 AM.

    #2
    Gary,

    Using just the snippet I do not get any errors with the Dots. They are appearing as they should be in the correct spots.

    Is this all you have in your code? or are there other items?

    Would you be willing to post here so I can review it?

    Additionally, all values are matching up on my end as well.

    Please provide a screenshot of your setup -
    To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file. Click Reply -> Go Advanced -> Paperclip icon in the toolbar

    For detailed instructions please visit the following link

    How to take a screenshot on your smartphone, tablet, notebook or desktop computer
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Cal, I can't explain what I did... I was cleaning up commented code - nothing more - in preparation for sending and now it works. I know that's not possible, but...

      Sorry for cluttering up the forum. Feel free to delete this thread.

      Thanks,
      Gary

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      633 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      364 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      567 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      568 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X