Coloring an IndicatorLine by Slope: Questions for Optimal Coding

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 don’t 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.

Everything is possible. Just set up the rules, and it can be coded in a few minutes.

Do you now intend to color the candles according to the slope of the moving average or according to the condition, whether they close inside or outside the bands?

Dojis can be accounted for as neutral candles.

What do you want to color, the moving average, the bands, the candles or the candle outlines?

There might be a way to improve upon the color coding of your new ThrustBars indicator, using
the BollingerUniversalX indicator but I've given up. Tried different parameters in the BollingerUniversalX
but there must be some hidden math, or whatever it's called, going on within the ThrustBars that is
somewhat better. Sometimes the bands would be slightly too wide or too narrow causing late
signals or false signals.

All set using your new ThrustBars indicator, unless something better comes along. I suppose I'll
always think there's something better (ha, ha).

It is some time that I had been looking for the post of William Eckhardt on the C-Test. It is one of the best explanations available, why the concept of angles does not work on scalable charts.

Here is the text, which was originally published in Technical Analysis of Stocks & Commodities V12:5, and which can be found in various internet blogs:

We all know that thorough testing is the only way to determine whether a particular trading system or indicator is viable. William Eckhardt, the mathematician whose conversation with Richard Dennis helped bring about the Turtles, points out that before you spend time testing a method, you should first use a methodological test for dimensional coherency called the c-test. Eckhardt explains.

In most cases, the only way to evaluate trading indicators or systems is through diligent and rigorous testing. However, there are cases in which indicators, systems or even entire approaches can be rejected on principle. A good way to root out the unworkable indicators, systems or approaches is to apply a c-test, which is a methodological test for dimensional coherency. A system can be said to be dimensionally coherent if its results do not change even though the units of measure do. The test is applied directly to the formulas or rules that define a system or indicator. If the system or indicator fails the c-test, then it will give incoherent results that cannot be trusted; however, a formula determined to be incoherent can often be modified to pass the c-test.

To determine why a coherency test is necessary, first we look at some charting procedures that we suspect may be incoherent — for example, the fallacy of attaching significance to the sizes of angles on a bar chart or similar price graph. It is not that trading systems making use of angles are inferior — there is such a glut of bad systems in general that it would hardly be worthwhile to identify only a few — but rather, these angle-dependent trading systems are pseudo-systems, incoherent procedures disguised as algorithms.

What holds true in a particular system should hold true no matter what the measurement. Now, a change in one unit may necessitate a change in others; if you change the unit of distance, then you must make corresponding changes to the unit of area or volume. However, in price analysis, the overriding variables of price and time are so heterogeneous that a change in the scale of one may occasion no need for a change in the scale of the other. (Chart services frequently rescale the price axes of their charts while leaving the time scales the same year after year.) Clearly, then, it should be possible to change the units for price and time separately in a valid rule — for example, if corn must rally 15 cents in five trading days, then it is also true that corn must rally 0.15 dollars in five trading days or 15 cents in one week. The meaning should not change, only the way in which it is stated.

RIGHT ANGLE INCLINATIONS
The fallacy concerning the sizes of angles in a bar chart or price graph arises from ignoring price/time heterogeneity. As an example, consider the claim that a major downtrend and the subsequent uptrend tend to be at right angles to each other. In Figure 1, the first chart conforms to the right-angle rule; in Figure 2, the uptrend falls short of the right-angle projection; in Figure 3, the uptrend exceeds the projection. The problem: These are all charts of the same price series (December 1989 gold, July 17, 1989, to December 1, 1989), but only the vertical price scale is different. This technique is likely to give the user varying results depending on the chart service he or she uses.

RELATIVE INCLINATION
Relative inclination fares no better. Here, the rule is that in the first two legs of a bull move, the angular inclination above the horizontal axis of the second leg is twice that of the first leg. Initially, this may appear to be a coherent prediction of the behavior of the second leg given that of the first, but what if the first leg climbs at more than 45 degrees? The rule predicts that the second leg will incline at more than 90 degrees — that is, it has to backtrack in time. And whatever the angular inclination of the first leg on the original chart, there exists a rescaling of the price axis in which this first leg climbs at more than 45 degrees. Thus, this rule is incoherent. It cannot stand up to the c-test.

Note that these geometric angle lines should not be confused with classical chart trendlines, which are defined as incidence properties — connecting points on a chart — and not in terms of angles. In Figures 1, 2 and 3, the downtrend line crosses the price series at the same price and on the same day.

A price chart is an attempt to model relevant aspects of price change. Price change is not linear displacement, whether vertical, horizontal or oblique. Nonetheless, price change can be represented as vertical displacement and time elapsed as horizontal displacement. Such a model, however, invariably supports relationships that does not correspond to anything in the original process.

The angular inclination of a trend on a price chart is a visually striking feature of this representation. Such angles have no intrinsic meaning for the price series, but this is one of the many factors (along with our facility for pattern recognition and wishful thinking) that contributes to our interpreting more from price charts than rigorous testing reveals is there.

FRACTAL EFFICIENCY
Sophisticated geometric constructions can have the same problems as simpler angular formulations. For a recent example, Hans Hannula defines a fractal efficiency indicator for a lookback of n days:

where P1,...,Pn are n consecutive closes. This expression is multiplied by -1 if Pn- P1 is negative.

And whatever the angular inclination of the first leg on the original chart, there exists a rescaling of the price axis in which this first leg climbs at more than 45 degrees. Thus, this rule is incoherent. It cannot stand up to the c-test.

Here, price and time variables are combined in such a way as to make it impossible for the indicator to retain the relative importance of price action and time change when both axes are rescaled independent of each other. The trader who prices a market in dollars finds that time components mean much more to that market's fractal efficiency than the trader who prices the same market in cents. This dimensional difference is not insignificant. Consider the following three-day price series:

Day
Series 1 2 3
1 50.00 50.60 50.80
2 52.00 52.50 52.40

The first has a fractal efficiency of 1.420..., while the second has a slightly higher one of 1.425.... Now suppose we multiply all these prices by 100, signaling a unit change from dollars to cents. In these units, the first series (5000, 5060, 5080) has a fractal efficiency of 1.000..., but the second (5200, 5250, 5240) has a lower fractal efficiency of 0.667.... Thus, fractal efficiency ranks these price series in an irrational and incoherent manner.
The only way to rid equation 1 of this ranking incoherency is to eliminate the time terms. The modified formula reduces to:
[2] Pn-Pn-1/ABS(P2-P1)+ABS(P3-P2)+...+ABS(Pn-Pn-1)

Simplified and divested of the surrounding incoherencies, the true formula becomes apparent. It is the net change divided by a close-to-close path length.

THE C-TEST
These ideas can be used to regulate system development. In essence, the c-test transforms relevant formulas in an indicator or system by multiplying every price term by a positive constant c (cą1), while leaving nonprice terms the same. If the transformed indicator or system gives the same indications or signals as the original, then it has passed the c-test. If not, the formulation in question is incoherent and depends unacceptably on the units chosen.

Let us examine in this connection a commonly used measure of trend strength, the n-velocity:
[3]VELn=(Pn-P1)/(n-1)

A c-test of the velocity has the effect of multiplying the whole expression by c; all velocities grow or shrink in concert. This indicates that the value of veln cannot be given absolute significance; to be coherent, a system or indicator must relate veln to something else.

This defect can be repaired in many ways. We might compare the strength of two trends by measuring the ratio of their velocities. The reader can check that a ratio of velocities is left unchanged in a c-test, as the net effect is to multiply both numerator and denominator by c. The velocity ratio is a dimensionally correct measure of relative trend strength, something that could not be constructed by means of trend angles. Because the velocity of a vertical line is effectively infinite, no doubling of a velocity gives a vertical ascent or goes beyond the vertical. However, the velocity ratio can only be useful if the denominator measures the velocity of a trend. The ratio behaves erratically if the denominator remains near zero.

A MORE APPLICABLE MEASURE
Seeking a more universally applicable measure, we might divide VELn by Pn:
[4]
(Pn-P1)/(n-1)Pn

to derive a percent of price velocity that clearly passes the c-test.
Equation 4 is dimensionally sound but flawed in other respects. Different futures contracts have different characteristic ranges of percent of price velocity, making it difficult to research this measure across contracts. (The velocity ratio shares this drawback.) We might seek to universalize the percent of price velocity further, perhaps by gauging it, in any given contract market relative to some historic norm for that market.

The analysis of price series is fraught with perils. A common pitfall is to research formulations that are dependent on arbitrary factors such as choice of units. A c-test performed on any proposed system or indicator before embarking on any statistical testing would save time and would aid in the avoidance of many errors.

William Eckhardt is a mathematician who has been trading since 1974. He has an extensive background in the history of scientific methodology as well as mathematical statistics, both of which have been instrumental in the development of his trading program. In addition, Eckhardt was profiled in Jack Schwager's The New Market Wizards. Currently, he is an officer of C&D Commodities, Inc.

REFERENCES
Hannula, Hans [1993]. “Polarized fractal efficiency,” Technical Analysis of STOCKS & COMMODITIES,
Volume 12: January.

The following 4 users say Thank You to Fat Tails for this post:

I recall this article from way back (I actually have all paper magazine copies from early 80's until now). It appears that none of the many Slope indicators are really worth a hoot, so can there really be a slope indicator? I don't know.

But, back then I came up with something for Metastock that was a derivative of the Velocity formula that I called Accelerator. It was a go/no-go tool and worked great in those days when we did not have the e-minis. I am not sure if it still works in this HFT environment.

Cheers!

Last edited by aligator; June 27th, 2012 at 05:20 PM.

The following user says Thank You to aligator for this post:

Have now updated the Bollinger Universal and Keltner Universal indicators.

You can select the midband from moving median, moving mode and 27 moving averages. Period for the midband and the smoothing period for the range or true range can be different. Both indicators allows to color the plots according to their slope or alternatively according to the slope of the midband. The range where the slope is considered neutral can be adjusted. It is possible not to display midband or channels.