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

How can I access plot values

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

    How can I access plot values

    For example, the MACD indicator has a plot called "Diff". When it draws on the chart, it shows the differences bars. When the bar value is, for example, 3.45, how do I get that value? I have tried several incantations but have not found the correct syntax.

    Thanks for your help.

    #2
    Hello,

    In order to access the Diff Plot, you would want to use:

    if (MACD(Fast, Slow, Smooth).Diff[0]

    More information on using the MACD indicator method can be found below:



    I would also suggest reviewing our Tip on Referencing the Correct Bar:

    MatthewNinjaTrader Product Management

    Comment


      #3
      OK, but I'm doing this inside the MACD indicator. Won't this recursion cause some trouble? I just want to get the value that is plotted on the screen.

      Diff[0] gives me a strange value, not the actual value plotted.

      Comment


        #4
        Hello,

        If you're working inside the MACD, you do not need to specify the indicator.

        Diff[0] should give you the difference of the macd - macdAvg for the current bar.

        Can you please clarify what value you are seeing vs the value you expect to see?
        MatthewNinjaTrader Product Management

        Comment


          #5
          Hmmmmm.... I guess it is getting the correct value, however, now my MACD is not working correctly as compared to a straight, unaltered one in a similar chart. I will need to look into that first.

          Comment


            #6
            Hello,

            Thanks for the update - I would suggest first checking the Calculate On Bar Close property on the indicators you're using as this can change the way Diff[0] will be plotted.

            When COBC = True, Diff[0] will be the most recent closed bar, when set to False, Diff[0] will be the current bar.
            MatthewNinjaTrader Product Management

            Comment


              #7
              OK the trouble comes in when I add other Bar objects:

              Add(PeriodType.Minute, 15);
              Add(PeriodType.Minute, 30);

              Adding those lines in or commenting them out makes it work or not work. Why?

              Comment


                #8
                Hello,

                Do you receive any errors on the Log tab of the Control Center?

                Are you checking for the BarsInProgress? Please see our Help Guide artcile on 'Accessing the Price Data in a Multi-Bars NinjaScript' & 'Accessing the Price Data in a Multi-Bars NinjaScript' for more information:

                MatthewNinjaTrader Product Management

                Comment


                  #9
                  OK I added :

                  // Ignore bar update events for the supplementary Bars object added above
                  if (BarsInProgress == 1)
                  return;

                  But to no avail. The MACD plot looks screwy and it's Diff value doesn't match an unadulterated one.

                  Comment


                    #10
                    OK, fixed it...

                    if (BarsInProgress != 0)
                    return;

                    Is what works... duh!

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by GwFutures1988, Today, 02:48 PM
                    0 responses
                    2 views
                    0 likes
                    Last Post GwFutures1988  
                    Started by mmenigma, Today, 02:22 PM
                    1 response
                    3 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by frankthearm, Today, 09:08 AM
                    9 responses
                    35 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Started by NRITV, Today, 01:15 PM
                    2 responses
                    9 views
                    0 likes
                    Last Post NRITV
                    by NRITV
                     
                    Started by maybeimnotrader, Yesterday, 05:46 PM
                    5 responses
                    28 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Working...
                    X