NexusFi: Find Your Edge


Home Menu

 





Centering chart on the Y axis


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Adamus with 7 posts (9 thanks)
    2. looks_two sniffy with 2 posts (5 thanks)
    3. looks_3 ThatManFromTexas with 1 posts (0 thanks)
    4. looks_4 madLyfe with 1 posts (1 thanks)
      Best Posters
    1. looks_one sniffy with 2.5 thanks per post
    2. looks_two Adamus with 1.3 thanks per post
    3. looks_3 DavidHP with 1 thanks per post
    4. looks_4 madLyfe with 1 thanks per post
    1. trending_up 7,905 views
    2. thumb_up 16 thanks given
    3. group 9 followers
    1. forum 12 posts
    2. attach_file 0 attachments




 
Search this Thread

Centering chart on the Y axis

  #11 (permalink)
 
ThatManFromTexas's Avatar
 ThatManFromTexas 
Houston,Tx
 
Experience: Advanced
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: TF
Posts: 2,265 since Feb 2010
Thanks Given: 1,206
Thanks Received: 4,355


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.FixedPanelMinRight;
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

@sniffy

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?

Thanks....

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

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
Trade idea based off three indicators.
Traders Hideout
Quant vue
Trading Reviews and Vendors
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
What broker to use for trading palladium futures
Commodities
 
  #12 (permalink)
sniffy
alask
 
Posts: 7 since Oct 2009
Thanks Given: 0
Thanks Received: 5

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

Reply With Quote
Thanked by:
  #13 (permalink)
 
Adamus's Avatar
 Adamus 
London, UK
 
Experience: Beginner
Platform: NinjaTrader, home-grown Java
Broker: IB/IQFeed
Trading: EUR/USD
Posts: 1,085 since Dec 2010
Thanks Given: 471
Thanks Received: 789


Here's the zip:


You can discover what your enemy fears most by observing the means he uses to frighten you.
Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote




Last Updated on April 11, 2012


© 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