Login Page - Create Account

Support Board


Date/Time: Sat, 18 May 2024 22:04:42 +0000



Post From: Last time price was seen

[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);