Centering chart on the Y axis (Page 2) - NinjaTrader Programming | futures trading

Go Back

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming

Centering chart on the Y axis
Started:February 14th, 2012 (11:36 AM) by Adamus Views / Replies:3,594 / 12
Last Reply:April 11th, 2012 (10:41 AM) Attachments:0

Welcome to

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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, and we will never resell your private information.

-- Big Mike

Thread Tools Search this Thread

Centering chart on the Y axis

Old March 22nd, 2012, 05:59 PM   #11 (permalink)
Elite Member
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Mirus Futures/Zen-Fire
Favorite Futures: TF
ThatManFromTexas's Avatar
Posts: 2,302 since Feb 2010
Thanks: 1,208 given, 4,281 received

sniffy View Post
this works for me

#region Event Handlers
private void centrePrice_Click(object sender, EventArgs e)
this.ChartControl.YAxisRangeTypeRight = YAxisRangeType.Fixed;
double yAxisSize = this.ChartControl.FixedPanelMaxRight -
this.ChartControl.FixedPanelMaxRight = Close[0] + (yAxisSize / 2);
this.ChartControl.FixedPanelMinRight = Close[0] - (yAxisSize / 2);

// force repaint so we dont have to wait for another event
ChartControl.ChartPanel.Invalidate(); // <<<<<<--------------------

#endregion Event Handlers


Please bear with me... I am self taught in writing code for Ninja Trader.... and my teacher isn't very good...

I'm trying to understand the code. Is this the entire thing or just a snippet?


I'm just a simple man trading a simple plan.

My daddy always said, "Every day above ground is a good day!"
Reply With Quote

Old March 23rd, 2012, 02:58 AM   #12 (permalink)
Trading Apprentice
Futures Experience: Master
Platform: ninja
Posts: 7 since Oct 2009
Thanks: 0 given, 5 received

follow adamus code

Adamus posted pretty much the entire thing above.

He is adding toggleTrade and centrePrice buttons to the ChartTrader panel.

His centreprice event handler will be fired when he clicks his centreprice button.

After the image coordinates are reset he needs to ensure that the image is repainted.

Moving the mouse off the region and back again has the effect of forcing a repaint, so that is
why he sees the behaviour that he sees,

To avoid dependence on other random repaint events he simply needs to force a repaint to happen by
using the Control. Invalidate() method.

This forces the repaint so that he can see the effect of his coordinates change.

So simply add ChartControl.ChartPanel.Invalidate(); to the event handler after changing the coordinates.

There is plenty of discussion about using .Invalidate method on the various forums, MSDN etc.

hope this helps

Last edited by sniffy; March 23rd, 2012 at 03:16 AM.
Reply With Quote
The following 2 users say Thank You to sniffy for this post:

Old April 11th, 2012, 10:41 AM   #13 (permalink)
Elite Member
London, UK
Futures Experience: Beginner
Platform: NinjaTrader, home-grown Java
Broker/Data: IB/IQFeed
Favorite Futures: EUR/USD
Adamus's Avatar
Posts: 1,083 since Dec 2010
Thanks: 467 given, 775 received

Uploaded the Chart Trader indicator with extra functionality that I use

Here's the zip:

You can discover what your enemy fears most by observing the means he uses to frighten you.
Reply With Quote
The following 3 users say Thank You to Adamus for this post:

Reply > Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming > Centering chart on the Y axis

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Upcoming Webinars and Events (4:30PM ET unless noted)

An Afternoon with FIO trader bobwest

Elite only

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

Similar Threads
Thread Thread Starter Forum Replies Last Post
Change the time axis (x axis) on Sierra Charts Affliction Sierra Chart 2 September 27th, 2011 12:27 PM
InvestorRT axis label coloring Big Mike Investor/RT 3 August 18th, 2011 06:53 AM
MATLAB Dates on the x - axis jakfourie Matlab, R project and Python 11 June 27th, 2011 02:55 AM
Formatting the Y-Axis Fat Tails NinjaTrader Programming 12 January 26th, 2011 05:32 AM
plot reference axis SARdynamite NinjaTrader Programming 1 July 8th, 2010 07:50 AM

All times are GMT -4. The time now is 12:12 PM.

Copyright © 2016 by 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

Page generated 2016-10-22 in 0.08 seconds with 19 queries on phoenix via your IP