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

TSV: Time segmented volume formula conversion

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

    TSV: Time segmented volume formula conversion

    Guys i met this indicator from TC2000 and it seems worth a try as it uses volume and price, like OBV, but seems more reliable.

    I found two version of the formula and i paste them both (don't know what language they are... choose the one easier)

    Code:
    Sum(If(C,>,Ref(C,-1),+V*C-Ref(C,-1),If(C,<,Ref(C,-1),-V*C - Ref(C,-1),0)),18)
    {with a moving average of 9}
    another version:

    Code:
    TSV=(Sum( IIf( C > Ref(C,-1), V * ( C-Ref(C,-1) ), IIf( C < Ref(C,-1),-V * ( C-Ref(C,-1) ), 0 ) ) ,18));
    
    Plot(TSV,"TSV",1,1);
    Thx...

    #2
    Hi skynetman,

    Perhaps a community member can help you out. As a last resort you can also try one of the 3rd party NinjaScript Consultants here: http://www.ninjatrader.com/webnew/pa...injaScript.htm
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      If we use simple variables (not working) the pseudo code should be:

      Code:
      if (Close[0] > Close[1])
          tmp= Volume[0]*(Close[0]-Close[1]);
      else if (Close[0] < Close[1])
          tmp=(-1)*Volume[0]*(Close[0]-Close[1]);
      else tmp=0;
      
      TSV = Sum (i don't know,18);
      The problem is that i do not understand when to use vectors or not...
      AFL language reference says that Sum (array, int) gives the sum of the previous int elements of the arraty as in NT.

      But i do not understand how C, Ref(C,-1) can create an array...
      Do i have to use something like
      Code:
      for (int i=0, i<18, i++)  tmp[i]= Volume[i]*(Math.Abs(Close[i] - Close[i-1]));
      Value.Set (sum(tmp,18));
      thx...
      Last edited by skynetman; 10-01-2008, 03:50 AM.

      Comment


        #4
        Unfortunately, skynetman, we are not experts in AFL language and are unqualified in helping with the conversion.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Hi Skynetman,

          I took a look at your formula and came up with this. Is this similar to what you have ?
          Attached Files

          Comment


            #6
            twtrader could you please past the whole code?
            I can't make it run.....

            Thx a lot!

            Comment


              #7
              It looks to me like it's a complicated way of expressing one of Wilder's indicators, a moving average (or sum) of volume * movement.
              Code:
              (Variables)
              private DataSeries TSV;
              
              (Initialize)
              TSV = new DataSeries(this);
              
              (OnBarUpdate)
              TSV.Set(Volume[0] * Math.Abs(Close[0] - Close[1]));
              MyIndicator.Set(SUM(TSV, 18)[0]);
              -Alex
              Last edited by anachronist; 10-06-2008, 09:23 PM.

              Comment


                #8
                Thx Alex!
                P.S.: To help the other noobs around, to make it compile i think the right one is
                Code:
                MyIndicator.Set(SUM(TSV, 18)[0]);
                @twtrader: same code as yours?
                Last edited by skynetman; 10-05-2008, 05:11 PM.

                Comment


                  #9
                  Originally posted by skynetman View Post
                  Thx Alex!
                  P.S.: To help the other noobs around, to make it compile i think the right one is
                  Code:
                  MyIndicator.Set(SUM(TSV, 18)[0]);
                  Whoops, you're right. I corrected the code in my message. Thanks. -Alex

                  Comment


                    #10
                    TSV is a line chart

                    I don't think this formula is correct, as TSV is a line chart and is usually cominbed with ROC.

                    Comment


                      #11
                      Noob Error - Figured it out

                      The code was throwing an exception. I figured out how to get the debugger working and found out that the code wasn't handling the case where CurrentBar = 0, and in that case Close[1] was invalid...

                      Here's the fix:
                      if (CurrentBar == 0)
                      {
                      TSV.Set(0);
                      }
                      else
                      {
                      TSV.Set(Volume[0] *
                      Math.Abs(Close[0] - Close[1]));
                      }
                      Plot0.Set(SUM(TSV, 18)[0]);

                      i'm currently working on overlaying the ROC plot with TSV

                      Comment


                        #12
                        Did anyone compile this?
                        Care to share the final code?

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by thanajo, 05-04-2021, 02:11 AM
                        3 responses
                        467 views
                        0 likes
                        Last Post tradingnasdaqprueba  
                        Started by Christopher_R, Today, 12:29 AM
                        0 responses
                        10 views
                        0 likes
                        Last Post Christopher_R  
                        Started by sidlercom80, 10-28-2023, 08:49 AM
                        166 responses
                        2,236 views
                        0 likes
                        Last Post sidlercom80  
                        Started by thread, Yesterday, 11:58 PM
                        0 responses
                        4 views
                        0 likes
                        Last Post thread
                        by thread
                         
                        Started by jclose, Yesterday, 09:37 PM
                        0 responses
                        9 views
                        0 likes
                        Last Post jclose
                        by jclose
                         
                        Working...
                        X