• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

VSA Indicator - Beta

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

    VSA Indicator - Beta

    I try to port an existing VSA Indicator from an Amibroker code. Anyone can check the AFL File to see if the port is good?, first time working with Ami codes. Also comments from VSA Fans are welcome to see if we can have a useful indicator

    Here you can find the Original code: http://www.vpanalysis.blogspot.com/

    PD
    Thanks Roonius for the fix in the shading routine.

    Regards
    Attached Files
    Last edited by PrTester; 01-04-2009, 04:35 PM. Reason: update File

    #2
    Here is my take on the same AmiBroker code.

    Notes: I coded a Wilder MA indicator that is included in the attached file. I also used LinRegSlopSFX to find the slope. Also, I used a slightly different color scheme to paint the bars with.
    Attached Files

    Comment


      #3
      Originally posted by scjohn View Post
      Here is my take on the same AmiBroker code.

      Notes: I coded a Wilder MA indicator that is included in the attached file. I also used LinRegSlopSFX to find the slope. Also, I used a slightly different color scheme to paint the bars with.
      scjohn, thanks for the share, i will check my interpretation with your code to see where its different, also my color scheme it's horrible I will check it and revise, he, he.

      Best Regards, and Happy Holidays.

      Comment


        #4
        With the help of scjohn code I made some updates and fix to my port, uploaded in the first post.

        Comment


          #5
          Thanks PrTester and scjohn, great work!
          BertrandNinjaTrader Customer Service

          Comment


            #6
            div by zero error?

            great code and thanks for sharing.

            Code:
            //			Price information
            			upbar.Set(Close[0] > Close[1] ? true : false); 	
            			dnbar.Set(Close[0] < Close[1] ? true : false); 
            			Cloc=Close[0]-Low[0];
            			x=spread[0]/Cloc;
            			x1 =( Close[0] - Low[0] == 0.00 ? arg[0] : x );
            could someone help explain why this doesn't return a div by zero error when the close[0] = low[0]? To my tiny knowledge Cloc therefore = 0?

            Comment


              #7
              Potentially double.Epsilon issues: http://www.ninjatrader-support2.com/...ead.php?t=3929
              JoshNinjaTrader Customer Service

              Comment


                #8
                that is an issue

                Interesting. How does the close/low ever equal something that was not traded? I assume that NT just takes the transmitted data price ( in my case IB)?
                eg close = 2157. It can't equal for example 2157.000000001 or can it?

                Would the correct code therefore be
                nb I have now removed the cloc variable altogether
                Code:
                if (Instrument.MasterInstrument.Compare (Close[0], Low[0]) == 0
                {x = 0;}
                else
                {x = range[0] / (Close[0] - Low[0]);}
                I should add no div by zero error or crash of any kind has happened with the original code but I am learning C# 101.
                Dollars are in the detail.
                Last edited by Mindset; 01-05-2009, 12:21 PM.

                Comment


                  #9
                  When you do any subtraction, multiplication, etc with double values they can end up not equaling zero exactly. Long story short, you have to be mindful of the double.Epsilon. This is a more technical C# topic. For more information try combing through google.
                  JoshNinjaTrader Customer Service

                  Comment


                    #10
                    data and doubles and epsilon

                    Ok but just to confirm if Low[0] = 1234 then it always equals 1234 unless you start to manipulate it. NT doesn't do any "data processing" of it's own?

                    In which case, Close[0] = low[0] could return zero - and I am right back to the original query - how is the div by zero error avoided?

                    I am not being difficult but I need to understand.

                    Comment


                      #11
                      NT does not change the data it receives. Your check for 0 is already manipulating it. Close[0] - Low[0] is stored into your temp variable. That temp variable is no guaranteed to be 0.
                      JoshNinjaTrader Customer Service

                      Comment


                        #12
                        learn something

                        Well I spent some time last night testing out this data concept and it appears you are right - 3.56 - 3.55 does not equal .01 difference.
                        It often has rogue digits 4,5 or even 10 decimal places away!

                        One thing however - where close and low were equal my print statement always returned zero. But now I don't know whether that really is a true zero or has some weird digit 17 decimal places away that I can't see ( I understand that double values go approx 15- 16 decimal places?)
                        Last edited by Mindset; 01-06-2009, 10:09 AM. Reason: sp

                        Comment


                          #13
                          Mindset,

                          This is C# and the concept revolves around double.Epsilon. It may be best for you to research this matter on MSDN. Unfortunately I cannot provide any more assistance on this.
                          JoshNinjaTrader Customer Service

                          Comment


                            #14
                            Hello Mindset,

                            when I have to use price bar numbers heavily for calculations then I convert them into the tick representation before usage. That also avoids these special double-issues.

                            Regards
                            Ralph

                            Comment


                              #15
                              tick representation

                              Do you mean TickSize?
                              Perhaps you could show an example?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by supermht, Today, 07:59 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post supermht  
                              Started by mohdhm, Today, 05:13 PM
                              1 response
                              12 views
                              0 likes
                              Last Post nkhoi
                              by nkhoi
                               
                              Started by 3lliot, Today, 05:55 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post 3lliot
                              by 3lliot
                               
                              Started by Fargo, Today, 04:57 PM
                              0 responses
                              11 views
                              0 likes
                              Last Post Fargo
                              by Fargo
                               
                              Started by Johnny Santiago, Today, 03:57 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post Johnny Santiago  
                              Working...
                              X