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

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 geddyisodin, Today, 05:20 AM
              5 responses
              32 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by bmartz, Today, 09:30 AM
              2 responses
              12 views
              0 likes
              Last Post bltdavid  
              Started by f.saeidi, Today, 11:02 AM
              1 response
              4 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by geotrades1, Today, 10:02 AM
              4 responses
              12 views
              0 likes
              Last Post geotrades1  
              Started by rajendrasubedi2023, Today, 09:50 AM
              3 responses
              16 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Working...
              X