NexusFi: Find Your Edge


Home Menu

 





Indicator Programming Help!!! @ ColorfulCandles


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Ph03nix with 2 posts (0 thanks)
    2. looks_two Tasker_182 with 1 posts (0 thanks)
    3. looks_3 shodson with 1 posts (1 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 1,859 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
Ph03nix
Frankfurt + Germany
 
Posts: 3 since Sep 2013
Thanks Given: 0
Thanks Received: 0

Hi guys!

I want to write an indicator which makes all candles grey, except the candles with high volatility. (Ninjatrader)
My volatility base would have been the ATR. So the candles that exceed the ATR or 2*ATR or whatever will be colored (red/green) - if not, it stays grey.

Something is messed up in my code and I would need your help... :S

This is the part where the coloring should happen....

#region Variables
private Color candleOutlineUp = Color.Lime;
private Color candleOutlineDown = Color.OrangeRed;
private Color candleOutlineDoji = Color.White;
private Color candleOutlineNeutral = Color.Gray;
#endregion

/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
CalculateOnBarClose = false;
Overlay = true;
AutoScale = true;
PriceTypeSupported = false;
DisplayInDataBox = false;
PaintPriceMarkers = false;
}
double ATRValue = 0;
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
ATRValue = ATR(24)[0];
if ( (Close[0]-Open[0]) > ATRValue )
BarColor = candleOutlineUp;
if ( (Close[0]-Open[0]) < -ATRValue )
BarColor = candleOutlineDown;
else
BarColor = candleOutlineDoji;
}

Could you help me out?
Thanks!


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Synapse Pro - Trade Copier with topstep and MT5 integrat …
NinjaTrader
SEC and CFTC Unlock Customer Cross-Margining for Treasur …
Treasury Notes and Bonds
Irans Answer Due Today: Peace Surges to 33.5%, Invasion …
Prediction Markets & Event Contracts
Prop Firms Are Banning Gold Trading as Record Prices Mak …
Funded Trading Evaluation Firms
April FOMC Minutes: Most Divided Fed Since 1992 -- Many …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #3 (permalink)
 
Tasker_182's Avatar
 Tasker_182 
Cedar Rapids, iowa
Legendary Market Wizard
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Ninjatrader - Continuum
Posts: 716 since Aug 2009
Thanks Given: 476
Thanks Received: 1,405



Ph03nix View Post
Hi guys!

I want to write an indicator which makes all candles grey, except the candles with high volatility. (Ninjatrader)
My volatility base would have been the ATR. So the candles that exceed the ATR or 2*ATR or whatever will be colored (red/green) - if not, it stays grey.

Something is messed up in my code and I would need your help... :S

This is the part where the coloring should happen....

#region Variables
private Color candleOutlineUp = Color.Lime;
private Color candleOutlineDown = Color.OrangeRed;
private Color candleOutlineDoji = Color.White;
private Color candleOutlineNeutral = Color.Gray;
#endregion

/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
CalculateOnBarClose = false;
Overlay = true;
AutoScale = true;
PriceTypeSupported = false;
DisplayInDataBox = false;
PaintPriceMarkers = false;
}
double ATRValue = 0;
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
ATRValue = ATR(24)[0];
if ( (Close[0]-Open[0]) > ATRValue )
BarColor = candleOutlineUp;
if ( (Close[0]-Open[0]) < -ATRValue )
BarColor = candleOutlineDown;
else
BarColor = candleOutlineDoji;
}

Could you help me out?
Thanks!

Just taking a quick look i don't see anything obvious. Have you tried using Print statements to verify the actual value of ATR? Have you tried using print statements in between the if statements to verify the conditions are true?


Be yourself; everyone else is already taken. Oscar Wilde
Reply With Quote
  #4 (permalink)
Ph03nix
Frankfurt + Germany
 
Posts: 3 since Sep 2013
Thanks Given: 0
Thanks Received: 0

Something is still messed up in my code, but it seems working now.
Thanks


Reply With Quote
  #5 (permalink)
 
shodson's Avatar
 shodson 
OC, California, USA
Quantoholic
 
Experience: Advanced
Platform: IB/TWS, NinjaTrader, ToS
Broker: IB, ToS, Kinetick
Trading: stocks, options, futures, VIX
Posts: 1,971 since Jun 2009
Thanks Given: 534
Thanks Received: 3,711

You are comparing

Close - Open

to your ATR value, but I think you want

High - Low

As volatility is usually a measure of the range of a bar, which is the high - the low.

Also, what is the condition for your neutral color? In your logic every bar will be either an up, down, or doji.


Follow me on X Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on December 10, 2013


© 2026 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 - Downloads - Top
no new posts