Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I can make the changes when we have agreement on what the changes should be, if that's not too much to ask for. This is the code that is in question:
My thinking is to change the first line to this:
This handles the case where high = low, which really means undermined because there is not much that can be interpreted with a spread like this. I let the value x1 be the average spread. Any other ideas?
The second part (close == low) will set x1 to be 2.3 which will make isDownCloseBar true, isUpCloseBar false, isMidCloseBar false and isVeryHighCloseBar false. This part is ok, but may seem a bit odd in cases where the spread is narrow and isMidCloseBar *could* be true, depending on the spread.
The last part sets x1 to be the spread/(close-low) which is the same as before.
Any questions about my suggestions?
Regards,
-C
“Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat.” - Sun Tzu
Can you help answer these questions from other members on NexusFi?
I'm in over my head here programming-wise and might be reading the code incorrectly but here goes...
1. So if high = low which should be the case in the first iteration of this code on a bar what will X1 be? I took a look at the avgSpread calculations but don't understand how the WildersAverage works:
In this case will it be avgSpread = WildersAverage (0, 30) [0]; ? If so, what will x1 be? (I got the 0 from spread = high - low and the 30 from input volumeEMAlength = 30. It seems to me that on the first iteration of this code on a bar the result should be isMidCloseBar = true.
2. (close = low) will generate a 2.3 which seems right to me.
Yes, I can see that high = low will now generate x1 = 2 and isMidCloseBar = true which seems right to me.
Going further into the assignments I am puzzled by the fact that if, for example, x1 = 1.9 both isUpCloseBar = true and isMidCloseBar = true which seems that it could lead to some problems unless there's code that compensates for this further into the study. If you have a quick answer for this please let me know. If not, I'll put my old programmer's hat on and dig around in the code to see if I can find an answer.
Another related example: if x1 = 2.1 then both isDownCloseBar = true and isMidCloseBar = true.
I'm also noticing some places where the study should report un upThrust and is not doing it. I'm gathering some data on examples as I see them and will report my findings later. For now, let's see what the new isMidCloseBar code does.
This could explain why there are occasionally two symbols for one bar. Just yesterday I saw a few instances - two examples of a green circle (stopping volume) / green square (strength) combo, one example of a Red Square (Upthrust) / yellow circle on the median (effort to fall), and another of a Red Triangle (Upthrust confirmation) / Green Circle (stopping volume).
As I mentioned in my last post I'm gathering data on some anomalies that I encounter. Here are a couple. I'm using the term "mid-stream" to indicate symbols that are drawn before the bar closes. I've also used some CAPS for emphasis. I trade the EUR/USD so the price numbers below should all be pre-pended with "1.".
1. a bar that was initially described as an upThrust bar but when the price FELL mid-stream it lost its status as an upThrust Bar and its Red Square even though it was now a BETTER example of an upThrust bar. Ending OHLC 3062, 3067, 3062, 3062. When the bar was in mid-stream it was 3062, 3067, 3062, and 3064 or so. The closing volume (200) was considerably higher than the previous bar (59) and the bar before that (66). I didn't record the trends but the short term trend should have been up because it was at the end of a 9-bar run starting at 3055 and ending with the high of the bar in question high at 3067. The code that generates a Red Square upthrust is:
Now that I look at it I'm thinking that what might have happened is that the ShortTermTrendSlope might have flipped to <= 0 mid-stream. I'll watch very carefully the next time I see this happen.
2. 2 bars at 5:28 AM PT on GDP news. Red Triangle BEFORE Red Square - Red Tri 3030, 3069, 3029, 3041, vol = 3,052 [huge]; Red Square 3041,3043, 3024, 3027, vol = 2,359 [Big]. I don't understand why the Triangle confirmation appeared in the bar BEFORE the initial upThrust Red Square.
As you can see I've started to dig through the code and I have a few questions that I hope you can answer.
I thought that def creates single variables whereas rec creates arrays. The [0] in this line seems to indicate that avgSpread is an array.
2. What is Double.NaN and what does it do? I get that NaN is Not a Number but have no idea of how it functions.
3. How do the TrendSlopes work? Is it that values > 0 for each indicate an uptrend with 0 indicating no trend and values < 0 indicating a downtrend?
4. How many decimal places are in each floating point number?
Thanks again! Yesterday when I studied my charts after market close I saw that in a number of instances the study gave a clear indication of market direction. With each day I become more and more confident that learning to apply it to my trading will lead to a very profitable future.
I thought that def creates single variables whereas rec creates arrays. The [0] in this line seems to indicate that avgSpread is an array.
WildersAverage returns an array. The [0] at the end of the line indicates that the assignment to avgSpread should be the value at the 0 index of the array. It's innocuous however since "WildersAverage(spread, volumeEMAlength)" will return the same value.
snowcloud
2. What is Double.NaN and what does it do? I get that NaN is Not a Number but have no idea of how it functions.
Double.NaN is used in the thinkscript plot to indicate that somthing should not be plotted. Thinkscript does not allow arbitrary items to be put on a chart, so you plot a line and turn "on" or "off" values at each bar. Take the red square at the top of the bar for example, the plot is made for every bar but only "turned on" when the criteria is met. Otherwise it is "turned off" by setting the value to Double.NaN.
snowcloud
3. How do the TrendSlopes work? Is it that values > 0 for each indicate an uptrend with 0 indicating no trend and values < 0 indicating a downtrend?
If you are referring to the chart labels for long, mid and short term trend, then the evaluation is done on the linear regression for long, mid and short terms. "Up" is when the slope is positive (>0), down otherwise. There is no flat according to the original NT code. This is the ToS code:
Quote:
If you are referring to the chart labels for long, mid and short term trend, then the evaluation is done on the linear regression for long, mid and short terms. "Up" is when the slope is positive (>0), down otherwise. There is no flat according to the original NT code. This is the ToS code:
OK, let's see how close I can come to describing in English what's going on here. Please correct my errors.
First, the 5-bar simple moving average based upon each bar's close is placed into a 5-cell array named fiveDaysSma.
Next, 3 trends are defined for LT, MT, and ST by creating arrays of 40, 15, and 5 cells respectively. Only the current [0] value is used to define each slope. (It is not clear to me how the LinearRegressionSlope function creates, for example, a 40 cell array with only 5 cells of data in fiveDaysSma).
Is this description close to correct?
Currently I'm using the VSA study in my 2-minute, 5-minute, and 15-minute charts. Does this mean that the LongTermTrendSlope using 40 cells covers the last 80 minutes on the 2-minute chart , the last 200 minutes on the 5-minute chart, and the last 600 minutes on the 15-minute chart?
****
On another topic I found a possible bug in the code for noSupplyBar. The code for noDemandBar fits pretty well with the description of No Demand and of a No Demand Up-Bar in the glossary of Williams' first book Master the Markets. The study defines it as an Up bar with narrow spread closing down on volume that has been decreasing over a 2 bar period. Williams' book doesn't define it quite as explicitly but the study's code seems to be a good fit.
However, in the code for noSupplyBar I think that the last term should be isUpCloseBar not isDownCloseBar. No Supply implies lack of selling pressure which would be more evident if the bar closes up not down.
Next, 3 trends are defined for LT, MT, and ST by creating arrays of 40, 15, and 5 cells respectively. Only the current [0] value is used to define each slope. (It is not clear to me how the LinearRegressionSlope function creates, for example, a 40 cell array with only 5 cells of data in fiveDaysSma).
Is this description close to correct?
Amost.
The LRS is not computing 40 bars worth of approximation using 5 bars from the SMA. Rather, each value in the 40 position array is the avareage computed by the 5 bar SMA at that time.
The latest value added to the LRS is the 5 bar sma, which is this: (c[4]+c[3]+c[2]+c[1]+c[0])/5
The previous value for the LRS is the same thing, but you can compute it again using the most recent bar: (c[5]+c[4]+c[3]+c[2]+c[1])/5
And so on up until you reach 40 for the LT, 15 for the MT, etc. Notice how the index advances every time a new bar comes into existance.
Think of the 5 bar sma as a line on the graph, the LRS computes the slope of the line between 2 points on that graph: 40, 15 and 5 bars away (roughly speaking).
snowcloud
On another topic I found a possible bug in the code for noSupplyBar. The code for noDemandBar fits pretty well with the description of No Demand and of a No Demand Up-Bar in the glossary of Williams' first book Master the Markets. The study defines it as an Up bar with narrow spread closing down on volume that has been decreasing over a 2 bar period. Williams' book doesn't define it quite as explicitly but the study's code seems to be a good fit.
However, in the code for noSupplyBar I think that the last term should be isUpCloseBar not isDownCloseBar. No Supply implies lack of selling pressure which would be more evident if the bar closes up not down.
Makes sense to me. I don't have the NT code with me to compare with. I could have made a mistake in conversion, but the entire reason why I've documented the process on this thread is so mistakes can be identified and corrected
snowcloud
I am going through the study's code line-by-line and comparing it with Williams' definitions and descriptions. I'll report issues as I find them.
This is something I've been wanting to do but I don't have the time. I appreciate your efforts!!
Regards,
-C
“Strategy without tactics is the slowest route to victory. Tactics without strategy is the noise before defeat.” - Sun Tzu