Support Board
Date/Time: Fri, 27 Dec 2024 05:46:18 +0000
Last time price was seen
View Count: 775
[2015-12-13 02:57:14] |
cazeek - Posts: 33 |
Hello, I need to perform calculations in my code based on the last time the security traded at the close price. So for example: 12/1: price range is 89 - 91 12/2 - 12/15: price always above 90 12/16: price closes at 90 On 12/16, I want to look back to find the last date that the price traded at 90 (12/1). Then I want to perform calculations on the subsection of sc.BaseDataIn from the dates 12/1-12/16. In other words, I need the max(date) where the Low Price <= 90 before today, and I want to perform calculations on only the range of bars between then and today. Would you be able to assist? Thank you very much |
[2015-12-14 02:16:38] |
cazeek - Posts: 33 |
I just tried something like this to at least get the index number of the last time the price traded above today's high, but it just freezes SierraChart when I try to load the study: int LastTimePriceIndexNumber; int DaysAgo = 1; float LastTimeHighPrice; float TodayHigh = sc.BaseDataIn[SC_HIGH][sc.Index]; do { LastTimeHighPrice = sc.BaseDataIn[SC_HIGH][sc.Index - DaysAgo]; SCDateTime LastTimePriceDate = sc.GetTradingDayStartDateTimeOfBar(sc.BaseDateTimeIn[sc.Index - DaysAgo]); LastTimePriceIndexNumber = sc.GetContainingIndexForSCDateTime(sc.ChartNumber, LastTimePriceDate); DaysAgo++; } while (LastTimeHighPrice < TodayHigh); |
[2015-12-14 22:37:23] |
cazeek - Posts: 33 |
Can someone assist with this please?
|
To post a message in this thread, you need to log in with your Sierra Chart account: