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

Low[0] High[0] input issue

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

    Low[0] High[0] input issue

    Hello,
    I've created an indicator that prints a line on the chart when certain conditions are met. The input for the line is Low[0]. For some reason, at certain times the line is being printed at the High[0]. Can someone please take a look at my code. I believe the issue is with the other indicator that I've created to use as a condition, but I can't figure out why that would change the input from Low to High.
    Thanks.
    Code:
    #region Variables
            private int triggerBar1 = -1;
            private int entryKillBar1 = -1;
            private double plotValue1 = 0;
            #endregion
    Code:
    protected override void Initialize()
            {
                Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "Low"));
                Overlay                = true;
            }
    Code:
    if(CurrentBar < 2)
                    return;
                
                double line_Prev = WilliamsR(RMI(BOP  (Close,10),14,3),8)[1];
                double line_Current = WilliamsR(RMI(BOP  (Close,10),14,3),8)[0];
                
                            
                if(line_Prev == 0 && line_Current < 0)
                {
                    this.triggerBar1 = CurrentBar;
                    this.entryKillBar1 = CurrentBar + 25;
                    this.plotValue1 = Low[0];
                    
                }
                
                 
                if (CurrentBar == this.entryKillBar1 + 1)
                {
                    this.triggerBar1 = -1;
                    this.entryKillBar1 = -1; 
                }    
                
            if (CurrentBar > this.triggerBar1 && CurrentBar <= this.entryKillBar1)
                {
                    Low.Set(this.plotValue1);
                    Print(Time[0]);
                    Print(Low[0]);
                    
                }
                else
                {
                    Low.Reset();
                }
    Attached Files

    #2
    Hello CaptainAmericaXX,

    Thank you for your inquiry.

    Was it intentional to set Low to "this.plotValue1" inside of your "if (CurrentBar > this.triggerBar1 && CurrentBar <= this.entryKillBar1)" conditional?

    You should not modify the Low DataSeries as this holds a collection of historical bar low prices.

    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      ZacharyG,
      Thank you for catching that error. Unfortunately that didn't solve this particular issue. Do you have any other thoughts on the matter?

      Comment


        #4
        Hello CaptainAmericaXX,

        I would suggest using Print() statements to check if you are getting expected values or not for your values. This can help narrow down what's going on and from there allow you to debug further.

        Here is a helpful link from the tips section of our support forum that details more about debugging: http://ninjatrader.com/support/forum...58&postcount=1

        Please, let me know if I can be of further assistance.
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          ZacharyG,
          Thanks for your reply. Before I started this thread I did do as you are suggesting and got the same results as this time. For some reason some of the Lows are printing as Highs.
          Here is the code.
          Code:
           if (CurrentBar > this.triggerBar1 && CurrentBar <= this.entryKillBar1)
                      {
                          Low.Set(plotValue1);//Green
                          Print(Time[0]);
                          Print(Low[0]);
                          
                      }
          Here is what the output window shows at the time of this particular instance.
          Code:
          9/2/2015 11:12:47 AM
          9/2/2015 11:15:07 AM
          110.9
          According to the Data Box the Low of that bar should be 110.7.

          I really do appreciate your help on this. That's about the extent of my debugging knowledge.
          Thanks
          Attached Files

          Comment


            #6
            Hello CaptainAmericaXX,

            In the code you have provided me in your previous post, it still looks like you are assigning the Low collection to a value. This will modify your Low values.

            I would suggest changing the name of your DataSeries from Low to something else so it will not conflict with the existing Low DataSeries, which holds a collection of historical low prices.

            Please comment out this line of code:
            Code:
            Low.Set(plotValue1);
            Do you experience the same?

            I would suggest reading this section in the help guide for more information about developing indicators: http://ninjatrader.com/support/helpG...indicators.htm

            Please, let us know if we may be of further assistance.
            Zachary G.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            7 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            18 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            4 views
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            12 views
            0 likes
            Last Post Javierw.ok  
            Started by timmbbo, Today, 08:59 AM
            2 responses
            13 views
            0 likes
            Last Post bltdavid  
            Working...
            X