NinjaTrader Support Forum TSV: Time segmented volume formula conversion

 Indicator Development Support for the development of custom indicators using NinjaScript.

 09-30-2008, 02:58 PM #1 skynetman Senior Member   Join Date: Mar 2008 Posts: 138 Thanks: 0 Thanked 0 times in 0 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...
 09-30-2008, 07:04 PM #2 NinjaTrader_JoshP NinjaTrader Product Manager     Join Date: May 2007 Location: Denver, CO Posts: 17,459 Thanks: 1 Thanked 348 times in 105 posts 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 JoshNinjaTrader Customer ServiceUse Kinetick, NinjaTrader’s preferred market data service - Learn MoreFree online training events - View Schedule
 10-01-2008, 03:17 AM #3 skynetman Senior Member   Join Date: Mar 2008 Posts: 138 Thanks: 0 Thanked 0 times in 0 posts 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 at 03:50 AM.
 10-01-2008, 07:10 AM #4 NinjaTrader_JoshP NinjaTrader Product Manager     Join Date: May 2007 Location: Denver, CO Posts: 17,459 Thanks: 1 Thanked 348 times in 105 posts Unfortunately, skynetman, we are not experts in AFL language and are unqualified in helping with the conversion. JoshNinjaTrader Customer ServiceUse Kinetick, NinjaTrader’s preferred market data service - Learn MoreFree online training events - View Schedule
10-01-2008, 11:13 AM   #5
Junior Member

Join Date: Jun 2008
Location: Chicago
Posts: 28
Thanks: 2
Thanked 1 time in 1 post

Hi Skynetman,

I took a look at your formula and came up with this. Is this similar to what you have ?
Attached Images
 tsv.png (76.7 KB, 272 views)

 10-01-2008, 12:21 PM #6 skynetman Senior Member   Join Date: Mar 2008 Posts: 138 Thanks: 0 Thanked 0 times in 0 posts twtrader could you please past the whole code? I can't make it run..... Thx a lot!
 10-04-2008, 06:59 PM #7 anachronist Senior Member   Join Date: Jul 2008 Posts: 296 Thanks: 4 Thanked 12 times in 11 posts 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 at 09:23 PM.
 10-05-2008, 05:02 PM #8 skynetman Senior Member   Join Date: Mar 2008 Posts: 138 Thanks: 0 Thanked 0 times in 0 posts 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 at 05:11 PM.
10-05-2008, 09:56 PM   #9
anachronist
Senior Member

Join Date: Jul 2008
Posts: 296
Thanks: 4
Thanked 12 times in 11 posts

Quote:
 Originally Posted by skynetman 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

 10-24-2008, 11:31 AM #10 stevewar Junior Member   Join Date: Oct 2008 Posts: 2 Thanks: 0 Thanked 0 times in 0 posts 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.
 10-24-2008, 03:03 PM #11 stevewar Junior Member   Join Date: Oct 2008 Posts: 2 Thanks: 0 Thanked 0 times in 0 posts 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
 04-28-2011, 04:27 AM #12 rrystrom Junior Member   Join Date: Apr 2011 Posts: 10 Thanks: 0 Thanked 0 times in 0 posts Did anyone compile this? Care to share the final code?

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home News and Announcements     News and Announcements NinjaTrader 8     Platform Technical Support     Add-On Development     Indicator Development     Strategy Development NinjaTrader 7     Platform Technical Support     General Development     Indicator Development     Strategy Development NinjaScript File Sharing     NinjaScript File Sharing Discussion     Version 8 Add-Ons     Version 8 Indicators     Version 8 Strategies     Version 7 Indicators     Version 7 Strategies     Version 7 Miscellaneous NinjaScript Educational Resources     Reference Samples     Tips Suggestions and Feedback     Suggestions And Feedback Historical Beta Archive     Version 8 Beta

 Similar Threads Thread Thread Starter Forum Replies Last Post funk101 Strategy Development 1 09-17-2008 12:37 PM pipsheker General Development 2 05-17-2008 06:57 AM RedDuke Indicator Development 4 10-19-2007 07:33 AM ClayB1 Indicator Development 5 06-26-2007 07:00 AM sknudsen Platform Technical Support 3 05-21-2007 05:24 PM

All times are GMT -6. The time now is 10:44 PM.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.