can you help with code, would like to paint low volume bar black - futures io
futures io futures trading



can you help with code, would like to paint low volume bar black


Discussion in NinjaTrader

Updated
    1. trending_up 2,313 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 4 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

can you help with code, would like to paint low volume bar black

(login for full post details)
  #1 (permalink)
london
 
Experience: Beginner
Platform: ninja
Trading: fgbl
 
Posts: 152 since Nov 2009
Thanks: 64 given, 44 received

why is this not working??
would like to paint volume bar black if it is below a certain amount
protected override void Initialize()
{
Add(new Plot(new Pen(Color.Lime, 2), PlotStyle.Bar, "UpVolume"));
Add(new Plot(new Pen(Color.Red, 2), PlotStyle.Bar, "DownVolume"));
Add(new Plot(new Pen(Color.Black, 2), PlotStyle.Bar, "LowVol"));
Add(new Line(Color.DarkGray, 0, "Zero line"));
DrawOnPricePanel = false;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (Close[0] >= Open[0])
{
Values[0].Set(Volume[0]);
Values[1].Reset();

if (Volume[1]<x)
{ Values[2].Set(Volume[1]);
}
}
else
{
Values[1].Set(Volume[0]);
Values[0].Reset();
if (Volume[1]<x)
{ Values[2].Set(Volume[1]);

many thanks for your help/advise

Started this thread Reply With Quote

Can you help answer these questions
from other members on futures io?
MACD line not plotting after change of plot order
NinjaTrader
Short Interest Ratio indicator?
ThinkOrSwim
Can the Magnet Tool Affect Chart Orders In Overcharts Ha …
Platforms and Indicators
If ES tracks SPX, why do support/resistance, Level 2, vo …
Emini and Emicro Index
SimplerOptions
Trading Reviews and Vendors
 
 
(login for full post details)
  #3 (permalink)
Market Wizard
Berlin, Europe
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,855 since Mar 2010
Thanks: 4,238 given, 26,728 received


Here are some changes that I suggest. Have not tested them. Also ou need to declare the Variable x via "double x = 0.0;" somewhere.

 
Code
 
protected override void Initialize()
{
Add(new Plot(new Pen(Color.Lime, 2), PlotStyle.Bar, "UpVolume"));
Add(new Plot(new Pen(Color.Red, 2), PlotStyle.Bar, "DownVolume"));
Add(new Plot(new Pen(Color.Black, 2), PlotStyle.Bar, "LowVol"));
Add(new Line(Color.DarkGray, 0, "Zero line"));
Overlay = false;  // DrawOnPricePanel is needed for additional drawing features, you probably mean "Overlay = false;"
}
 
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (Close[0] >= Open[0])
{
Values[0].Set(Volume[0]);
Values[1].Set(0.0);
} 
else // continue here for negative volume
{
Values[1].Set(Volume[0]);
Values[0].Set(0.0);
} 
// good idea to repaint the last bar after it became a low volume bar, but the first bar on the chart (index 0)does not have a last bar, so you may only start this with the second bar (index 1) -> CurrentBar > 0 is required
if (CurrentBar > 0 && Volume[1] < x)
{ 
Values[0].Set(1,0.0);
Values[1].Set(1,0.0);
Values[2].Set(1, Volume[1]); // you do not want to set the value for the current volume bar but for the prior bar
so you need to use the correct syntax Set( int barsAgo, double value)
}
Values[2].Set(0.0); // always, only affects the current incomplete bar
}
Further suggestions:

If you post code, you can use [Code] tags -> just highlight the code and select # on your task bar

The condition
 
Code
 
if (CurrentBar > 0 && Volume[1] < x)
will work but is annoying, because you have to change the value of x for every instrument. You could try
 
Code
 
if(CurrentBar > 10 && Volume[1] == MIN(Volume, 10)[1])
This would show the bar as a low volume bar, if it has the lowest volume of the last 20 bars - not including the current active bar, which is yet incomplete.

Reply With Quote
 
(login for full post details)
  #4 (permalink)
london
 
Experience: Beginner
Platform: ninja
Trading: fgbl
 
Posts: 152 since Nov 2009
Thanks: 64 given, 44 received

thank you soooo much fat tails - i get the gist of yr code and will play around with it

Started this thread Reply With Quote
 
(login for full post details)
  #5 (permalink)
london
 
Experience: Beginner
Platform: ninja
Trading: fgbl
 
Posts: 152 since Nov 2009
Thanks: 64 given, 44 received

yep, code is correct - just needed to declare variable as you said

Started this thread Reply With Quote


futures io Trading Community Platforms and Indicators NinjaTrader > can you help with code, would like to paint low volume bar black


Last Updated on December 19, 2010


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts