Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

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

Reply
 
Thread Tools Display Modes
Old 09-30-2008, 02:58 PM   #1
skynetman
Senior Member
 
Join Date: Mar 2008
Posts: 138
Thanks: 0
Thanked 0 times in 0 posts
Default 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...
skynetman is offline  
Reply With Quote
Old 09-30-2008, 07:04 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,460
Thanks: 1
Thanked 162 times in 82 posts
Default

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
NinjaTrader_Josh is offline  
Reply With Quote
Old 10-01-2008, 03:17 AM   #3
skynetman
Senior Member
 
Join Date: Mar 2008
Posts: 138
Thanks: 0
Thanked 0 times in 0 posts
Default

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.
skynetman is offline  
Reply With Quote
Old 10-01-2008, 07:10 AM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,460
Thanks: 1
Thanked 162 times in 82 posts
Default

Unfortunately, skynetman, we are not experts in AFL language and are unqualified in helping with the conversion.
NinjaTrader_Josh is offline  
Reply With Quote
Old 10-01-2008, 11:13 AM   #5
twtrader
Junior Member
 
Join Date: Jun 2008
Location: Chicago
Posts: 28
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi Skynetman,

I took a look at your formula and came up with this. Is this similar to what you have ?
Attached Images
File Type: png tsv.png (76.7 KB, 249 views)
twtrader is offline  
Reply With Quote
Old 10-01-2008, 12:21 PM   #6
skynetman
Senior Member
 
Join Date: Mar 2008
Posts: 138
Thanks: 0
Thanked 0 times in 0 posts
Default

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

Thx a lot!
skynetman is offline  
Reply With Quote
Old 10-04-2008, 06:59 PM   #7
anachronist
Senior Member
 
Join Date: Jul 2008
Posts: 272
Thanks: 4
Thanked 7 times in 7 posts
Default

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.
anachronist is offline  
Reply With Quote
Old 10-05-2008, 05:02 PM   #8
skynetman
Senior Member
 
Join Date: Mar 2008
Posts: 138
Thanks: 0
Thanked 0 times in 0 posts
Default

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.
skynetman is offline  
Reply With Quote
Old 10-05-2008, 09:56 PM   #9
anachronist
Senior Member
 
Join Date: Jul 2008
Posts: 272
Thanks: 4
Thanked 7 times in 7 posts
Default

Quote:
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
anachronist is offline  
Reply With Quote
Old 10-24-2008, 11:31 AM   #10
stevewar
Junior Member
 
Join Date: Oct 2008
Posts: 2
Thanks: 0
Thanked 0 times in 0 posts
Default 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.
stevewar is offline  
Reply With Quote
Old 10-24-2008, 03:03 PM   #11
stevewar
Junior Member
 
Join Date: Oct 2008
Posts: 2
Thanks: 0
Thanked 0 times in 0 posts
Default 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
stevewar is offline  
Reply With Quote
Old 04-28-2011, 04:27 AM   #12
rrystrom
Junior Member
 
Join Date: Apr 2011
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
Default

Did anyone compile this?
Care to share the final code?
rrystrom is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

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 Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
time and sales volume vs. e.Volume funk101 Strategy Development 1 09-17-2008 12:37 PM
CCI formula pipsheker General Programming 2 05-17-2008 06:57 AM
Calculating Time in Volume Bars RedDuke Indicator Development 4 10-19-2007 07:33 AM
Time of Day Average Volume ClayB1 Indicator Development 5 06-26-2007 07:00 AM
Volume Average vs. Time intervals sknudsen Miscellaneous Support 3 05-21-2007 05:24 PM


All times are GMT -6. The time now is 05:37 PM.

FULL RISK DISCLOSURE: Futures 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.