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!