Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

No Plot issue

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

    No Plot issue

    I am trying to plot on a zero line in say panel 2 when certain conditions are met in panel 1.
    My code looks for an inside bar or an outside bar and should plot a black dot when this occurs.

    If I remove the condition I get a plot at zero otherwise I get nothing.
    Can someone point me in the right direction?

    Code:
            protected override void Initialize()
            {
                Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
    		    Add(new Plot(Color.FromKnownColor(KnownColor.Black), PlotStyle.Dot, "Plot1"));
    	
                CalculateOnBarClose	= true;
                Overlay				= false;
                PriceTypeSupported	= false;
            }
    
            protected override void OnBarUpdate()
            {
    				int insidebar = 0;
    			int outsidebar = 0;
             	if(High[0] <= High[1] && Low[0] >= Low[1])	//Inside Bar
    			{insidebar = 1; }
    	
    		if( High[0] >= High[1] && Low[0] <= Low[1]	)//Outside Bar
    			{outsidebar = 1;}
             if (insidebar > 0 || outsidebar > 0)
    		{Plot1.Set(1);}
    		Plot0.Set(0);
            }

    #2
    Mindset,

    If you have a condition and it does not give you the dot this would be an indication of your condition not being true. Please check your conditions. Also bear in mind that you need to check that you have enough bars for your code to work.

    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Condition met

      I have another indicator overlayed on price that plots the same and that works so it isn't the condition statement.

      Comment


        #4
        Using another indicator is not a good measure. Please work within the indicator and use Print statements to debug. Look for errors in your Control Center logs as well.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          error

          on calling the onBarUpdate method - index was out of range. Must be non negative and less than the size of the collection.

          I am using 1 and zero and the OHLC so how can I be out of range?

          Comment


            #6
            Originally posted by Mindset View Post
            I am using 1 and zero and the OHLC so how can I be out of range?
            A quick out of range example: on the 1st bar (index 0), it tries checking the previous bar (index -1). Index -1 does not exist.

            A simple solution would be to add this at the top of OnBarUpdate():
            Code:
            OnBarUpdate()
            {
                 if (CurrentBar < 1)
                     return;
            
                // all your other OnBarUpdate code
            }
            This thread provides a more detailed explanation.
            AustinNinjaTrader Customer Service

            Comment


              #7
              Thanks

              That is just so obvious - Thanks Austin.
              I could not for the life of me see what the problem was!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              599 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              345 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              103 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              558 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              558 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X