NexusFi: Find Your Edge


Home Menu

 





How to make SMA coloured histogram ?


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one inmax with 5 posts (0 thanks)
    2. looks_two Fat Tails with 3 posts (2 thanks)
    3. looks_3 lolu with 2 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 5,706 views
    2. thumb_up 2 thanks given
    3. group 3 followers
    1. forum 10 posts
    2. attach_file 5 attachments




 
Search this Thread

How to make SMA coloured histogram ?

  #1 (permalink)
inmax
Poland
 
Posts: 16 since Oct 2010
Thanks Given: 11
Thanks Received: 2

Hi,

I want to make coloured SMA histogram for BuySellStrength by tulanch.
Indicator you can find: NinjaTrader Support Forum > Links and Downloads Manager > Version 7 Indicators


Question is: How to make the histogram value higher than zero to have a green colour, and for values ​​lower than zero to have a red colour?

I modified the BuySellStrength indicator by adding:
// needed for the average
 
Code
Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "BP"));
and
 
Code
Plot2.Set(buysellstrength);

----------------------------------------
and SMA indicator by adding:
// to illustrate the value higher and lower than zero
 
Code
Add(new Line(Color.FromKnownColor(KnownColor.Black), 0, "Zero"));
The result can be seen in the attached file. There are no colours which I wrote about. Can sombody help me?

Regards,

Attached Thumbnails
Click image for larger version

Name:	6E 06-11 (100 Tick) 2011-04-27.jpg
Views:	254
Size:	85.9 KB
ID:	38670  
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
About a successful futures trader who didn´t know anyth …
Psychology and Money Management
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
How to apply profiles
Traders Hideout
Better Renko Gaps
The Elite Circle
REcommedations for programming help
Sierra Chart
 
  #3 (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,103


Best you post the indicator file. Otherwise you need to add something like

 
Code
if (Values[1] >= 0)
    PlotColors[1][0] = Color.Lime;
else
    PlotColors[1][0] = Color.Red;
If you edit the indicator code below you will get an idea, how to make the colors user selectable.

Attached Files
Elite Membership required to download: DerivativeOscillator.zip
Reply With Quote
  #4 (permalink)
inmax
Poland
 
Posts: 16 since Oct 2010
Thanks Given: 11
Thanks Received: 2

I only need to modify BPSMA indicator. BPSMA is just a SMA standard ninjatrader indicator. I only added zero line:
 
Code
Add(new Line(Color.FromKnownColor(KnownColor.Black), 0, "Zero"));
I just want to modify the usual SMA (which can be found including standard indicators) for a value greater than zero have a green color and the lower value of zero have a red bar color.

My input series for SMA indicator (BPSMA) is: BuySellStrength indicator with Plot "BP", but it could be anything else.
BP is just a variable from BuySellStrength indicator:

 
Code
protected override void Initialize()
{
// ...
Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "BP"));
// ...
}

 
Code
protected override void OnBarUpdate()
{

if (CurrentBar < 1)
return;

long bidvol = GetCurrentBidVolume();
long askvol = GetCurrentAskVolume();

int buysellstrength =  (int) askvol - (int) bidvol;

Plot2.Set(buysellstrength);
}
So, I take variable BP and make SMA but would be nice to see the effect of green bars> 0 and red <0, only by modifying SMA indicator.


UPDATE: 2011-05-16
Fix BPSMA to show if SMA > 0 then green else red.

Attached Thumbnails
Click image for larger version

Name:	6E 06-11 (100 Tick).jpg
Views:	250
Size:	75.6 KB
ID:	38674  
Attached Files
Elite Membership required to download: BuySellStrength.zip
Elite Membership required to download: BPSMA.zip
Reply With Quote
  #5 (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,103

To color the SMA, just add

 
Code
if (Values[0] >= 0)
    PlotColors[0][0] = Color.Lime;
else
    PlotColors[0][0] = Color.Red;
to OnBarUpdate().

Reply With Quote
Thanked by:
  #6 (permalink)
inmax
Poland
 
Posts: 16 since Oct 2010
Thanks Given: 11
Thanks Received: 2


Fat Tails View Post
To color the SMA, just add

 
Code
if (Values[0] >= 0)
    PlotColors[0][0] = Color.Lime;
else
    PlotColors[0][0] = Color.Red;
to OnBarUpdate().

Compile Error: Can not use the operator "> =" to the arguments of operations such as "NinjaTrader.Data.DataSeries" or "int".
CS0019: Error Code Explanation
Strings cannot be compared with relational operators (<, >, <=, >=, ==, !=) to other object types. Strings can only be compared to other strings and only through the use of equality operators (==, !=).

Reply With Quote
  #7 (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,103


inmax View Post
Compile Error: Can not use the operator "> =" to the arguments of operations such as "NinjaTrader.Data.DataSeries" or "int".
CS0019: Error Code Explanation
Strings cannot be compared with relational operators (<, >, <=, >=, ==, !=) to other object types. Strings can only be compared to other strings and only through the use of equality operators (==, !=).

Try "Value[0]" or "Values[0][0]".

Reply With Quote
Thanked by:
  #8 (permalink)
inmax
Poland
 
Posts: 16 since Oct 2010
Thanks Given: 11
Thanks Received: 2


Fat Tails View Post
Try "Value[0]" or "Values[0][0]".

Works well! Many Thanks!

Reply With Quote
  #9 (permalink)
 
lolu's Avatar
 lolu 
Lagos, Nigeria
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader, SierraChart
Trading: Euro Currency & Oil
Frequency: Daily
Duration: Hours
Posts: 2,552 since Jun 2009
Thanks Given: 1,049
Thanks Received: 1,678


inmax View Post
Works well! Many Thanks!

Have you updated the BPSMA posted in post #4 to the one that now works ?

Lolu

Visit my NexusFi Trade Journal Reply With Quote
  #10 (permalink)
inmax
Poland
 
Posts: 16 since Oct 2010
Thanks Given: 11
Thanks Received: 2



lolu View Post
Have you updated the BPSMA posted in post #4 to the one that now works ?

Lolu


Right now, I updated the indicator in post #4.

Regards,
inmax

Reply With Quote




Last Updated on May 16, 2011


© 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