Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

indicator-behaviour

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

    indicator-behaviour

    Hallo,

    I have coded an indicator(indi2) that calulates values based on another indicator (indi1).
    Whenever indi1 doesn't contain values, indi2 automatically uses Close-values instead.
    That's absolutely unwanted and it seems like it's
    a problem due to the indicator class in general.

    I want indi2 not to be calculated if values for indi1 do not exist. Is there a way to switch
    that automatic use of Closes off?

    Here is an example to illustrate the problem:

    indi1:

    if (CurrentBar>=200)
    {
    Plot0.Set(1);
    }
    else
    {return;}

    Applied to a chart the indicator plots nothing before bar no. 200, after it it plots 1.

    indi2:

    Plot0.Set(Testindi1()[0]);

    I would expect and want indi2 to do the same as indi1.
    But what happens is that the value of the current Close is plotted before bar number 200.

    Any suggestions to get rid of/suppress that behaviour?

    Thanks in advance,
    Stephan

    #2
    Hello,

    Thanks for the forum post.

    This is expected and added in to prevent against a null value. You must always have a value in a data series. If you do not have a value set NinjaTrader will automatically assign the close price so that you do not error the program.

    Therefor if your not setting the data series then you must set it with another value that makes since in an off position. Then code indicator 2 to recognize this off position value and then you can take some action in indicator 2 for that.

    However with indicators in NinjaTrader you cannot have an empty data series and NinjaTrader will guard against this with the close price.


    Let me know if I can be of further assistance.

    Comment


      #3
      I suppressed assigning Close-values with the following syntax:

      if (Testindi1().Value.IsValidPlot(CurrentBar))
      {
      //calculate Testindi2

      Seems to work now.
      In strategies where indi2 is applied I probably can do the same.
      }
      }

      Comment


        #4
        Hello,

        Ah Yes this is a check from a hosted indicator is needed if the plot is not set. More information can be found in this sample if you need it though it seems you found the information needed.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by RubenCazorla, 08-30-2022, 06:36 AM
        3 responses
        77 views
        0 likes
        Last Post PaulMohn  
        Started by f.saeidi, Yesterday, 12:14 PM
        9 responses
        23 views
        0 likes
        Last Post f.saeidi  
        Started by Tim-c, Today, 03:54 AM
        0 responses
        3 views
        0 likes
        Last Post Tim-c
        by Tim-c
         
        Started by FrancisMorro, Today, 03:24 AM
        0 responses
        5 views
        0 likes
        Last Post FrancisMorro  
        Started by Segwin, 05-07-2018, 02:15 PM
        10 responses
        1,772 views
        0 likes
        Last Post Leafcutter  
        Working...
        X