Login Page - Create Account

Support Board


Date/Time: Sun, 05 May 2024 23:07:07 +0000



Post From: How to set the time for the past 10 minutes to use sc.GetOHLCOfTimePeriod

[2019-10-18 11:00:58]
User704508 - Posts: 20
Hi!

I'm trying to use the sc.GetOHLCOfTimePeriod function but am struggling with the dates. I tried using SetDateTimeYMDHMS, BaseDateTimeIn, SetTime but can't figure it out.

My goal: getting the current time and the current time minus 10 minutes to get the highest point and lowest point of the past 10 minutes.

Thank you in advance.

Here is what I got so far:

float& Open = sc.GetPersistentFloat(6);
  float& High = sc.GetPersistentFloat(7);
  float& Low = sc.GetPersistentFloat(8);
  float& Close = sc.GetPersistentFloat(9);
  float& NextOpen = sc.GetPersistentFloat(10);
  
  int Day = sc.BaseDateTimeIn[sc.Index].GetDay();
  int Hour = sc.BaseDateTimeIn[sc.Index].GetHour();
  int Minute = sc.BaseDateTimeIn[sc.Index].GetMinute();
  int MinuteMinus = sc.BaseDateTimeIn[sc.Index-10].GetMinute();
  int Month = sc.BaseDateTimeIn[sc.Index].GetMonth();
  int Year = sc.BaseDateTimeIn[sc.Index].GetYear();
  
  SCDateTime startDateTime;
  SCDateTime endDateTime;
  startDateTime.SetDateTimeYMDHMS(Year, Month, Day, Hour, MinuteMinus, 0);
  endDateTime.SetDateTimeYMDHMS(Year, Month, Day, Hour, Minute, 0);
  startDateTime.SetTime(startDateTime);
  endDateTime.SetTime(endDateTime);
  
  sc.GetOHLCOfTimePeriod(startDateTime, endDateTime, Open, High, Low, Close, NextOpen);