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