Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get Opening market price

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

    Get Opening market price

    I want to get the price at a given time, in the example 11:30 (opening of the market ).
    My code does not work....

    private DataSeries myDataSeries; //in variables
    .....

    myDataSeries = new DataSeries(this); //in initialize method
    .....
    int BarsAgoOpenPrice = Bars.GetBar(new DateTime(2008,04,14,11,30,0,0));
    OpenPrice = Close [BarsAgoOpenPrice];

    Do i have also to check with myDataSeries.ContainsValue(BarsAgoOpenPrice) if there is a value?
    Thx

    #2
    GetBar returns the absolute index of a bar and not the "barsAgo" index which you would need to stuff into Close[barsAgo].

    Comment


      #3
      So what can i use with getbar to have the price?

      Comment


        #4
        You need to apply some math to convert the absolute index to the barsAgo index like (pseudo code):
        int barsAgo = CurrentBar - GetBar(new DateTime(2008,04,14,11,30,0,0))

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        152 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        87 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        131 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        127 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        106 views
        0 likes
        Last Post CarlTrading  
        Working...
        X