• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

volume/close of previous day

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

    volume/close of previous day

    I write code of some strategy and I don't know how to check close/volume another day?

    I need following:

    I need to check close/volume of previous day in the same hours
    for example,

    if(previous day)
    if(time == 2 hours pm(for example) )
    if(CloseOfPrevDay < Close[0])
    do smth...

    #2
    Hello Yevhenii,

    Thank you for your note.

    To get the price of the close and the volume at this time yesterday, under OnBarUpdate you should post the following,
    DateTime nowDate =DateTime.Now; //Saves the current Date/Time to variable nowDate

    nowDate= nowDate.AddDays(-1); //Subtracts 1 day from the date of nowDate

    int yesBarsAgo = GetBar(nowDate); //Gives you how many bars ago 1 day ago at this time was.

    double yesClose = Close[yesBarsAgo]; //Assigns the closing price of yesterday on this bar to yesClose variable.

    double yesVolume = Volume[yesBarsAgo]; //Assigns the volume of yesterday on this bar to yesVolume variable.

    Print("Time "+Time[yesBarsAgo]+"YesVolume = "+yesVolume.ToString() +" YesClose "+yesClose);

    You should now be able to use yesClose and yesVolume in your condition.
    Please see AddDays Method:
    https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thank you for sharing the information, it is of interest to many people.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by suprsnipes, Today, 08:26 PM
      0 responses
      2 views
      0 likes
      Last Post suprsnipes  
      Started by RobertoPaez, Today, 06:47 PM
      0 responses
      7 views
      0 likes
      Last Post RobertoPaez  
      Started by catinabag, Today, 06:45 PM
      0 responses
      4 views
      0 likes
      Last Post catinabag  
      Started by darkgreen, Today, 03:35 PM
      0 responses
      9 views
      0 likes
      Last Post darkgreen  
      Started by GTBrooks, Today, 02:44 PM
      3 responses
      14 views
      0 likes
      Last Post GTBrooks  
      Working...
      X