Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bar Data By Passing Index

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Bar Data By Passing Index

    Is there are way to retrive bar value by passing the index. I got the index by:
    Code:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]
    int[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] startDayBarsAgo = GetBar(g_StartTradingTime);[/COLOR]
    [/SIZE][/FONT][/SIZE][/FONT]
    What I want to do is loop through the bar data and pass the value to a method simular to below, but I know these are not the correct methods to use:
    Code:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000]([/COLOR][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] i=startBarsAgo; i>=[/COLOR][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000]; i--)[/COLOR]
    { 
    IBar bar = Bars.Get(i);
    discoverTrends(bar.Value);
    }
    [/SIZE][/FONT][/SIZE][/FONT]
    Any thoughts on how to accomplish this?

    #2
    Hello,

    All looks good except this not sure what you got going here.

    IBar bar = Bars.Get(i);


    Would use here Close[i] for example, or Open[i] to loop though these data points. Then send these values to the method.

    I look forward to assisting you further.

    BrettNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by cmoran13, Yesterday, 01:02 PM
    0 responses
    27 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    18 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    160 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    95 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    148 views
    2 likes
    Last Post CaptainJack  
    Working...
    X