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 4,598 views
    2. thumb_up 1 thanks given
    3. group 4 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread

GoTo Bar ChartControl

  #1 (permalink)
 decs0057 
Munich, Germany
 
Experience: Intermediate
Platform: NinjaTrader, TWS
Broker: IB, NinjaTrader Brokerage
Trading: ES,NQ,6E
Posts: 71 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?
Trade idea based off three indicators.
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
NexusFi Journal Challenge - May 2024
Feedback and Announcements
REcommedations for programming help
Sierra Chart
 
  #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: 71 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,454 since Jun 2009
Thanks Given: 33,227
Thanks Received: 101,645

Download courtesy @decs0057:



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 Twitter 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


Big Mike View Post
Download courtesy @decs0057:



Mike

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


© 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