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 jeronymite, 04-12-2024, 04:26 PM
        3 responses
        39 views
        0 likes
        Last Post jeronymite  
        Started by bill2023, Today, 08:51 AM
        2 responses
        15 views
        0 likes
        Last Post bill2023  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        167 responses
        2,260 views
        0 likes
        Last Post jeronymite  
        Started by warreng86, 11-10-2020, 02:04 PM
        7 responses
        1,362 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Perr0Grande, Today, 08:16 PM
        0 responses
        5 views
        0 likes
        Last Post Perr0Grande  
        Working...
        X