ahujat Posted October 7 Report Share Posted October 7 Is there an easy way to get the CandleNumber of the first candle of the week? Should take into account futures vs stocks. Quote Link to comment Share on other sites More sharing options...
ahujat Posted October 8 Author Report Share Posted October 8 Bump Quote Link to comment Share on other sites More sharing options...
Jerry Medved Posted October 9 Report Share Posted October 9 there is no direct way. Computing yourself can be done, but not sure then if taking futures/stocks into account can be easily done. Will have to wait for Mike to answer - he is out for a few days. Quote Link to comment Share on other sites More sharing options...
Mike Medved Posted October 10 Report Share Posted October 10 int FirstWeeklyCandle = -1; public void MainCalculation() { if ((int)(Timestamp.DayOfWeek) == 0) // Sunday is 0 FirstWeeklyCandle = CandleNumber; ... That would do it for futures (first day is sunday). If you want to do it for both, and you presume that there is no candle for Sunday for stocks, int FirstWeeklyCandle = -1; DateTime FirstWeeklyCandleDT; public void MainCalculation() { if ((int)(Timestamp.DayOfWeek) == 0) // Sunday is 0 { FirstWeeklyCandle = CandleNumber; FirstWeeklyCandleDT = Timestamp.Date; } else if ((int)(Timestamp.DayOfWeek) == 1) // Monday is 1 { if ((int)(FirstWeeklyCandleDT.DayOfWeek) != 0) // there isn't already a sunday FirstWeekly { FirstWeeklyCandle = CandleNumber; FirstWeeklyCandleDT = Timestamp.Date; } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.