NexusFi: Find Your Edge


Home Menu

 





Coloring an IndicatorLine by Slope: Questions for Optimal Coding


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Fat Tails with 24 posts (87 thanks)
    2. looks_two stephenszpak with 12 posts (0 thanks)
    3. looks_3 Big Mike with 3 posts (4 thanks)
    4. looks_4 Trendseek with 3 posts (15 thanks)
      Best Posters
    1. looks_one Trendseek with 5 thanks per post
    2. looks_two Fat Tails with 3.6 thanks per post
    3. looks_3 NJAMC with 1.5 thanks per post
    4. looks_4 Big Mike with 1.3 thanks per post
    1. trending_up 29,018 views
    2. thumb_up 111 thanks given
    3. group 22 followers
    1. forum 59 posts
    2. attach_file 19 attachments




 
Search this Thread

Coloring an IndicatorLine by Slope: Questions for Optimal Coding

  #31 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


stephenszpak View Post

In the 6E using 3 RangeNoGap charts these dojis are always coming up.
If the bands are widened to include all the dojis, then candles that should go bullish or bearish
have closes within the bands and would be colored neutral.

Is there a way to make all dojis with the same close neutral, regardless of what
the computations of BollingerUniversalX come up with, within some code? I believe you
said once that NT can't do stuff like that.

- Stephen

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?

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
REcommedations for programming help
Sierra Chart
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
MC PL editor upgrade
MultiCharts
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
18 thanks
  #32 (permalink)
 
stephenszpak's Avatar
 stephenszpak 
Massachusetts (USA)
 
Experience: None
Platform: NinjaTrader
Trading: YM
Posts: 750 since Jun 2009
Thanks Given: 144
Thanks Received: 356


Fat Tails View Post
Everything is possible.

I like your attitude!

Reply With Quote
  #33 (permalink)
 
stephenszpak's Avatar
 stephenszpak 
Massachusetts (USA)
 
Experience: None
Platform: NinjaTrader
Trading: YM
Posts: 750 since Jun 2009
Thanks Given: 144
Thanks Received: 356



Fat Tails View Post
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).

Thanks,

- Stephen

Reply With Quote
  #34 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


stephenszpak View Post
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).

Thanks,

- Stephen

I have several good friends, who are not married. They always thought that there would be someone better.

Reply With Quote
Thanked by:
  #35 (permalink)
 
stephenszpak's Avatar
 stephenszpak 
Massachusetts (USA)
 
Experience: None
Platform: NinjaTrader
Trading: YM
Posts: 750 since Jun 2009
Thanks Given: 144
Thanks Received: 356


Fat Tails View Post
I have several good friends, who are not married. They always thought that there would be someone better.

On a more serious note...

I am just throwing this out as an idea. I don't say I myself even have a great
deal of interest in it. Maybe others might.

1) This would be off topic for this thread, but since we're sort of talking about it,
maybe there is/was a thread listing all the charting methods.

{ No moving
averages or indicators
, just the charts. For example, NoGapRange, generic candlestick,
Kase, Momemtum, Renko Hybrid, etc.}

2) Maybe a running poll on the thread as time passes and perhaps new charting
ideas come along over the years.

I am positive that some charts are just harder to read than others.

- Stephen

Reply With Quote
  #36 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102

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:

[1] SQRT((Pn-P1)*(Pn-P1)+n)/SQRT((P2-P1)*(P2-P1)+1)+SQRT((P3-P2)*(P3-P2)+1)+...+SQRT((Pn-Pn-1)*(Pn-Pn-1)+1)

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.

Reply With Quote
Thanked by:
  #37 (permalink)
 
aligator's Avatar
 aligator 
Las Vegas, NV
Legendary Market Wizard
 
Experience: Advanced
Platform: Abacus, Slide Rule, HP-65
Trading: Futures, Stocks, Options
Posts: 3,620 since Aug 2010
Thanks Given: 1,071
Thanks Received: 5,992


Fat Tails View Post
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.

@Fat Tails;

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!

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #38 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


aligator View Post
@Fat Tails;

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!

@aligator: Slope is just a graphical representation of momentum. If you have a software package with scalable charts, just measure momentum!

Reply With Quote
  #39 (permalink)
 
aligator's Avatar
 aligator 
Las Vegas, NV
Legendary Market Wizard
 
Experience: Advanced
Platform: Abacus, Slide Rule, HP-65
Trading: Futures, Stocks, Options
Posts: 3,620 since Aug 2010
Thanks Given: 1,071
Thanks Received: 5,992


Fat Tails View Post
@aligator: Slope is just a graphical representation of momentum. If you have a software package with scalable charts, just measure momentum!

Thanks , Yes, I got your point many years ago when I started using the "Accelerator", a form of momentum formula.

Visit my NexusFi Trade Journal Reply With Quote
  #40 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


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.

The indicators can be found here:








Reply With Quote
Thanked by:




Last Updated on May 25, 2016


© 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