Go Back   NinjaTrader Support Forum > NinjaTrader 7 > 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_JoshP
NinjaTrader Product Manager
 
NinjaTrader_JoshP's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,459
Thanks: 1
Thanked 293 times in 98 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_JoshP 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_JoshP
NinjaTrader Product Manager
 
NinjaTrader_JoshP's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,459
Thanks: 1
Thanked 293 times in 98 posts
Default

Unfortunately, skynetman, we are not experts in AFL language and are unqualified in helping with the conversion.
NinjaTrader_JoshP 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: 2
Thanked 1 time in 1 post
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, 267 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: 296
Thanks: 4
Thanked 12 times in 11 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: 296
Thanks: 4
Thanked 12 times in 11 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 Development 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 Platform Technical Support 3 05-21-2007 05:24 PM


All times are GMT -6. The time now is 06:26 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.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content. Visit the CFTC resources for education regarding the industry and signs of fraud.