VSA for ThinkorSwim - ThinkOrSwim Programming | futures io social day trading
futures io futures trading


VSA for ThinkorSwim
Updated: Views / Replies:169,465 / 429
Created: by cbritton Attachments:131

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you dont need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 131  
 
Thread Tools Search this Thread
 

VSA for ThinkorSwim

  #1 (permalink)
Elite Member
Atlanta, Georgia
 
Futures Experience: Intermediate
Platform: NT
Broker/Data: DDT
Favorite Futures: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 237 received

VSA for ThinkorSwim

I'm working on converting the NinjaTrader VPA indicator (found in the downloads section) to ThinkorSwim. I'm still at the beginning stages right now and I'm starting this thread so the readers here can keep me honest

Included are 2 screen shots of GDX with the indicator in ToS and NT. There are some differences in that the NT version is showing some items the ToS version is not and vice versa it seems. I hope to iron out the differences in the following days.

ToS can't draw some of the symbols the same way NT can. For example, a diamond symbol does not exist (as of this post) in ToS, so I am resorting to just using a circle. Downward pointing triangles are not supported in ToS either, so this indicator will use the upward pointing triangle. These differences will be noted in this thread.

My first objective is to get the conditions correct on displaying the symbols on the bars so that the ToS version matches the NT version. Second, I will create the volume histogram with the colored bars to match. Third, I will attempt to document as much as possible the differences between the two and note any caveats.

The ToS study has been added here, but the file extension has been changed to .txt. If you want to import it to ToS, then you have to either rename the extension to .ts and import it or copy the content of the file into a new ToS study.

Regards,
-C

Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat. - Sun Tzu
Attached Thumbnails
VSA for ThinkorSwim-nt_vsa_gdx.png   VSA for ThinkorSwim-tos_vsa_gdx.png  
Attached Files
Register to download File Type: txt VPAv1STUDY.txt (12.7 KB, 1044 views)
Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Atlanta, Georgia
 
Futures Experience: Intermediate
Platform: NT
Broker/Data: DDT
Favorite Futures: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 237 received


While I was comparing the ToS and NT VSA indicators that I posted earlier, I was looking at the test for no supply. In the NT version for GDX, 9/28 is a no supply bar, but not on the ToS chart for the same instrument and date. I traced this back to the results for computing the isNarrowSpreadBar which is defined as this in the NT version:

 
Code
                            
spread.Set(High[0] - Low[0]);
avgSpread = (Wilder(spreadvolumeEmaAve)[0]);
isNarrowSpreadBar.Set(spread[0] < (narrowSpreadFactor avgSpread)); 
The reason for the difference in the ToS version is that the results for the avgSpread is not equal to the NT computation which could lead to different values when computing the no supply test. ToS has a built in WildersAverage function which is what I used. The NT version has a provided Wilders indicator and it has no author on it. This is the meat of the code from that indicator:

 
Code
                            
protected override void OnBarUpdate()
{
    
// Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    
if (CurrentBar == 
    {
        
firstAvg.Set(0);
        return;
    }
    
//if (CurrentBar + 1 == Period )
    
{    
        
//calculate first average
        
firstAvg.SetSMA(Inputperiod)[0]);
    }
    
WAvg.Set( (firstAvg[1] * (period -1) + Input[0]) / period);

Googling, I found this definition of wilders ma:

Wilder's Current Day Moving Average = (Previous Day Wilder's Moving Average * (n-1) + Current Day Price)/n

So the Wilders indicator that comes with VPA is not correct. It should be something like this:

WAvg.Set( (WAvg.Get(1) * (period -1) + Input[0]) / period);

I will make some changes to this and post my findings here.

Regards,
-C

Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat. - Sun Tzu
Reply With Quote
The following 2 users say Thank You to cbritton for this post:
 
  #4 (permalink)
Elite Member
Atlanta, Georgia
 
Futures Experience: Intermediate
Platform: NT
Broker/Data: DDT
Favorite Futures: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 237 received

I managed to reproduce the NT Wilder's indicator in ToS.

 
Code
                            
declare lower;
input length 30;

rec spread high low;

# ToS version
plot waa WildersAverage(spreadlength)[0];

# NT version
rec nta compoundValue(1average(spread,length), 0);
plot ntb = (nta[1]*(length-1) + spread)/length
Plotting the 2 values on the same graph shows that they are different. See the attached image.

I did a random sampling comparison between the NT versions on ToS and NT. The values are accurate to within 2 decimal places.

I will be posting the updated NT version shortly.

Regards,
-C

Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat. - Sun Tzu
Attached Thumbnails
VSA for ThinkorSwim-tos_comp1.png  

Last edited by cbritton; April 9th, 2010 at 03:49 PM.
Reply With Quote
The following user says Thank You to cbritton for this post:
 
  #5 (permalink)
Elite Member
Atlanta, Georgia
 
Futures Experience: Intermediate
Platform: NT
Broker/Data: DDT
Favorite Futures: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 237 received

This is the code that I think should be used for the NT Wilders indicator:

 
Code
                            
            if (CurrentBar <= period)
            {
                return;
            }
            else if (
CurrentBar == period+1)  // the first calculation in the Wilders average
            
{
                
WAvg.Set(SMA(Input,period)[0]);
            }
            else 
// all subsequent calculations
            
{
                
WAvg.Set((WAvg[1] * (period-1) + Input[0])/period);
            } 
I did some comparison between the values of plotting the spread using the wilders average on both ToS and NT. For the first 60 bars or so, the values differ but that difference decreases. I'm not sure why that is. Maybe something in the way I wrote the indicator? After those 60 bars, there is no difference to within 2 decimal places.

At this point, I don't know the authors original intention. Did they mean to use Wilders average and incorrectly implement the indicator? Or was this intentional? If the former, then the version in the download section is incorrect and, I think, the above patch should be what is needed. The downside is that it *could* give false signals as what I am suspecting is the reason for the difference between the ToS and NT version that I mentioned before (not counting my code errors ).

My expectation that someone with authority on this subject chiming in here is pretty slim and my knowledge of the VSA algorithm is limited. That being said, I am proceeding with the assumption that the Wilders average (as defined by Wilder) is to be used so future NT charts in this thread will be based on the revised indicator.

If you are using NT's VPA indicator, I hope you take this under advisement.

Anyways, I will post more charts for comparison and iron out more issues.

Regards,
-C

Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat. - Sun Tzu
Reply With Quote
The following 2 users say Thank You to cbritton for this post:
 
  #6 (permalink)
Elite Member
Atlanta, Georgia
 
Futures Experience: Intermediate
Platform: NT
Broker/Data: DDT
Favorite Futures: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 237 received

So what's the deal with this bit of code?

 
Code
                            
protected override void OnBarUpdate()
{

    if (
CurrentBar volumeEmaAve) return;
    
spread.Set(High[0] - Low[0]);
    ...
    
// Calculate Range information
    
avgSpread = (Wilder(spreadvolumeEmaAve)[0]);
    ...

In the Wilder function, the first element computed is the SMA on the given data series. However, the first condition of the OnBarUpdate() says that if the current bar is less than volumeEmaAve, then exit. Let's assume that volumeEmaAve = 10. So when CurrentBar == 10, the first value of the spread is set and the SMA for the part of Wilders indicator is calculated on the spread. Right? So the SMA on 10 bars of data is

Sum(High[n] - Low[n])/10 for n = 0..9

Right? But only 1 value of the spread data series is set because of the first condition. So that sum is just

(High[0] - Low[0])/10

This creates incorrect computed values for the average spread.

To get the correct sum of the spread for the first 10 bars, the spread data series must be set for bars 1..9. The following code will set the spread then perform the condition:

 
Code
                            
protected override void OnBarUpdate()
{
    
spread.Set(High[0] - Low[0]);
    if (
CurrentBar volumeEmaAve) return;
    ...
    
// Calculate Range information
    
avgSpread = (Wilder(spreadvolumeEmaAve)[0]);
    ...

Now the SMA on the Wilders algorithm is correctly computed.

Be careful with that C# code!

Regards,
-C

Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat. - Sun Tzu
Reply With Quote
The following user says Thank You to cbritton for this post:
 
  #7 (permalink)
Elite Member
New Brunswick, NJ
 
Futures Experience: Intermediate
Platform: N/A
Favorite Futures: N/A
 
Posts: 133 since Jun 2009
Thanks: 46 given, 154 received

If I can put in my two cents, I would suggest you take a step back and think what you want to accomplish.

VSA is based on a few simple concepts, like No Demand, No Supply, Tests, Thrusts, etc. The VSA Ninja Indicator is just one author's interpretation of mathematically defining these concepts.

If your goal is to assume that the author of the NinjaTrader's VSA interpretation is "correct" and try to match it exactly, then it is important to port his code exactly.

On the other hand, VSA is not a mechanical system and should not be treated as such. I think this more important to understand the concepts and once you do, this really doesn't matter what kind of moving average you use to define the average range as long as you do it in a consistent way. There is no way to say one is better than the other.

Reply With Quote
The following user says Thank You to thatguy for this post:
 
  #8 (permalink)
Elite Member
Atlanta, Georgia
 
Futures Experience: Intermediate
Platform: NT
Broker/Data: DDT
Favorite Futures: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 237 received


thatguy View Post
If I can put in my two cents, I would suggest you take a step back and think what you want to accomplish.

VSA is based on a few simple concepts, like No Demand, No Supply, Tests, Thrusts, etc. The VSA Ninja Indicator is just one author's interpretation of mathematically defining these concepts.

If your goal is to assume that the author of the NinjaTrader's VSA interpretation is "correct" and try to match it exactly, then it is important to port his code exactly.

On the other hand, VSA is not a mechanical system and should not be treated as such. I think this more important to understand the concepts and once you do, this really doesn't matter what kind of moving average you use to define the average range as long as you do it in a consistent way. There is no way to say one is better than the other.

The goal is to have a usable ToS version based on the NT version of what I think the author's intentions are. I am detailing this process so others can benefit from this conversion and hopefully 1) gain an understanding of how complex coding can be, and 2) don't assume any indicator does what they think it actually does.

My assumption is with the intention of what the author means, not blindly porting the indicator line for line. If that means corrections and improvements can be proposed back into the NT version, then I think I have accomplished something. I have been pointing out "issues" with the NT version for the purpose of learning and to make others aware that the implementation may produce false signals based on that implementation. While VSA is not a mechanical system, it does act as a guide for the user to make informed decisions.

Making observations and proposing corrections in this sense is analogous to getting a car mechanic to inspect your Prius. If you assume that the brakes on your Prius work well for you, then there's no need to have someone double check Toyota's work.


Regards,
-C

Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat. - Sun Tzu
Reply With Quote
The following 3 users say Thank You to cbritton for this post:
 
  #9 (permalink)
Elite Member
Atlanta, Georgia
 
Futures Experience: Intermediate
Platform: NT
Broker/Data: DDT
Favorite Futures: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 237 received

In the variables section in the NT version, narrowSpreadFactor is defined as a double with a value 0.7:

 
Code
                            
        private double highCloseFactor 0.70;
        private 
double lowCloseFactor 0.25;
        private 
double narrowSpreadFactor 0.7
However, the Properties section reassigns these values to have a minimum of 1:

 
Code
                            
        [Description("High Close Factor")]
        [
Category("Price Parameters")]
        [
Gui.Design.DisplayNameAttribute("High Close Factor")]
        public 
double DwHighClose
        
{
            
get { return highCloseFactor; }
            
set highCloseFactor Math.Max(1value); }
        }

        [
Description("Low Close Factor")]
        [
Category("Price Parameters")]
        [
Gui.Design.DisplayNameAttribute("Low Close Factor")]
        public 
double DwLowClose
        
{
            
get { return lowCloseFactor; }
            
set lowCloseFactor Math.Max(1value); }
        }

        [
Description("Narrow Spread Factor")]
        [
Category("Spread Parameters")]
        [
Gui.Design.DisplayNameAttribute("Narrow Spread Factor")]
        public 
double DwNarrowSpread
        
{
            
get { return narrowSpreadFactor; }
            
set narrowSpreadFactor Math.Max(1value); }
        } 
For example, when this indicator is added to a chart, narrowSpreadFactor is set to 1 and not the default of 0.7. ultraHighVolfactor and aboveAvgVolfactor have minimum property values of 1, but these have a default of 2 and 1.5, respectively.

If you want to use the default values, then I suggest you set the above three to have a minimum of 0 in the properties section.

Regards,
-C

Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat. - Sun Tzu
Reply With Quote
 
  #10 (permalink)
Elite Member
Atlanta, Georgia
 
Futures Experience: Intermediate
Platform: NT
Broker/Data: DDT
Favorite Futures: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 237 received


Sorry I have not posted much lately. I've been busy with other things.

With the changes in the NT version I mentioned in the previous postings, I am now able to match both.

I have a new version of the VSA study for ThinkorSwim. This version has the input parameters for the scaling factors as well as paint bar colors by trend (see the screen shot). I also added code to hide the titles for each plot since that can get very messy and not really convey any useful information.

(Please remember that the attached ToS study is a .txt file. If you want to import it into ToS, you need to change the extension to .ts or copy the content of the file into a new ToS study.)

ToS has some rudimentary text plotting functions that I plan on using for matching with some of the banners on the NT version. I'm not sure how this will work out, but I'll try to get something useful in the coming days. I plan on making the volume plot at some point as well.

Regards,
-C

Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat. - Sun Tzu
Attached Thumbnails
VSA for ThinkorSwim-tos_vsa_gdx.png  
Attached Files
Register to download File Type: txt VPAv1STUDY.txt (14.5 KB, 434 views)
Reply With Quote

Reply



futures io > > > > > VSA for ThinkorSwim

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Volume Spread Analysis (VSA) slumlord Traders Hideout 57 December 6th, 2017 01:19 AM
VSA indicator for MT4 sam1197 MetaTrader 12 December 21st, 2015 08:15 PM
VSA alexav Russian Traders 5 December 17th, 2012 05:03 AM
VSA in MC? TonyB MultiCharts 10 May 28th, 2011 11:37 AM


All times are GMT -4. The time now is 11:17 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-13 in 0.16 seconds with 20 queries on phoenix via your IP 54.227.51.103