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

oscillator not plotting

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

    oscillator not plotting

    Hello

    I am trying to create an oscillator but it is not plotting anything. The Data Window says N/A.

    I have printed all of the values to the Output Window and everything is printing correctly there so I assume that it is something in the way that I have told NT to write to the chart. But I can not find my error. Could you please help me with that?

    I really appreciate it. I have highlighted and made bold the areas that I think are important for creating it to make it easier for you to see.

    Thanks!

    Code:
            protected override void Initialize()
            {
               [COLOR="red"][B] Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
                Add(new Line(Color.FromKnownColor(KnownColor.DarkOliveGreen), 0, "Distance"));
                Overlay				= false;[/B][/COLOR]
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
    			if (CurrentBar <= 4)
    			{
    				return;
    			}
    			
    			if ((High[0] < High[2]
    				&& High[1] < High[2]
    				&& High[3] < High[2]
    				&& High[4] < High[2])
    				|| (High[0] < High[2]
    				&& High[1] == High[2]
    				&& High[3] < High[2]
    				&& High[4] < High[2]))
    			{
    				swingHigh = High[2];
    			}
    			
    			if ((Low[0] > Low[2]
    				&& Low[1] > Low[2]
    				&& Low[3] > Low[2]
    				&& Low[4] > Low[2])
    				|| (Low[0] > Low[2]
    				&& Low[1] == Low[2]
    				&& Low[3] > Low[2]
    				&& Low[4] > Low[2]))
    			{
    				SL1 = true;
    				SLValue1 = Low[2];
    				Print("SLValue1 = " + SLValue1);
    			}
    			
    			if ((SL1 == true
    				&& Low[0] > Low[2]
    				&& Low[1] > Low[2]
    				&& Low[3] > Low[2]
    				&& Low[4] > Low[2])
    				|| (SL1 == true
    				&& Low[0] > Low[2]
    				&& Low[1] == Low[2]
    				&& Low[3] > Low[2]
    				&& Low[4] > Low[2]))
    			{
    				SL2 = true;
    				SLValue2 = Low[2];
    				Print("SLValue2 = " + SLValue2);
    			}
    			
    			if (SL1 == true
    				&& SL2 == true
    				&& swingHigh > 0)
    			{
    				distance = swingHigh - SLValue1;
    				Print(distance *10000);
    				[B][COLOR="Red"]Plot0.Set(distance * 10000);[/COLOR][/B]
    				swingHigh = 0;
    				SL2 = false;
    				SLValue1 = SLValue2;
    				Print("Submit Oscillator");
    			}
    			
    
    			
               
            }

    #2
    jg123, you're likely not setting a value here for every bar, so hard to see when using line style. Have you checked on another plotstyle like bar for example?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Okay, that is something that I hadn't considered.

      I changed to PlotStyle.Bar and that didn't make any changed to what I see on the chart.

      I attached the file if that helps the situation at all.
      Attached Files

      Comment


        #4
        jg123, please give the one attached a try, made some minor changes to it. Plots for me on Bar style.
        Attached Files
        BertrandNinjaTrader Customer Service

        Comment


          #5
          NT is not allowing the import because it is not a zip file. is there another way to import just the .cs file?

          Comment


            #6
            You can just copy it into your Documents > NinjaTrader7 > bin > custom > indicator folder and compile all files in NT then.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Thank you very much.

              I see the small changes that you made and I appreciate those. It helps me learn

              There are some other changes that I need to make to this indicacator in order to make it work correctly as it still has some bugs that I can now see.

              In the process of debugging this indicator, I would like to change where the line is plotted. For now, I would like to have it plot 2 bars ago, but my current method for trying to do that is not working and I can't find the documentation to make that change. Here is what I am currently trying to do:

              Code:
              Plot0.Set(distance * 10000)[2];
              or

              Code:
              Plot0.Set[2](distance * 10000);
              but neither are working. Could you please let me know how to have it plot 2 bars ago.

              In the future, though, when I have all of the bugs worked out, I will actually want to plot this indicator below the highest swingHigh which would be constantly changing in the number of bars back. Could you point me in the right direction for how to tell it to plot it below that bar?

              Thanks

              Comment


                #8
                jg123, there's a signature for the data series set as well to set a prior value, you could for example work with -

                Plot0.Set(2, distance * 10000);

                For the last question, it sounds like you would need to keep track of the highest SwingHigh then and use that as plot series value to which apply your distance factor to?
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  This was good information. Thank you.

                  I will probably have some more questions as I am ready to move into that next portion

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Rapine Heihei, Today, 08:19 PM
                  1 response
                  3 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by Rapine Heihei, Today, 08:25 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post Rapine Heihei  
                  Started by f.saeidi, Today, 08:01 PM
                  1 response
                  4 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by Rapine Heihei, Today, 07:51 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post Rapine Heihei  
                  Started by frslvr, 04-11-2024, 07:26 AM
                  5 responses
                  96 views
                  1 like
                  Last Post caryc123  
                  Working...
                  X