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 Aviram Y, Today, 05:29 AM
              0 responses
              1 view
              0 likes
              Last Post Aviram Y  
              Started by quantismo, 04-17-2024, 05:13 PM
              3 responses
              25 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by ScottWalsh, 04-16-2024, 04:29 PM
              7 responses
              34 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by cls71, Today, 04:45 AM
              0 responses
              6 views
              0 likes
              Last Post cls71
              by cls71
               
              Started by mjairg, 07-20-2023, 11:57 PM
              3 responses
              216 views
              1 like
              Last Post PaulMohn  
              Working...
              X