Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 gravdigaz6, Today, 11:40 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by MarianApalaghiei, Today, 10:49 PM
        3 responses
        10 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by XXtrader, Today, 11:30 PM
        0 responses
        4 views
        0 likes
        Last Post XXtrader  
        Started by love2code2trade, Yesterday, 01:45 PM
        4 responses
        28 views
        0 likes
        Last Post love2code2trade  
        Started by funk10101, Today, 09:43 PM
        0 responses
        9 views
        0 likes
        Last Post funk10101  
        Working...
        X