NexusFi: Find Your Edge


Home Menu

 





VSA for ThinkorSwim


Discussion in ThinkOrSwim

Updated
      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 (71 thanks)
    4. looks_4 swimtrader with 22 posts (19 thanks)
      Best Posters
    1. looks_one Hornblower with 2.3 thanks per post
    2. looks_two cbritton with 1.9 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 304,527 views
    2. thumb_up 223 thanks given
    3. group 86 followers
    1. forum 434 posts
    2. attach_file 131 attachments




 
Search this Thread

VSA for ThinkorSwim

  #171 (permalink)
snowcloud
LA, CA
 
Posts: 93 since Jul 2010
Thanks Given: 2
Thanks Received: 25


swimtrader View Post
Snow,

As I see it, here's what is needed to improve this indicator:


Problem: There are definitions within the script that are questionable. For example, I think the code calls for a close to come off the low by 40% to qualify as a supply test.
Proposal: Thresholds and how they're calculated warrants a re-examation to ensure it's in keeping with the principals behind a "test." VSA requires a test to be 50% or more off the close. Doing so might reduce the number of signals while improving specificity and positive predictive value.


Thoughts?

Steve

I've got a little window of free time at present so I'd like to re-visit the White Square Test for Supply indicator in an attempt to improve it. (After this puppy is better and if time allows I'd like to tackle the extremely elusive Gray Square Test for Supply in an UpTrend). The code for White Squares is currently:

rec supplyTestBar = (isTwoDaysLowVol && low[0] < low[1] && isUpCloseBar);

This code requires a supplyTestBar to have volume lower than each of the previous 2 bars, a low lower than the previous bar, and a close above 50% of the spread. (The current code does seem to satisfy this >50% requirement. See below for excruciating detail*).

On p. 110 Williams writes "Testing is one of the best indications of strength. The prices will be marked down rapidly during the day (or any other time frame) but the price then recovers to close on the high of the day and will be accompanied by low volume."

It would seem that replacing "isUpCloseBar" with "isVeryHighCloseBar" would make supplyTestBar closer to Williams' definition.

Thoughts on this and other changes that might improve White Square Test for Supply?

The current code for a Cyan Circle noSupplyBar is:

def noSupplyBar = (isDownBar[0] && isNarrowSpreadBar[0] && isTwoDaysLowVol && isUpCloseBar);

This requires that a noSupplyBar be a narrow-spread down bar closing up with volume that is lower than the volumes of each of the two previous bars.

Thoughts for improvements? (As I am writing this I am looking at an example of a Cyan Circle noSupplyBar immediately preceding a White Square test for Supply which clearly is backwards).

Going on to the bar following a test, Williams writes on p. 35 "Any testing that does not respond immediately with higher prices, or certainly during the next day or so, can be considered an indication of weakness."

The current code for a Cyan Triangle successfulSupplyTestBar requires that the previous bar be a supplyTestBar and that the current bar be both an upBar and an UpCloseBar which seems to match Williams quite well.

def successfulSupplyTestBar = (supplyTestBar[1] && isUpBar[0] && isUpCloseBar);

Are there other requirements that would make this a stronger indicator of a potential upTrend?

*******
*Excruciating detail: two lines of code determine isUpCloseBar. The way it's written all bars in which (spread / (close - low)) is less than 2 (i.e. above the 50% line) are UpCloseBars. For example, a bar with an OHLC of 12/64/5/35 will have a spread of 59 (64-5) and a median price of 34.5 ((59/2)+5). That means that a bar with a close of 34 is not an UpCloseBar and a bar with a close of 35 is. That seems to satisfy the requirement in your proposal above.

def x1 = if (high==low) then 2.0 else if (close == low) then 2.65 else (spread / (close - low));
def isUpCloseBar = (x1 < 2);

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Build trailing stop for micro index(s)
Psychology and Money Management
NexusFi Journal Challenge - April 2024
Feedback and Announcements
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
36 thanks
NexusFi site changelog and issues/problem reporting
25 thanks
GFIs1 1 DAX trade per day journal
19 thanks
The Program
18 thanks
  #172 (permalink)
StockJock
Chicago + Illinois/USA
 
Posts: 256 since Aug 2010
Thanks Given: 15
Thanks Received: 154

This is the current code to color paint the price bars.

 
Code
AssignPriceColor(
if colorBars and shortTermTrendSlope > 0 and MiddleTermTrendSlope > 0 and longtermtrendslope > 0 then CreateColor(0, 255, 0) else 
if colorBars and shortTermTrendSlope > 0 and MiddleTermTrendSlope > 0 and longtermtrendslope < 0 then Color.green else 
if colorBars and shortTermTrendSlope > 0 and MiddleTermTrendSlope < 0 and longtermtrendslope < 0 then CreateColor(153, 255, 153) else 
if colorBars and shortTermTrendSlope < 0 and MiddleTermTrendSlope < 0 and longtermtrendslope < 0 then Color.red else 
if colorBars and shortTermTrendSlope < 0 and MiddleTermTrendSlope > 0 and longtermtrendslope > 0 then CreateColor(153, 255, 153) else 
if colorBars and shortTermTrendSlope < 0 and MiddleTermTrendSlope < 0 and longtermtrendslope > 0 then color.orange else 
if colorBars then Color.yellow else GetColor(7));
This is the current color bar legend.


Quoting 
green - short term up, mid term up, long term up
light green - short term up, mid term up, long term down
lime green - short term up, mid term down, long term down
red - short term down, mid term down, long term down
lime green - short term down, mid term up, long term up
orange - short term down, mid term down, log term up
yellow - anything not matching the above.



These are my observations.
  1. In the first "if" statement CreateColor(0, 255, 0) is the same as Color.green; so this is a duplication with the second "if" statement in color using different code commands.
  2. In the second "if" statement Color.green is incorrect, Color.light_green should be used.
  3. In the third "if" statement CreateColor(153, 255, 153) is correct; however, why not just use Color.lime?
  4. In the fourth "if" statement is correct.
  5. In the fifth "if" statement CreateColor(153, 255, 153) is correct; however, why not just use Color.lime?
  6. In the sixth "if" statement is correct.
  7. In the seventh "if" statement is correct.
========================================
RECOMMENDATIONS
========================================

Change the color legend assignments and associated code for easily distinguished colors bars on the chart.


Quoting 
green - short term up, mid term up, long term up
white - short term up, mid term up, long term down
magenta - short term up, mid term down, long term down
red - short term down, mid term down, long term down
cyan - short term down, mid term up, long term up
orange - short term down, mid term down, log term up
yellow - anything not matching the above.

This is the revised code for my recommended bar color assignments.

 
Code
AssignPriceColor(
if colorBars and shortTermTrendSlope > 0 and MiddleTermTrendSlope > 0 and longtermtrendslope > 0 then Color.green else 
if colorBars and shortTermTrendSlope > 0 and MiddleTermTrendSlope > 0 and longtermtrendslope < 0 then Color.white else 
if colorBars and shortTermTrendSlope > 0 and MiddleTermTrendSlope < 0 and longtermtrendslope < 0 then Color.magenta else 
if colorBars and shortTermTrendSlope < 0 and MiddleTermTrendSlope < 0 and longtermtrendslope < 0 then Color.red else 
if colorBars and shortTermTrendSlope < 0 and MiddleTermTrendSlope > 0 and longtermtrendslope > 0 then Color.cyan else 
if colorBars and shortTermTrendSlope < 0 and MiddleTermTrendSlope < 0 and longtermtrendslope > 0 then color.orange else 
if colorBars then Color.yellow else GetColor(7));
This is what the revised colors will look like on a chart.


Reply With Quote
Thanked by:
  #173 (permalink)
StockJock
Chicago + Illinois/USA
 
Posts: 256 since Aug 2010
Thanks Given: 15
Thanks Received: 154


I'm not sure what can be done for an explanation of the three time periods, but here's an attempt for a bar label legend.

 
Code
# SJ_TimePeriodLabels
declare lower;
input length = 9;
input displace = 0;
plot SMA = Average(volume[-displace], length);
SMA.SetDefaultColor(GetColor(1));
SMA.HideBubble();
SMA.HideTitle();
#
plot Shares = Volume;
Shares.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Shares.SetLineWeight(5);
#
# Trend Definitions
rec fiveDaysSma = compoundValue(5, Average(close, 5)[0], Double.NaN);
def LongTermTrendSlope = LinearRegressionSlope(price = fiveDaysSma, length = 40)[0];
def MiddleTermTrendSlope = LinearRegressionSlope(price = fiveDaysSma, length = 15)[0];
def ShortTermTrendSlope = LinearRegressionSlope(price = fiveDaysSma, length = 5)[0];
######
# Candle definitions
Shares.AssignValueColor(
if shortTermTrendSlope > 0 and MiddleTermTrendSlope > 0 and longtermtrendslope > 0 then  Color.green 
else 
if shortTermTrendSlope > 0 and MiddleTermTrendSlope > 0 and longtermtrendslope < 0 then Color.white else 
if shortTermTrendSlope > 0 and MiddleTermTrendSlope < 0 and longtermtrendslope < 0 then Color.magenta 
else 
if shortTermTrendSlope < 0 and MiddleTermTrendSlope < 0 and longtermtrendslope < 0 then Color.red else 
if shortTermTrendSlope < 0 and MiddleTermTrendSlope > 0 and longtermtrendslope > 0 then Color.cyan else 
if shortTermTrendSlope < 0 and MiddleTermTrendSlope < 0 and longtermtrendslope > 0 then Color.orange else  
Color.yellow);
AddChartLabel(Yes, "5BarsUp, 15BarsUp, 40BarsUp", Color.green); 
AddChartLabel(Yes, "5BarsUp, 15BarsUp, 40BarsDown", Color.white);
AddChartLabel(Yes, "5BarsUp, 15BarsDown, 40BarsDown", Color.magenta);
AddChartLabel(Yes, "5BarsDown, 15BarsDown, 40BarsDown", Color.red);
AddChartLabel(Yes, "5BarsDown, 15BarsUp, 40BarsUp", Color.cyan);
AddChartLabel(Yes, "5BarsDown, 15BarsDown, 40BarsUp",Color.orange);
AddChartLabel(Yes, "Default", Color.yellow);
Here's what it looks like.


Reply With Quote
Thanked by:
  #174 (permalink)
StockJock
Chicago + Illinois/USA
 
Posts: 256 since Aug 2010
Thanks Given: 15
Thanks Received: 154

Here's another way to look at the time periods, if this proves useful.

 
Code
# SJ_VPA_ShortTerm
declare lower;
input length = 9;
input displace = 0;
# Trend Definitions
rec fiveDaysSma = compoundValue(5, Average(close, 5)[0], Double.NaN);
def LongTermTrendSlope = LinearRegressionSlope(price = fiveDaysSma, length = 40)[0];
def MiddleTermTrendSlope = LinearRegressionSlope(price = fiveDaysSma, length = 15)[0];
def ShortTermTrendSlope = LinearRegressionSlope(price = fiveDaysSma, length = 5)[0];
# ==============================
def upTrend = shortTermTrendSlope > 0; 
def downTrend = shortTermTrendSlope < 0; 
# ==============================
plot Shares = if upTrend then Volume else if downTrend then -Volume else Double.NaN;
Shares.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Shares.SetDefaultColor(GetColor(4));
Shares.DefineColor("Up", Color.Green);
Shares.DefineColor("Down", Color.Red);
Shares.AssignValueColor(if upTrend then Shares.color("Up") else if downTrend then Shares.color("Down") else GetColor(1));
Shares.SetLineWeight(5);
Shares.HideTitle();
Shares.HideBubble();
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(GetColor(8));
ZeroLine.SetLineWeight(2);
ZeroLine.HideTitle();
ZeroLine.HideBubble();
 
Code
# SJ_VPA_MidTerm
declare lower;
input length = 9;
input displace = 0;
# Trend Definitions
rec fiveDaysSma = compoundValue(5, Average(close, 5)[0], Double.NaN);
def LongTermTrendSlope = LinearRegressionSlope(price = fiveDaysSma, length = 40)[0];
def MiddleTermTrendSlope = LinearRegressionSlope(price = fiveDaysSma, length = 15)[0];
def ShortTermTrendSlope = LinearRegressionSlope(price = fiveDaysSma, length = 5)[0];
# ==============================
def upTrend =MiddleTermTrendSlope > 0; 
def downTrend = MiddleTermTrendSlope < 0; 
# ==============================
plot Shares = if upTrend then Volume else if downTrend then -Volume else Double.NaN;
Shares.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Shares.SetDefaultColor(GetColor(4));
Shares.DefineColor("Up", Color.Green);
Shares.DefineColor("Down", Color.Red);
Shares.AssignValueColor(if upTrend then Shares.color("Up") else if downTrend then Shares.color("Down") else GetColor(1));
Shares.SetLineWeight(5);
Shares.HideTitle();
Shares.HideBubble();
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(GetColor(8));
ZeroLine.SetLineWeight(2);
ZeroLine.HideTitle();
ZeroLine.HideBubble();
 
Code
# SJ_VPA_LongTerm
declare lower;
input length = 9;
input displace = 0;
# Trend Definitions
rec fiveDaysSma = compoundValue(5, Average(close, 5)[0], Double.NaN);
def LongTermTrendSlope = LinearRegressionSlope(price = fiveDaysSma, length = 40)[0];
def MiddleTermTrendSlope = LinearRegressionSlope(price = fiveDaysSma, length = 15)[0];
def ShortTermTrendSlope = LinearRegressionSlope(price = fiveDaysSma, length = 5)[0];
# ==============================
def upTrend = LongTermTrendSlope > 0; 
def downTrend = LongTermTrendSlope < 0; 
# ==============================
plot Shares = if upTrend then Volume else if downTrend then -Volume else Double.NaN;
Shares.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Shares.SetDefaultColor(GetColor(4));
Shares.DefineColor("Up", Color.Green);
Shares.DefineColor("Down", Color.Red);
Shares.AssignValueColor(if upTrend then Shares.color("Up") else if downTrend then Shares.color("Down") else GetColor(1));
Shares.SetLineWeight(5);
Shares.HideTitle();
Shares.HideBubble();
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(GetColor(8));
ZeroLine.SetLineWeight(2);
ZeroLine.HideTitle();
ZeroLine.HideBubble();
This is the resulting display for the three time periods as histograms.


Reply With Quote
Thanked by:
  #175 (permalink)
snowcloud
LA, CA
 
Posts: 93 since Jul 2010
Thanks Given: 2
Thanks Received: 25


StockJock View Post
This is the current code to color paint the price bars.


In the third "if" statement CreateColor(153, 255, 153) is correct; however, why not just use Color.lime?



Thanks for your suggestions. To answer your question above, using specific RGB values allows for much finer control of color.

Reply With Quote
  #176 (permalink)
snowcloud
LA, CA
 
Posts: 93 since Jul 2010
Thanks Given: 2
Thanks Received: 25

My window of free time is starting to close so I'm posting a new version of the VSA study with changes I had time to make over the past 10 days or so. I've described them below and as before I welcome comments about specific aspects of the study that work and other aspects that don't work. One thing I have noticed is that when volume is very low the study's indications are much less reliable than when volume is robust. I suppose that the study could account for low volume situations and adjust thresholds accordingly but for now simply being aware of the study's inconsistencies will have to do.

I have also noticed that when there is a dense cluster of symbols attached to a few adjacent bars that that very density provides a strong signal of impending movement. Many times I have seen lots of Green - usually a Circle followed by a Square and a combination of UpArrows - signaling the end of a downtrend and the beginning of an uptrend.

My window of free time is closing again so I won't be able to make any other changes to the study in the near future but am looking forward to reading comments from whomever wants to post.

Here are some notes on changes that have been made:

1. Changed text descriptions from, for example, "An UpBar indicates a return of Strength" to "Strength returning on UpBar". In most cases the first word of each description is Strength, Weakness, Bullish, or Bearish. This way it's easier to catch the gist of the message if it flashes on the screen only briefly.

2. In effortToMoveDownBar I changed "high[0] < high[1]" to "((high[0] < high[1]) OR (isWideSpreadBar && volume[0] > 1.5 * sAvgVolume[0]))" . This allows a bar with big volume and a wide spread to be considered an Effort-to-Fall bar even though its high might be higher than the previous bar's.

3. Added "&& MiddleTermTrendSlope > 0" to isUpThrustBar in order to filter out upThrusts on trends that are only short term.

4. Added Yellow Circle Stopping Volume at Highs for an above-the-candle signal for an UpThrust-like indication of trend reversal. I have noticed that Stopping Volume works extremely well at lows in a DownTrend to signal its possible end. I anticipate that the opposite criteria at highs will signal the end of Uptrends.

5. Changed the trend colors to the following in keeping with the ROYGBIV mapping of color to trend direction and strength.


light cyan bar - short term up, mid term down, long term down
light green - short term up, mid term up, long term down
green - short term up, mid term up, long term up
yellow bar - short term down, mid term up, long term up
orange bar - short term down, mid term down, long term up
red bar - short term down, mid term down, long term down
light gray bar - anything not matching the above.


6. Added new variables for trend length: shortTermLength = 5, midTermLength = 15, longTermLength = 40. This allows users to select any trend length in the Inputs dialog box of Edit Studies and Strategies.

7. Changed Color Bars default to true so that when loading the study it displays bars in color.

Attached Files
Elite Membership required to download: VPAv1_07aSTUDY.ts
Reply With Quote
  #177 (permalink)
 swimtrader 
Sarasota, FL USA
 
Experience: Advanced
Platform: TOS, NinjaTrader
Broker: Mirus/Zenfire & TOS
Trading: ES
Posts: 22 since Sep 2010
Thanks Given: 0
Thanks Received: 19

Snow,

Sorry it's taken me a bit to reply. Have been focused on understanding the Market's current trading range. I want to share one image. It's a screen-shot of algo-based software I lease (on the left) vs TradeGuider (the real VSA) on the right. (I own TradeGuider.)

The message is this: The high-end decision-support tools attempt to reduce noise ...provide visually simple signals. But even then, market dynamics create difficult challenges. That's what money management is for.

I won't have time to contribute to the .ts work, for the near-term ...but wanted to pop in and give you guys an example of the challenges associated with simplicity. Notwithstanding, I think that's the path that is most important.

Lastly, were you to ignore market timing and enter a position - anywhere ...any level ...just respecting the direction of the trend ...it will be your exit which defines your success. If you enter and the market promptly goes against you, you have to ask yourself - am I early or is this reversal? The ability to identify levels at which large volume traders last entered long or distributed (short) will draw the line in the sand. If you enter and the market goes your way, it will be money management issues that define your exit: e.g., is the next profit level one which provides a 3:1 reward to risk, do I have an edge greater than 100%, is my expected short-term ROI greater than 10% (or annualized greater than 40%) ...that sort of stuff.

So ...try and keep the visual signals to a minimum. There's a lot of other stuff to think about!

Steve

Attached Thumbnails
Click image for larger version

Name:	RC_vs_VSA_100510.png
Views:	396
Size:	25.8 KB
ID:	21705  
Follow me on Twitter Reply With Quote
Thanked by:
  #178 (permalink)
snowcloud
LA, CA
 
Posts: 93 since Jul 2010
Thanks Given: 2
Thanks Received: 25


swimtrader View Post
Snow,

Sorry it's taken me a bit to reply. Have been focused on understanding the Market's current trading range. I want to share one image. It's a screen-shot of algo-based software I lease (on the left) vs TradeGuider (the real VSA) on the right. (I own TradeGuider.)

...

So ...try and keep the visual signals to a minimum. There's a lot of other stuff to think about!

Steve

Thanks very much for your input, Steve. Very interesting charts and good advice on money and trade management issues. One question - did the Algo package print the "Downtrend Signal Invalidated" text or did you add it? If the latter did the algo package provide other notice that the downtrend signal was invalidated?

Also, what are the numbers under and above the candles?

Thanks.

Reply With Quote
  #179 (permalink)
 swimtrader 
Sarasota, FL USA
 
Experience: Advanced
Platform: TOS, NinjaTrader
Broker: Mirus/Zenfire & TOS
Trading: ES
Posts: 22 since Sep 2010
Thanks Given: 0
Thanks Received: 19

I labelled the Algo plot. Like most systems, there are requirements for signals to achieve confirmation. That short signal was not confirmed, and for now remains invalid. The numbers you see are TD Sequential.

Interestingly, shortly after I posted, TradeGuider signaled weakness. I've attached. The cyan up arrow is a trend indicator. The blue bar is a high-volume up bar. VSA tenets that weakness is seen on up bars. The "Indicator Information" is revealed by clicking the green square. In doing so, we are told to be cautious about seeing the trend indicator and blue bar as a start of trend up, as there is weakness in the market. Again, a signal ...and it is what follows that either confirms or invalidates the initial signal. Further, context counts. A sign of weakness in a weak background will be more significant.

That's my feeling, currently; there is a background of weakness. (Institutional investors have their eye on Friday and today's rally may be short-lived.) (Fade that comment!)

Signals + Context + Judgement

Regards,
Steve

Attached Thumbnails
Click image for larger version

Name:	Weakness on UpBars.png
Views:	304
Size:	9.6 KB
ID:	21724  
Follow me on Twitter Reply With Quote
  #180 (permalink)
 swimtrader 
Sarasota, FL USA
 
Experience: Advanced
Platform: TOS, NinjaTrader
Broker: Mirus/Zenfire & TOS
Trading: ES
Posts: 22 since Sep 2010
Thanks Given: 0
Thanks Received: 19


After that last comment, I thought it would be wrong to have an opinion. I try and avoid that as much as possible, in my trading!

I use Tom DeMark's systematic approach in decision-making. A TD Supply Line breakout is "unexpected" and if qualifying conditions are met, one can initiate a fresh long position, intra-bar ...i.e. without having to wait for the close to confirm.

So I ran the numbers.

This morning's breakout does not qualify. This adds objective support to TradeGuider's VSA warning. Moreover, this emphasizes the need to use objective measures to minimize subjective bias.

Steve

Attached Thumbnails
Click image for larger version

Name:	TDLine Conditions.png
Views:	266
Size:	24.1 KB
ID:	21738  
Follow me on Twitter Reply With Quote




Last Updated on May 21, 2023


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts