Coloring an IndicatorLine by Slope: Questions for Optimal Coding - NinjaTrader Programming | futures io social day trading
futures io futures trading


Coloring an IndicatorLine by Slope: Questions for Optimal Coding
Updated: Views / Replies:14,499 / 59
Created: by Trendseek Attachments:19

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.

-- Big Mike, Site Administrator

Reply
 19  
 
Thread Tools Search this Thread
 

Coloring an IndicatorLine by Slope: Questions for Optimal Coding

  #51 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,602 received
Forum Reputation: Legendary


Rad4633 View Post
@Fat Tails

Sir, I was wondering do you have a combo indicator with the bollinger and keltner channels together? , Ive seen one months back that colors candles up or down based off bands and squeeze of both bollinger/keltner. Sorry no picture at this time but Im 100% sure you know what Im referring too

thx in advance for your reply
R


You can add both a UniversalKeltner and Universal Bollinger Band indicator to your chart. If you want to get alerted to a squeeze (Bollinger Band inside Keltner Channel), there is a squeez indicator in the downloads.

So far, I have not coded an indicator that combines both Bollinger Bands and Keltner Channels. I have posted a screenshot some time ago, of a multi-timeframe Keltner Channel. which shows a larger and smaller timeframe Keltner Channel.

Reply With Quote
The following 2 users say Thank You to Fat Tails for this post:
 
  #52 (permalink)
Elite Member
Dallas, TX/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: ES, CL
 
Posts: 46 since Aug 2013
Thanks: 52 given, 6 received

Slope Measure

Can someone point me to the slope measurement for NT that Fat Tails references.

Reply With Quote
 
  #53 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,602 received
Forum Reputation: Legendary



KrazyTrader View Post
Can someone point me to the slope measurement for NT that Fat Tails references.

Slope is a geometrical measure that depends on the chart compression. With scalable charts, the concept of slope or angles is void.

In the past slope was used as a proxy for momentum. A "steep" trend line was showing that momentum over that period was high. A "flat" trendline would show that momentum was close to zero.

Momentum is just the size of the price move, where an upmove is seen as positive and a downmove is seen as negative momentum. Instead of the slope of a moving average or a linear regression line you would rather measure rise over run. Some explanations are here:

Slope [ChartSchool]

The absolute value of the rise over run does not tell you whether the market is trending or sideways. If you look at a 240 min chart the momentum measured over 20 bars can take much higher values, then the 20-bar momentum on a 1 min chart. Also the momentum depends on the tick value and volatility of an instrument.

Therefore to get a comprehensive and normalized measure for slope or steepness of a move, you need to put the size of that move into relationship with the average bar size. Divide the rise over run - or momentum - by either

- the SMA of the simple range over an extended lookback period
- the SMA of the average range over that lookback period
- or the standard deviation over that lookback period

and you will get a measure for the strength of a move that is coherent across all instruments and timeframes.

Reply With Quote
The following 2 users say Thank You to Fat Tails for this post:
 
  #54 (permalink)
Elite Member
Dallas, TX/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: ES, CL
 
Posts: 46 since Aug 2013
Thanks: 52 given, 6 received


Fat Tails View Post
Slope is a geometrical measure that depends on the chart compression. With scalable charts, the concept of slope or angles is void.

In the past slope was used as a proxy for momentum. A "steep" trend line was showing that momentum over that period was high. A "flat" trendline would show that momentum was close to zero.

Momentum is just the size of the price move, where an upmove is seen as positive and a downmove is seen as negative momentum. Instead of the slope of a moving average or a linear regression line you would rather measure rise over run. Some explanations are here:

Slope [ChartSchool]

The absolute value of the rise over run does not tell you whether the market is trending or sideways. If you look at a 240 min chart the momentum measured over 20 bars can take much higher values, then the 20-bar momentum on a 1 min chart. Also the momentum depends on the tick value and volatility of an instrument.

Therefore to get a comprehensive and normalized measure for slope or steepness of a move, you need to put the size of that move into relationship with the average bar size. Divide the rise over run - or momentum - by either

- the SMA of the simple range over an extended lookback period
- the SMA of the average range over that lookback period
- or the standard deviation over that lookback period

and you will get a measure for the strength of a move that is coherent across all instruments and timeframes.

Fat Tails- words can not describe my thanks to you and your mentoring.

Reply With Quote
 
  #55 (permalink)
Market Wizard
New Orleans, La (Mardi Gras City)
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Ninjatrader / Optimus Futures / AmpFutures
Favorite Futures: ES / 6E / 6B / CL
 
DavidHP's Avatar
 
Posts: 1,002 since Aug 2009
Thanks: 803 given, 1,367 received


Fat Tails View Post
Slope is a geometrical measure that depends on the chart compression. With scalable charts, the concept of slope or angles is void.

@Fat Tails

I've monitored several of the posts on futures.io (formerly BMT) about angles and slopes and it all sounds reasonable considering the type of charts created by NT.

This made me think that maybe there are other considerations about this.

If a trendline is drawn on a tick chart, and lows or highs are connected in the series.
Many times if the lines are set to show on "ALL CHARTS" the lines are either off by a small to considerable amount on range or other chart types.
When trendlines are drawn on tick charts many times the duplicated trendline on a minute chart is totally off the scale.

Would this type of issue, invalidate trendlines?
Does that mean the concept of 'touches' of trendlines is just snake oil since it is dependent upon the type of chart and is not universal?
Or am I over thinking the issue?

Thanks for your response.

Rejoice in the Thunderstorms of Life . . .
Knowing it's not about Clouds or Wind. . .
But Learning to Dance in the Rain ! ! !
Reply With Quote
 
  #56 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,602 received
Forum Reputation: Legendary


DavidHP View Post
@Fat Tails

I've monitored several of the posts on futures.io (formerly BMT) about angles and slopes and it all sounds reasonable considering the type of charts created by NT.

This made me think that maybe there are other considerations about this.

If a trendline is drawn on a tick chart, and lows or highs are connected in the series.
Many times if the lines are set to show on "ALL CHARTS" the lines are either off by a small to considerable amount on range or other chart types.
When trendlines are drawn on tick charts many times the duplicated trendline on a minute chart is totally off the scale.

Would this type of issue, invalidate trendlines?
Does that mean the concept of 'touches' of trendlines is just snake oil since it is dependent upon the type of chart and is not universal?
Or am I over thinking the issue?

Thanks for your response.

You have correctly observed that the exact location of a trendline depends on the bar type and bar period. The same is true for a SMA. A SMA on a tick chart will be in a different location than the same period SMA on a minute chart. This does not entirely invalidate these tools for analyzing markets. However, if you apply such tools to exotic bar types, then it is questionable whether there is any support and resistance at the exact location where they print.

The main point to consider is that trendlines and moving averages and many other tools rely on self-fulfilling prophecy. A trendline will only produce a reaction, if that same trendline is watched by any other traders. If you are the only one to watch it on your exotic chart, then it may be well ignored.

This leads us to the question whether there are tools available that do not depend on the bar type and the bar period of a chart and help to find S/R on all charts at the same time. And yes, such tools exist. Please have a look at the VWAP, the market profile or the floor and GLOBEX pivots. But even these tools rely on self-fulfilling prophecy - swarm behaviour - to work.

Reply With Quote
The following 6 users say Thank You to Fat Tails for this post:
 
  #57 (permalink)
Elite Member
Sydney
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: Forex
 
Posts: 63 since Nov 2015
Thanks: 31 given, 40 received

Sorry to re-open this old thread.

Imagine a strategy that buys a bullish candlestick pattern. I want to improve this strategy by only buying when the 20SMA is "rising". For that I've been using a very simple method.

 
Code
private bool IsMARising(int period, EnumMAType type)
{
	double dMA1 = MA(period, type, 0);
	double dMA2 = MA(period, type, 1);
	if (dMA1 > dMA2)
	{
		return true;
	}
	return false;
}
So to know if the 20SMA "is rising", I would call IsMARising(20, EnumMAType.Simple).

@Fat Tails posted a very nice indicator, the "Bollinger Universal V4" that correctly shows if a 20SMA is "rising".

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


What I would like to do is change my IsRising method to something like


 
Code
private bool IsMARising(int period, EnumMAType type)
{
	if( Fat Tail's indicator shows the line in green)
		return true;
	else
		return false;
}
I can see exactly on the OnBarUpdate of anaBollingerUniversal.cs where the lines are made Green, Red or Yellow.

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


However I don't know how to "output" this value so I could later on read it from within my IsMARising() method.

 
Code
// method called on OnBarUpdate. It will return true or false for the CurrentBar
private bool IsMARising(int period, EnumMAType type)
{
	// assume the instantiation was successful
	IndicatorBase ind = anaBollingerUniversal(Input, midbandMAType, numStdDev, period, smoothed, stdDevPeriod, threshold);
	// 1 = Up, 0 = Neutral, -1 = Down
	if(ind.TrendDirection > 0)
		return true;
	else 
		return false;
}
I tried to create a public property TrendDirection of this indicator, that would return 1,0 or -1, however I can't access it from within my strategy. This is a bit outside my skills, could anyone give a hand please?

I will keep trying and update if I manage to do it.

Thanks everyone for this excellent thread and thanks Fat Tail for the indicator.

Leo


Last edited by little leo; March 7th, 2016 at 10:35 PM. Reason: spelling
Reply With Quote
 
  #58 (permalink)
Elite Member
Sydney
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: Forex
 
Posts: 63 since Nov 2015
Thanks: 31 given, 40 received

Here it is, it works great!

 
Code
private bool IsMARising(int period, EnumMAType type)
		{
			// convert between enums (because my strategy uses different enums for MA types)
			anaBollingerMAType midbandMAType;
			switch (type) 
			{
				case EnumMAType.SMA:
					midbandMAType = anaBollingerMAType.SMA;
					break;
				case EnumMAType.EMA:
					midbandMAType = anaBollingerMAType.EMA;
			}
			double numStdDev = 2.0; // not using, just interested in the MA
			bool smoothed = true;
			int stdDevPeriod = 20; // not using, just interested in the MA
			int threshold = 30; // Slope as percentage of average true range

			Indicator.anaBollingerUniversal ind = anaBollingerUniversal(midbandMAType, numStdDev, period, smoothed, stdDevPeriod, threshold);
			// line is green
			if (ind.Trend[0] > 0)
			{
				return true;
			}
			else {
				return false;
			}
			/* old code
			double dMA1 = MA(period, type, 0);
			double dMA2 = MA(period, type, 1);

			if (dMA1 > dMA2)
			{
				return true;
			}
			return false;
			*/
		}

Reply With Quote
 
  #59 (permalink)
Elite Member
Dallas, TX/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: ES, CL
 
Posts: 46 since Aug 2013
Thanks: 52 given, 6 received


little leo View Post
Here it is, it works great!

 
Code
private bool IsMARising(int period, EnumMAType type)
		{
			// convert between enums (because my strategy uses different enums for MA types)
			anaBollingerMAType midbandMAType;
			switch (type) 
			{
				case EnumMAType.SMA:
					midbandMAType = anaBollingerMAType.SMA;
					break;
				case EnumMAType.EMA:
					midbandMAType = anaBollingerMAType.EMA;
			}
			double numStdDev = 2.0; // not using, just interested in the MA
			bool smoothed = true;
			int stdDevPeriod = 20; // not using, just interested in the MA
			int threshold = 30; // Slope as percentage of average true range

			Indicator.anaBollingerUniversal ind = anaBollingerUniversal(midbandMAType, numStdDev, period, smoothed, stdDevPeriod, threshold);
			// line is green
			if (ind.Trend[0] > 0)
			{
				return true;
			}
			else {
				return false;
			}
			/* old code
			double dMA1 = MA(period, type, 0);
			double dMA2 = MA(period, type, 1);

			if (dMA1 > dMA2)
			{
				return true;
			}
			return false;
			*/
		}


I'm attempting the same thing with @Fat Tails Keltner Universal indicator. Did you add code to anaBollinger or is this a separate indicator reference anaBollinger?

Thanks.

Difference between discomfort and pain = 1 tick
Reply With Quote
 
  #60 (permalink)
Elite Member
Berlin, Europe
 
Futures Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,653 since Mar 2010
Thanks: 4,226 given, 25,602 received
Forum Reputation: Legendary



KrazyTrader View Post
I'm attempting the same thing with @Fat Tails Keltner Universal indicator. Did you add code to anaBollinger or is this a separate indicator reference anaBollinger?

Thanks.


Those indicators already come with a public property that allows for catching the trend. The public property is called Trend and can take the three values

+1 for an uptrend (blue)
- 1 for a downtrend (red)
0 for a neutral trend (gray)

The trend is based on the slope of the midline of the channel.

You can directly access these values via the Strategy Builder, the Market Analyzer or another indicator. You do not need to code anything. The public property Trend is available with both the Bollinger Universal and the Keltner Universal indicators.

Below is a picture showing the three different trend states.

It is possible to use the indicator with two trend states only (uptrend or downtrend). This can be achieved by setting the neutral threshold parameter to 0.


Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Reply With Quote
The following user says Thank You to Fat Tails for this post:

Reply



futures io > > > > > Coloring an IndicatorLine by Slope: Questions for Optimal Coding

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Some Basic NinjaTrader Coding Questions -- IDataSeries Crow NinjaTrader Programming 7 October 15th, 2017 04:49 AM
Tricky NinjaScript coding {questions} . . . jmejedi NinjaTrader Programming 10 August 2nd, 2014 10:09 PM
InvestorRT axis label coloring Big Mike Investor/RT 3 August 18th, 2011 07:53 AM
NT MA with BG coloring emini_Holy_Grail NinjaTrader 10 January 11th, 2011 07:29 AM
On finding the optimal settings for a range interval trendisyourfriend The Elite Circle 5 December 7th, 2010 02:53 PM


All times are GMT -4. The time now is 07:52 PM.

Copyright © 2017 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
Page generated 2017-12-15 in 0.18 seconds with 20 queries on phoenix via your IP 54.163.61.66