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 28,992 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

  #11 (permalink)
 TradeWind 
Singapore
tw
 
Experience: Intermediate
Platform: NT7
Trading: EUR/USD CL TF
Posts: 73 since Sep 2011
Thanks Given: 80
Thanks Received: 13


Fat Tails View Post
Coloring an indicator by slope is pretty simple. Let us assume that you want to color the first PlotSeries of an indicator, which is called Values[0]. Then you need to define two colors, "upColor" and "downColor", which you use for coloring the slope.

You will then need to take into account three cases: rising slope, falling slope, zero slope. Here is the code

 
Code
if (CurrentBar > 0)
{
       if(Values[0][0] > Values [0][1])  
                 PlotColors[0][0] = upColor;
       else if (Values[0][0] < Values[0][1])
                 PlotColors[0][0] = downColor;
       else 
                 PlotColors[0][0] = PlotColors[0][1];
}
Attached is an example for an indicator, which colors the indicator plot and the paint bars based on slope.


@Fat Tails
How can I use this indicator to pain the SMA slope?
Thank you
tw

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
Increase in trading performance by 75%
The Elite Circle
Better Renko Gaps
The Elite Circle
MC PL editor upgrade
MultiCharts
How to apply profiles
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
GFIs1 1 DAX trade per day journal
17 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
13 thanks
My NQ Trading Journal
12 thanks
  #12 (permalink)
 
ThatManFromTexas's Avatar
 ThatManFromTexas 
Houston,Tx
 
Experience: Advanced
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: TF
Posts: 2,265 since Feb 2010
Thanks Given: 1,206
Thanks Received: 4,353


Fat Tails View Post
If we want to define a neutral zone for the slope, we have to check the slope against volatility. This can be done by using any measure for volatility, for example

-> average true range
-> average range
-> standard deviation

But don't use the ticksize. Attached is an example of an experimental study to color the slope of the midband and the channel lines of the Bollinger Bands. The indicator uses the average true range to normalize slope and has a number of options. For example you may color the channel lines according to their own slope, or according to the slope of the midband.

This indicator is consistent across instruments and timeframes. You can use the same setting for YM 03-12 and ES 03-12, irrespective of their different tick sizes. And if you apply that indicator to a 60 min chart of YM, the neutral zone will not dissolve into nothing. Chart and indicator attached.

@ Trendseek: Would like to know, whether you will apply that method to the RSI.


@Fat Tails

What if you use range bars?

I'm just a simple man trading a simple plan.

My daddy always said, "Every day above ground is a good day!"
Reply With Quote
  #13 (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



ThatManFromTexas View Post
@ Fat Tails

What if you use range bars?

You can easily use the indicator with range bars.

Reply With Quote
  #14 (permalink)
bwfutures
united states
 
Posts: 2 since Mar 2011
Thanks Given: 0
Thanks Received: 0

Hello,
does anyone know where i can find a free basic NT7 TRIX indicator coded one color for rising and another color for falling?

thx

Reply With Quote
  #15 (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
"Slope" does not exist on scalable charts. The concept "Slope" refers to print outs and was used 50 years ago when charts were printed and neither the time scale nor the price scale were ever changed.




Ticks are not suited to normalize momentum or slope

But ticks or tick size are not at all suited, because the ticks do not reflect volatility.

Forget the ticks, you cannot use them for normalization. And best forget the concept of slope, angles and remember that they were just used to visualize momentum, when charts were printed.

Hi Fat Tails

I was wondering what you think about using the slope of a SMA=2. In this case it would be on a 3 RangeNoGap
chart of the 6E. Not sure how to do this:

The chart that use candles shows that I would want candles colored in 3 possible ways.

YELLOW for up move that has significance
RED for no movement or little movement

BLACK for down move that has significance (no example area shown on the chart however)

The chart that uses HiLo bars is what I'd actually be thinking of using, if there is some way to
do this in the end.

Apparently there is no way to color code wicks of candles in NT?? So I am thinking about
color coding entire HiLo bars which is possible and apparently the way to go in this???

The HiLo chart provided is not important at the moment really.


So in the first chart the ideal color coding for the 8 candles/HiLo bars in question would be:

RED RED RED RED RED (No movement in price as shown by SMA=2.)
YELLOW (Price moves up significantly. Slope of SMA=2 seems significant.)
RED (No movement in price as shown by SMA=2.)
RED (Critical bar here. There is little price movement. Slope of SMA=2 is not sharply downward.
Since I'd be applying whatever I used in the end to the HiLo chart, this candle,
because there is almost no price movement, would be colored RED.)

Next HiLo bar would of course be colored YELLOW, as price make another sharp
move to the upside.

I'm looking at the angle of the SMA=2, but from what I thought I read about this matter it
is never good to look at the angle of a moving average or use ticks either??? I'm sure I missed
something somewhere that stated what I should do.

Thanks if you have time for this,

(Only thinking about RangeNoGap charts, and only thinking about a simple moving average
that is a value of 2. Don't know if that would matter. Just an additional comment.)

- Stephen

Attached Thumbnails
Click image for larger version

Name:	3 RangeNoGap with a SMA=2 using candles.png
Views:	308
Size:	77.9 KB
ID:	70035   Click image for larger version

Name:	3 RangeNoGap with a SMA=2 using HiLo bars.png
Views:	302
Size:	74.2 KB
ID:	70036  
Reply With Quote
  #16 (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: It is possible to change the color of the wicks. However in that case also the outline of the candle will be changed. You could try the following code:

 
Code
if (CurrentBar > 0) 
{        
       if(SMA(2)[0] > SMA (2)[1])
       {        
              BarColor = Color.Yellow;
              CandleOutlineColor = Color.Yellow;
       } 
       else if(SMA(2)[0] < SMA (2)[1])
       {        
              BarColor = Color.Black;
              CandleOutlineColor = Color.Black;
       } 
       else
       {        
              BarColor = Color.Red;
              CandleOutlineColor = Color.Red;
       } 
}
Not tested.

Reply With Quote
Thanked by:
  #17 (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
@ stephenszpak: It is possible to change the color of the wicks.

Thanks. The main idea I had was with slope though. It slope totally pointless?
What would you suggest here?

- Stephen

Reply With Quote
  #18 (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
Thanks. The main idea I had was with slope though. It slope totally pointless?
What would you suggest here?

- Stephen

The code above checks for the slope of the SMA(2).

Reply With Quote
  #19 (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
The code above checks for the slope of the SMA(2).

Ok great.

So if the SMA(2) is going sideways, just slightly upwards, and just slightly downwards,
the coloring is RED. I can't see that it does that at the moment.

Reply With Quote
  #20 (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
Ok great.

So if the SMA(2) is going sideways, just slightly upwards, and just slightly downwards,
the coloring is RED. I can't see that it does that at the moment.

Then you need to define what is "slightly". I would use a multiple of the range or average range.

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