HA
hamsider
Blocked user by Spotware at 16 Sep 2021, 21:48
0 follower(s) 0 following 5 subscription(s)
Replies

hamsider
21 Sep 2021, 12:47

RE:

cAlgo_Fanatic said:

Hello,

Try this code:

public override void Calculate(int index)
{
    if (index == 0) return;

    DateTime currentTime = MarketSeries.OpenTime[index];
    DateTime previousTime = MarketSeries.OpenTime[index-1];

    if(currentTime.Month != previousTime.Month)
    {
        // first bar of the month           
    }
    if(currentTime.DayOfWeek == DayOfWeek.Monday && previousTime.DayOfWeek != DayOfWeek.Monday)
    {
        // first bar of the week        
    }
    if(currentTime.Date != previousTime.Date)
    {
        // first bar of the day        
    }
    //...

Any idea how to get the actual index of Day start, Week start and Month start?

I'm confused there should be a quick way to get them. help is highly appreciated. 

thank you