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,942 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?
Saylors 41-Month HODL Breaks: Strategy Sells 32 BTC as $ …
Prediction Markets & Event Contracts
Post-Summit Market Verdict: ES -1%, NQ -1.5%, 10-Year Yi …
Traders Hideout
Warsh Drops Easing Bias, December Hike Now Above 50% -- …
Prediction Markets & Event Contracts
Warsh Rate Hike at 40%, Iran June 15 Expires Tonight at …
Prediction Markets & Event Contracts
CME Raises Energy Futures Margins After Iran-War Volatil …
Commodities
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
15 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 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,406



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
 
Experience: Advanced
Platform: IB/TWS, NinjaTrader, ToS
Broker: IB, ToS, Kinetick
Trading: stocks, options, futures, VIX
Posts: 1,972 since Jun 2009
Thanks Given: 534
Thanks Received: 3,720

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