• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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).
    Patrick H.NinjaTrader Customer Service

    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.
        Patrick H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by YevhenShynkarenko, Yesterday, 01:22 AM
        2 responses
        36 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by testingsarasa, 05-20-2018, 02:50 PM
        11 responses
        733 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by martyn73, Today, 05:27 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by MichaelAlexander, 02-22-2017, 05:06 AM
        5 responses
        1,402 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by walter739, Today, 11:56 AM
        3 responses
        11 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X