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

Indicator Plot

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

    Indicator Plot

    I am trying to create a simple indicator that sums 3 periods of the cumulative delta.

    I cannot figure out how to get the addplot() to work.

    If I try and assign the logic to the variable I created I get "cannot convert double" errors when compiling.
    I also tried to use value[0] which will compile but the chart panel is blank.

    I have attached the indicator.

    I have gone through the help guide and cannot figure out what I am doing wrong.
    I think the help guide will make more sense after I successfully get a plot to work.

    appreciate the help in advance.

    Also are there any videos from NT for creating indicators?
    Attached Files

    #2
    Hello sdauteuil,
    You can use as below:-
    Option 1 : CumulativeDeltaPLot[0] = SUM(cumulativeDelta.DeltaClose, 3)[0];
    Option 2 : Values[0][0] = SUM(cumulativeDelta.DeltaClose, 3)[0];
    Hope it helps!

    Comment


      #3
      I was trying

      Option 1 : CumulativeDeltaPLot[0] = SUM(cumulativeDelta.DeltaClose, 3)[0];

      but I get 'CumulativeDeltaPlot' does not exist in the current context when compiling.

      I have it defined under properties
      #region Properties

      [Browsable(false)]
      [XmlIgnore]
      public Series<double> CumulativeDeltaPlot
      {
      get { return Values[0]; }
      }

      #endregion

      ***

      When I tried Option 2 : Values[0][0] = SUM(cumulativeDelta.DeltaClose, 3)[0];

      The code will compile but the panel on the chart is empty. I turned on tick replay but that didn't help.


      Thank you

      Comment


        #4
        I think I made a copy paste error, please correct it as :-
        Code:
        CumulativeDeltaPlot[0] = SUM(cumulativeDelta.DeltaClose, 3)[0];
        Note:
        You're using PlotStyle.Bar, change this to Line & be sure to have Auto Scale selected.
        Last edited by s.kinra; 11-22-2020, 01:49 AM. Reason: typo error

        Comment


          #5
          Let me also ask if you're getting any errors in Control Center Log tab ?

          Comment


            #6
            That was able to compile

            I changed PlotStyle to Line and added IsAutoScale = true;

            However the indicator panel is still empty

            Comment


              #7
              Log error
              11/22/2020 12:28:19 AM Default Indicator 'TestCumulativeDeltaSum': Error on calling 'OnBarUpdate' method on bar 0: Object reference not set to an instance of an object.

              Comment


                #8
                OK great, it means no issues with plot. Order Flow might be unable to process on first bar, so you can exclude it.
                You need to add this :-
                Code:
                protected override void OnBarUpdate()
                {[INDENT]if(CurrentBar < 3)[/INDENT][INDENT=2]return;[/INDENT]
                 ...  // rest of code
                }
                You can adjust it later.

                Comment


                  #9
                  I had tried adding that

                  if (BarsInProgress != 0)
                  return;

                  if (CurrentBars[0] < 20)
                  return;

                  whatever number I put in the CurrentBars statement comes up in the error log.
                  11/22/2020 9:15:56 AM Default Indicator 'TestCumulativeDeltaSum': Error on calling 'OnBarUpdate' method on bar 20: Object reference not set to an instance of an object.
                  I have tried adding Print() statements to debug it, none of the statements print in the output window only the error.
                  I thought maybe there was a spelling or upper / lower case error but haven't found any.

                  The latest version is attached
                  Attached Files

                  Comment


                    #10
                    I also tried adding

                    if ((CurrentBars[0] < 20)
                    || (CurrentBars[1] < 20))
                    return;

                    In case the secondary series was the problem

                    Comment


                      #11
                      I found this in a previous post... not sure if this has anything to do with it

                      The secondary series is synced with the primary series

                      However there is no property region to define variables


                      protected override void OnBarUpdate()
                      {
                      if (BarsInProgress == 0)
                      {
                      // Print the close of the cumulative delta bar with a delta type of Bid Ask and with a Session period
                      Print("Delta Close: " + cumulativeDelta.DeltaClose[0]);
                      }
                      else if (BarsInProgress == 1)
                      {
                      // We have to update the secondary series of the hosted indicator to make sure the values we get in BarsInProgress == 0 are in sync
                      cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
                      }
                      Attached Files

                      Comment


                        #12
                        Originally posted by sdauteuil View Post
                        I am trying to create a simple indicator that sums 3 periods of the cumulative delta.

                        I cannot figure out how to get the addplot() to work.
                        Hi sdauteuil

                        I have created several indicators based on CD and found a good example by NinjaTrader_PaulH located here:

                        OFCDKeltner uses the Order Flow Cumulative Delta indicator as the input to draw the standard Keltner Channel. To use, please follow this process: 1) Add Order Flow Cumulative Delta to your chart. 2) Add the indicator OFCDKeltner and ensure before applying that you have selected the same parameters that the Order Flow Cumulative Delta indicator [&#8230;]


                        It is a good reference for a starting point.

                        Robotman
                        OFCDKeltner uses the Order Flow Cumulative Delta indicator as the input to draw the standard Keltner Channel. To use, please follow this process: 1) Add Order Flow Cumulative Delta to your chart. 2) Add the indicator OFCDKeltner and ensure before applying that you have selected the same parameters that the Order Flow Cumulative Delta indicator […]

                        Comment


                          #13
                          Hello sdauteuil,

                          In the file you posted in Post #1 I am able to import this, and there is no compile error.
                          However, there is logic run-time error.

                          You have 'if (State == State.DataLoaded)' nested within the action block for 'else if (State == State.Configure).

                          If the State is State.Configure then it cannot also be State.DataLoaded at the same time.
                          The condition on line 58 will never be true, and the cumulativeDelta will never have an indicator instance assigned.

                          Change this to 'else if (State == State.DataLoaded)' and move this below the action block for State.Configure, currently on line 65.


                          In the file you have posted in Post #11, I am not seeing any issue. This runs and I am seeing prints appearing in the output window. Let me know if you need a video of the script being tested and showing prints in the output window.
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            Thank you that worked

                            In the first one the indicator wizard didn't add the State == State.DataLoaded
                            apparently I added that incorrectly.

                            In the second one the print function was working but no property area was create to define the series/variable
                            I wasn't sure how to create the series for the plot.

                            Comment


                              #15
                              Thanks Robotman for that information

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by yertle, Today, 08:38 AM
                              2 responses
                              7 views
                              0 likes
                              Last Post yertle
                              by yertle
                               
                              Started by dappa, Today, 09:18 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post dappa
                              by dappa
                               
                              Started by bill2023, Yesterday, 08:51 AM
                              4 responses
                              22 views
                              0 likes
                              Last Post bltdavid  
                              Started by trilliantrader, Today, 08:16 AM
                              3 responses
                              9 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by NinjaTrader_ChelseaB, 01-08-2017, 06:59 PM
                              79 responses
                              19,662 views
                              5 likes
                              Last Post zrobfrank  
                              Working...
                              X