Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Please help me with an arraylist part.

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

    #16
    got interrupted by phone call -- first 30 mins coding not done

    am interested, so will complete this
    will need another 30 mins

    I think original author script has some errors

    more soon

    Comment


      #17
      Great!..You are good coder. Yes, the pine script can not plot for high price such as BTCUSD sometime.
      ....Thanks so much...Take you time, David.
      Last edited by mailonline38; 03-18-2021, 03:44 PM.

      Comment


        #18
        coding done, debugging ...

        Comment


          #19
          Coding done, testing done, but looks useless on a 5min ES chart.

          Naturally, I have a feeling there are some calculation errors.

          For example, VPCc inside the PriceFunc is poorly described
          at the original TradingView website. They imply it is an array,
          but I think the 'c' in VPCc could be a typo ... or not.

          I had to add some extra code to make sure VPCc and VPRr
          were not causing divide by zero -- when the Compare method
          shows they're too close to zero, I just set them to 1, which means
          they should contribute nothing to the formula (because 1/1 is 1).

          Anyways, use the attached code as a basis for continued
          experimentation -- I'm not interested in continuing because I
          don't know Pine Script -- and like I said I think the original
          Pine source is a bit flakey. He has variables lenT and offset,
          but never uses them, VPCI is calculated twice, and the biggie
          is VPCc looks like an array inside PriceFunc -- arrrgh!

          Not knowing Pine Script means my frustration at guessing
          at the original code is aggravating, esp when I don't know if
          the original code has any bugs or not -- like I said, some things
          just look kinda flakey.

          But, that could just be my ignorance showing.

          Good luck!
          Attached Files
          Last edited by bltdavid; 03-18-2021, 06:48 PM.

          Comment


            #20
            The script is a lot cleaner, should help you learn quite a bit more
            about NinjaScript -- esp with DataSeries.

            Comment


              #21
              Yeahhhh....Thank you so much, David.
              Yes, I did open my view about arraylist and now DataSeries.

              I know the logic after converting into NT7, it have a bit different plot as the picture. Click image for larger version

Name:	Chart different.jpg
Views:	293
Size:	448.4 KB
ID:	1147306

              Comment


                #22
                Looks pretty close!

                Comment


                  #23
                  Thanks a lot again. I am studying your code for further understanding. You made my day.

                  Comment


                    #24
                    Originally posted by mailonline38 View Post
                    I am reading about Series<double> now to avoid using ArrayLists.
                    Oh .. ok ... well, uh, just be aware ... using Series<double> is NT8.

                    I bring this up because this is an NT7 forum.

                    NT8 has made many code-breaking changes. For NT8, they opted to use
                    a generic type parameter when creating their new Series class, so in NT8
                    we use Series<double> ... which was formerly the DataSeries class in NT7.

                    In NT8, Series<int> is same as IntSeries class from NT7.
                    Series<bool> is same as BoolSeries class.
                    Series<string> is same as StringSeries class.
                    etc

                    The concepts between the two are very similar.
                    Just realize there are many syntax differences between NT7 and NT8.

                    An NT7 script cannot run as-is on NT8.

                    All NT7 scripts must be modified at the source code level to accommodate
                    the many changes made to the NT8 NinjaScript framework.

                    -=o=-

                    Saying "data series" in NT7 usually meant the "DataSeries class" or the
                    "IDataSeries interface" -- it was relatively specific. The "IDataSeries
                    interface" was kinda like the gateway to understanding what the term
                    "data series" really meant. It was a nice bridge to understanding what
                    the other series named things were, like a bar series, an IntSeries, etc.

                    In NT8, saying "data series" has started evolving into a more generic term,
                    and now usually refers to anything using the new Series<T> class -- where
                    type T is your "data" when speaking of an NT8 "data series".

                    My point is, in NT7 a "data series" was talked about in both generic and
                    specific ways, and you had to infer from context what was really being
                    said. In NT8, to my way of thinking, the term "data series" now leans
                    heavily generic, and much less specific. This is a good thing.

                    -=o=-

                    I should say, however, that NT8 NinjaScript includes a new method called
                    AddDataSeries, which I think is a very poor name -- it should have been
                    called AddBarSeries, since that better fits what it actually does.

                    My point is: regulating the term "data series" to the completely generic term
                    it really is didn't happen completely in NT8. They embedded the term into a
                    tangential relationship with creating a new bar series -- a mistake, I think -- esp
                    when you consider a fantastic name like AddBarSeries was readily available.

                    Oh well ... I guess, at the time, they forgot to ask me ... LOL



                    EDIT: In NT8, when selecting the bar series for the chart, the dialog that
                    allows you to do this is titled "Data Series". It seems NT folks are trying to
                    redefine "data series" to mean "bar series" -- a direction that seems
                    completely unnecessary. Data series should be the generic description,
                    just like the Series class has become generic. A bar series is a specific
                    instance of a data series, but NT pollutes their own terminology.
                    Last edited by bltdavid; 03-23-2021, 05:34 PM.

                    Comment


                      #25
                      Originally posted by bltdavid View Post
                      Anyways, use the attached code ...
                      I found a bug.

                      Inside the PriceFunc method, you'll see this loop
                      at the bottom,

                      Code:
                      double Price = 0;
                      for (int i = 0; i < lenV; ++i)
                      {
                          double VPRr = VPR[i];
                          if (VPRr.Compare(0, 0.000000000001) == 0)
                              VPRr = 1;
                          Price += Low[B][COLOR=#e74c3c][0][/COLOR][/B] * 1/VPCc * 1/VPRr;
                      }
                      The Low[0] should be Low[i].

                      My bad.

                      Comment


                        #26
                        Originally posted by bltdavid View Post

                        I found a bug.

                        Inside the PriceFunc method, you'll see this loop
                        at the bottom,

                        Code:
                        double Price = 0;
                        for (int i = 0; i < lenV; ++i)
                        {
                        double VPRr = VPR[i];
                        if (VPRr.Compare(0, 0.000000000001) == 0)
                        VPRr = 1;
                        Price += Low[B][COLOR=#e74c3c][0][/COLOR][/B] * 1/VPCc * 1/VPRr;
                        }
                        The Low[0] should be Low[i].

                        My bad.
                        Yes, it looks better...Thanks so much David.

                        Comment


                          #27
                          Hello @bltdavid,
                          I have learn from the clean way of your code with DataSeries and PrintString a lot. Thanks so much.
                          The tryAVSL script plotted is fine but it can not plot for any security with the price above 10,000 scale.
                          Do you have any hint or tips for this problem? Please advise.

                          Comment


                            #28
                            Not really, but I'll take a look ...

                            What instrument are you testing with?
                            YM, NQ ... ??

                            Comment


                              #29
                              Originally posted by bltdavid View Post
                              Not really, but I'll take a look ...

                              What instrument are you testing with?
                              YM, NQ ... ??
                              Yes, YM, NQ and RTY with Timeframe 60min and below (ES is OK). Thanks for your reply.
                              Last edited by mailonline38; 03-23-2021, 12:13 PM.

                              Comment


                                #30
                                I have no idea.

                                I've done my best interpretation, trying to faithfully translate the Pine
                                script directly to NinjaScript.

                                I've read through the Pine script again, and even reading through the
                                user comment section on the tradingview.com website.

                                The original pine script has issues, some have been acknowledged in
                                the comments.

                                The main issue, I think, is no one seems to have (or understand) the
                                correct formula. The source of the original algorithm is a book, and
                                complaints in the user comment section imply the book author has
                                explained this algorithm poorly.

                                I agree, something is wrong with my translation. But I don't know what
                                it is, and I don't know where to look to find an answer.

                                Unfortunately, you're on your own from here.

                                Good luck!

                                Last edited by bltdavid; 03-23-2021, 05:18 PM.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                571 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                331 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                101 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                549 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                549 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X