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 Big Mike with 1 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 AlBundy with 1 posts (1 thanks)
    1. trending_up 5,649 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?
Daytrading to swingtrading
Traders Hideout
Warsh Drops Easing Bias, December Hike Now Above 50% -- …
Prediction Markets & Event Contracts
Without Pulisic, USA 61.5% Live vs. Australia -- France …
Prediction Markets & Event Contracts
Ninjatrader users - good CONNECTIONs post and article fr …
NinjaTrader
Thanks Mike. Godspeed.
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Want your NinjaTrader indicator created, free?
5 thanks
Afternoon-close session
1 thanks
Franks Trading Journey
1 thanks
Denied 20K payouts: Alpha Futures
1 thanks
FootPrintV2 Chart for NT8
1 thanks
  #3 (permalink)
 bukkan 
Calcutta, India
 
Experience: Intermediate
Platform: ArthaChitra
Posts: 279 since Jun 2009
Thanks Given: 161
Thanks Received: 272


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
 R.I.P. 1977-2026 
 
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,586

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