NexusFi: Find Your Edge


Home Menu

 





GoTo Bar ChartControl


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one decs0057 with 2 posts (0 thanks)
    2. looks_two bukkan with 1 posts (0 thanks)
    3. looks_3 Big Mike with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 5,445 views
    2. thumb_up 1 thanks given
    3. group 4 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 decs0057 
Munich, Germany
 
Experience: Intermediate
Platform: NinjaTrader, TWS
Broker: IB, NinjaTrader Brokerage
Trading: ES,NQ,6E
Posts: 73 since Feb 2010
Thanks Given: 15
Thanks Received: 25

Is there a method GoToBar with argument DateTime which jumps to the bar and scrolls it to the visible canvas if it is outside ?
There is a method GoTo in ChartControl but you can't call it because it is internal.
Is it possible with GetXByBarIdx ?


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Hungary Called for Magyar at 97pct, Ending 16-Year Orban …
Prediction Markets & Event Contracts
Penalties in Budapest, Peace Deadline in Tehran: Arsenal …
Prediction Markets & Event Contracts
Irans Dual Probability: Guns Quiet at 99.95% While Forma …
Prediction Markets & Event Contracts
Bookmap Global Plus Lifetime + Lifetime Addons For Sale
Platforms and Indicators
More Than Capable: Hegseths War Warning Validates $114M …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #3 (permalink)
 bukkan 
Calcutta, India
 
Experience: Intermediate
Platform: ArthaChitra
Posts: 278 since Jun 2009
Thanks Given: 161
Thanks Received: 271


int i = Bars.GetBar(datetime);


Reply With Quote
  #4 (permalink)
 decs0057 
Munich, Germany
 
Experience: Intermediate
Platform: NinjaTrader, TWS
Broker: IB, NinjaTrader Brokerage
Trading: ES,NQ,6E
Posts: 73 since Feb 2010
Thanks Given: 15
Thanks Received: 25

now i have the index, if index is outside of visible range how can i scroll that bar becomes visible

I tried

int totalBars = indicator.ChartControl.Bars[0].Count;
DateTime dt = goToDate;
// int indicator.ChartControl.AutoScroll;
int barsIndex = indicator.Bars.GetBar(dt);
int firstBarPainted = chartCtrl.FirstBarPainted;
IBar firstBar = indicator.Bars.Get( firstBarPainted );
int lastBarPainted = chartCtrl.LastBarPainted;
IBar lastBar = indicator.Bars.Get( lastBarPainted );
int visibleBars = lastBarPainted - firstBarPainted;
if( barsIndex >= firstBarPainted && barsIndex < lastBarPainted )
return;

int xByBarIndex = chartCtrl.GetXByBarIdx( barsIndex );

HScrollProperties hsp = chartCtrl.ChartPanel.HorizontalScroll;
int scrollValue = (int)((100 * barsIndex) / totalBars);
hsp.Enabled = true;
hsp.Value = scrollValue;

but scrollbar doesn't move


Started this thread Reply With Quote
  #5 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,557

Download courtesy @decs0057:

https://nexusfi.com/download/vip_elite_circle/1277-download.html?view

Mike




We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on X Visit my NexusFi Trade Journal Reply With Quote
  #6 (permalink)
 
AlBundy's Avatar
 AlBundy 
Vienna Austria
 
Experience: Advanced
Platform: NinjaTrader
Trading: Forex
Posts: 25 since Jun 2013
Thanks Given: 10
Thanks Received: 12



First thank you Mike for the link and I am posting now the pure code how I implemented it in my indicator and it works perfect:

 
Code
// execute the internal method GoTo
dtDateTime = <the DateTime value>;
BindingFlags bfObject = BindingFlags.Instance | BindingFlags.NonPublic;
MethodInfo methodGoTo = typeof(ChartControl).GetMethod("GoTo", bfObject);
methodGoTo.Invoke(ChartControl, new Object [] { dtDateTime });
In the variable dtDateTime you put the DateTime value from the beginning of the area you want to scroll to.


Reply With Quote
Thanked by:




Last Updated on February 17, 2015


© 2026 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 - Downloads - Top
no new posts