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

Calling Last Plot

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

    Calling Last Plot

    Hi,

    How do I call the last plot of an indicator? not the last value from say n-bars ago? just the last time the plot was plotted (for an indicator that only plots on certian bars)

    Thanks for any help,

    R.T.

    #2
    Hello R.T,

    You may be able to work with ContainsValue() for this.

    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks Ryan,

      will work on it over the weekend... rather then start another thread... I am having trouble getting a basic plot to compile... if you can help, or if you rather have me start a new thread let me know...

      I am trying to create a plot for
      Plot0.Set(Low[2] > Low[1] && Low [1] < Low[0]);

      This will not compile though and I do not understand why? I get and "arugment 1" error and something about the double and bool but it reads the same to me as others I have compiled in the same manner before...

      Thanks for any help,
      R.T.

      Comment


        #4
        Your expression in the "Set" brackets is a boolean value: Plots values must be doubles. You might want to cast your bool to a double, probably most understandably by using a separate line to create a double if the condition is true, and then setting the plot to that double value.

        Code:
        double DesiredValue = (Low[2] > Low[1] && Low [1] < Low[0]) ? 1.0 : 0;
        Plot0.Set(DesiredValue);
        Of course, you could always just put your assignation statement directly in the Plot statement. It just would look more formidable to understand a few months from now when you come to look at the code again to modify it, if you so choose to do.

        I have never tried to directly cast a bool to a double, as I have never found it necessary so far, but it might also be worth looking into, as an alternative.

        Comment


          #5
          Thanks Koganam! I appreciate the help!

          The code works just like I want but is there a way to get the plot to plot under the bar which meats the requirements? Right now it creates the plot in a separate window for 1 = true and 0 = false but I just want it to plot a dot or triangle under the bars which are "true"... This code is great though because I can use it in market analyzer which I need also...

          Thanks!

          Comment


            #6
            Originally posted by tshirtdeal View Post
            Thanks Koganam! I appreciate the help!

            The code works just like I want but is there a way to get the plot to plot under the bar which meats the requirements? Right now it creates the plot in a separate window for 1 = true and 0 = false but I just want it to plot a dot or triangle under the bars which are "true"... This code is great though because I can use it in market analyzer which I need also...

            Thanks!
            Code:
            if (DesiredValue == 1) DrawDot(CurrentBar.ToString(), false, 0, Low[0] - (TickSize * 10), Color.Green)
            is one way. You may want to adjust the TickSize multiplier in order to place the dot conveniently.

            More often, as I prefer to place my drawings with more precision, I would use DrawText, as that allows me to resize the dot, and also place it at a fixed pixel offset from the low, independent of TickSize or other considerations.

            Comment


              #7
              Thanks so much koganam! that really works great for me! Pretty much got what I needed, except for some reason it will not plot on the incoming bar with caculateonbarclose = false... not sure why....

              Thanks for the help! I really appreciate it!

              Comment


                #8
                ha, nevermind I got it.... I was (added to your code) a command for the MASlopePlot indicator and it is built on "cacualteonbarclose = true" so I guess the indicator had to wait for the bar to close, I changed the indicator script to "false" and compiled it and now this indicator works perfect!

                very awesome and thanks so much!

                BTW, is there a way to set an indicators "caculateonbarclose = false when you call it in a script or do you have to change the original script?

                Comment


                  #9
                  Originally posted by tshirtdeal View Post
                  ha, nevermind I got it.... I was (added to your code) a command for the MASlopePlot indicator and it is built on &quot;cacualteonbarclose = true&quot; so I guess the indicator had to wait for the bar to close, I changed the indicator script to &quot;false&quot; and compiled it and now this indicator works perfect!

                  very awesome and thanks so much!

                  BTW, is there a way to set an indicators &quot;caculateonbarclose = false when you call it in a script or do you have to change the original script?
                  Create a new boolean property and assign it to CalculateOnBarClose in either the OnStartUp() or OnBarUpdate() method.

                  As it is a property, you can call the indicator with it set to whatever you want.
                  Last edited by koganam; 05-22-2011, 01:59 PM.

                  Comment


                    #10
                    Okay, got it! thanks again... I'm gonna be one last pain in your A** ... what method can I use to limit the indicator plots... it currently plots the dot on every bar which meets the requirements over the timeperiod and days of the chart, I know with "Draw" objects that is very CPU heavy and I really only need the plot on the bar it occurs for live trading...

                    I know there is a Plot(Reset) but this has no plot, is there a way to limit the plot for say the last couple of times on the chart? if that makes any sense... I've tried to find something but can't get anything to work...

                    Thanks for any help!

                    Comment


                      #11
                      Originally posted by tshirtdeal View Post
                      Okay, got it! thanks again... I'm gonna be one last pain in your A** ... what method can I use to limit the indicator plots... it currently plots the dot on every bar which meets the requirements over the timeperiod and days of the chart, I know with "Draw" objects that is very CPU heavy and I really only need the plot on the bar it occurs for live trading...

                      I know there is a Plot(Reset) but this has no plot, is there a way to limit the plot for say the last couple of times on the chart? if that makes any sense... I've tried to find something but can't get anything to work...

                      Thanks for any help!
                      If you want to limit your drawing to live trading only:

                      Code:
                      if (!Historical) DrawDot( ...)
                      The other option is to use a second plot, instead of the DrawDot, where you only set the plot (at Low[0] - TickSize * 10), when the condition is true, and reset the plot otherwise.

                      Comment


                        #12
                        man I knew it was something simple... that works great, project done for now... just what I needed...

                        I can't thank you enough for the help! I learned a ton doing this so thanks again!

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Tim-c, Today, 02:10 PM
                        1 response
                        6 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by Taddypole, Today, 02:47 PM
                        0 responses
                        2 views
                        0 likes
                        Last Post Taddypole  
                        Started by chbruno, 04-24-2024, 04:10 PM
                        4 responses
                        50 views
                        0 likes
                        Last Post chbruno
                        by chbruno
                         
                        Started by TraderG23, 12-08-2023, 07:56 AM
                        10 responses
                        399 views
                        1 like
                        Last Post beobast
                        by beobast
                         
                        Started by lorem, Yesterday, 09:18 AM
                        5 responses
                        25 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Working...
                        X