Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bug in Ninjatrader7?

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

    Bug in Ninjatrader7?

    Hi!
    Try this indicator named 'ninjaBug'

    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {

    [Description("Ninja -Bug Exposed")]
    public class ninjaBug : Indicator
    {
    #region Variables

    private DataSeries mydataseries;
    #endregion


    protected override void Initialize()
    {
    Overlay = true;
    mydataseries = new DataSeries(this);
    }

    protected override void OnBarUpdate()
    {
    if (CurrentBar < 10)
    return;
    mydataseries.Set(High[0] - Low[0]);

    if (mydataseries[-1] > mydataseries[0] && mydataseries[2] > mydataseries[1])


    DrawArrowDown(mydataseries[0].ToString(), true, 0, High[0] + TickSize, Color.Red);
    Simple code. No compilation error. Apply this indicator on your chart
    NINJATRADER WILL CRASH!!
    Now re-phrase if condition like this

    if (mydataseries[2] > mydataseries[1] && mydataseries[-1] > mydataseries[0])

    it is one and same but shuffled. Compile it. and apply indicator - It will work and plot arrow

    #2
    baqer110,

    So this is what you refer to in your previous thread: http://www.ninjatrader.com/support/f...ad.php?t=81865

    I would not recommend accessing -1 in the DataSeries, it has no values yet. While this may work on historical bars, in real-time this is going to cause issues like crashing.

    Refer to my other response to you on accessing values ahead of the current bar: http://www.ninjatrader.com/support/f...ad.php?t=81780
    You will notice in the sample I completely ignored your idea of using negative indexes and went back the required or needed number of bars (2 for the index in that example).

    Comment


      #3
      Originally posted by NinjaTrader_PatrickH View Post
      baqer110,

      So this is what you refer to in your previous thread: http://www.ninjatrader.com/support/f...ad.php?t=81865

      I would not recommend accessing -1 in the DataSeries, it has no values yet. While this may work on historical bars, in real-time this is going to cause issues like crashing.

      Refer to my other response to you on accessing values ahead of the current bar: http://www.ninjatrader.com/support/f...ad.php?t=81780
      You will notice in the sample I completely ignored your idea of using negative indexes and went back the required or needed number of bars (2 for the index in that example).
      Thanks a lot and I really do appreciate your valuable time given to me
      My point was that both "if statements are one and same" Only difference is in one "if" condition [-] index is used first and applied to chart and NT crashes. In second one [-] applied in the 2nd condition and applied to chart. It worked well and NT didn't crash.
      You are right. I was applying [-] to find short/medium term/long term high low. For short term no problem. For medium term I had to use loop to separate short term high from the private series. Look back loop worked ok but look forward had to use negative [-] . Compilation no error but NT was crashing.
      The code you have sent me I imported to NT and applied to chart. Its not plotting anything. No compilation error. I am studying the to find out the problem. Can you please apply at your end and guide me?
      Once again I do appreciate your valuable time

      Comment


        #4
        Hello baqer110,

        Thank you for your response.

        The behavior that you see would somewhat be unexpected no matter as the negative index on a DataSeries is not really accurate in this case. So it may work or it may not. I will follow up on the other post.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by firefoxforum12, Yesterday, 08:53 PM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by kmunroe478, Yesterday, 05:39 PM
        2 responses
        14 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by kevinenergy, 02-17-2023, 12:42 PM
        115 responses
        2,699 views
        1 like
        Last Post kevinenergy  
        Started by prdecast, Today, 06:07 AM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by Christopher_R, Today, 12:29 AM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Working...
        X