VSA for ThinkorSwim - futures io
futures io futures trading



VSA for ThinkorSwim


Discussion in ThinkOrSwim

Updated by tradercy
      Top Posters
    1. looks_one snowcloud with 93 posts (25 thanks)
    2. looks_two StockJock with 91 posts (27 thanks)
    3. looks_3 cbritton with 37 posts (65 thanks)
    4. looks_4 swimtrader with 22 posts (19 thanks)
      Best Posters
    1. looks_one Hornblower with 2.2 thanks per post
    2. looks_two cbritton with 1.8 thanks per post
    3. looks_3 StockJock with 0.3 thanks per post
    4. looks_4 snowcloud with 0.3 thanks per post
    1. trending_up 208,957 views
    2. thumb_up 214 thanks given
    3. group 81 followers
    1. forum 433 replies
    2. attach_file 130 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
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

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

 
Thread Tools Search this Thread
 

VSA for ThinkorSwim

  #1 (permalink)
Atlanta, Georgia
 
Experience: Intermediate
Platform: NT
Broker: DDT
Trading: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 248 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
Click image for larger version

Name:	NT_VSA_GDX.PNG
Views:	3634
Size:	58.1 KB
ID:	10894   Click image for larger version

Name:	ToS_VSA_GDX.png
Views:	2214
Size:	48.7 KB
ID:	10895  
Attached Files
Register to download File Type: txt VPAv1STUDY.txt (12.7 KB, 1180 views)
Reply With Quote

Can you help answer these questions
from other members on futures io?
Convert NinjaTrader NT7 indicator to Tradestation EasyLanguage and RADARSCREEN
Platforms and Indicators
Issue meeting order entry conditions
Elite Automated NinjaTrader Trading
Last 5 minutes Label
ThinkOrSwim
Moving average with Lag reduction
NinjaTrader
Linux?
ThinkOrSwim
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Spoo-nalysis ES e-mini futures S&P 500
129 thanks
What is your single biggest weakness?
93 thanks
Is Volume Profile worth learning or is it an outdated concept?
57 thanks
Is Amp at risk of going under?
41 thanks
Is Orderflow An Outdated Concept?
30 thanks
 
  #3 (permalink)
Atlanta, Georgia
 
Experience: Intermediate
Platform: NT
Broker: DDT
Trading: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 248 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)
Atlanta, Georgia
 
Experience: Intermediate
Platform: NT
Broker: DDT
Trading: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 248 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
Click image for larger version

Name:	ToS_Comp1.png
Views:	1445
Size:	68.4 KB
ID:	10946  

Last edited by cbritton; April 9th, 2010 at 02:49 PM.
Reply With Quote
The following user says Thank You to cbritton for this post:
 
  #5 (permalink)
Atlanta, Georgia
 
Experience: Intermediate
Platform: NT
Broker: DDT
Trading: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 248 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)
Atlanta, Georgia
 
Experience: Intermediate
Platform: NT
Broker: DDT
Trading: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 248 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)
New Brunswick, NJ
 
Experience: Intermediate
Platform: N/A
Trading: N/A
 
Posts: 133 since Jun 2009
Thanks: 46 given, 155 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)
Atlanta, Georgia
 
Experience: Intermediate
Platform: NT
Broker: DDT
Trading: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 248 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)
Atlanta, Georgia
 
Experience: Intermediate
Platform: NT
Broker: DDT
Trading: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 248 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)
Atlanta, Georgia
 
Experience: Intermediate
Platform: NT
Broker: DDT
Trading: ZN, ZB
 
cbritton's Avatar
 
Posts: 224 since Mar 2010
Thanks: 152 given, 248 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
Click image for larger version

Name:	ToS_VSA_GDX.png
Views:	1109
Size:	48.0 KB
ID:	11450  
Attached Files
Register to download File Type: txt VPAv1STUDY.txt (14.5 KB, 487 views)
Reply With Quote
The following user says Thank You to cbritton for this post:



futures io Trading Community Platforms and Indicators ThinkOrSwim > VSA for ThinkorSwim




Upcoming Webinars and Events
 

Understanding Order Flow Stop Runs & Icebergs w/Bookmap

May 28
 

Free BloodHound Licenses to everyone!

June
     



Copyright © 2020 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