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 shodson with 1 posts (1 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 Tasker_182 with 1 posts (0 thanks)
    1. trending_up 1,343 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread

Indicator Programming Help!!! @ ColorfulCandles

  #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?
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Futures True Range Report
The Elite Circle
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
The Program
18 thanks
Battlestations: Show us your trading desks!
18 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,401



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,976 since Jun 2009
Thanks Given: 533
Thanks Received: 3,709

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 Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on December 10, 2013


© 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