How to Ensure Resolution is 1 Day?

Questions about MultiCharts .NET and user contributed studies.
User avatar
Analyst
Posts: 19
Joined: 09 Jul 2013
Has thanked: 3 times
Been thanked: 2 times

How to Ensure Resolution is 1 Day?

Postby Analyst » 25 Sep 2013

I have a problem with, I guess, the resolution in my real time scanner. I am using a study which counts up and down days, and it works fine with daily data. A screen shot is attached. When I use this study in the scanner, it starts counting up and down ticks – even though my resolution is set to days.

I observe that other daily studies, like RSI, will compute on a daily basis even as they adjust the current day based on the latest tick. My study doesn’t behave that way. What am I doing wrong?
Attachments
Streak.jpg
(35.71 KiB) Downloaded 507 times

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: How to Ensure Resolution is 1 Day?

Postby JoshM » 25 Sep 2013

I have a problem with, I guess, the resolution in my real time scanner. I am using a study which counts up and down days, and it works fine with daily data. A screen shot is attached. When I use this study in the scanner, it starts counting up and down ticks – even though my resolution is set to days.
Do you might have your indicator set to 'Update on every tick'? Setting that setting on will force the indicator to recalculate on every incoming tick, while that setting off will only calculate the indicator on bar close (i.e. once a day with daily data).

You can also control this in the code, like this:

Code: Select all

namespace PowerLanguage.Indicator
{
[UpdateOnEveryTick(false)] // No updating on every tick, just on bar close
public class Example : IndicatorObject
{
public Example(object _ctx):base(_ctx){}

protected override void Create()
{
}

protected override void StartCalc()
{
}

protected override void CalcBar()
{
}

}
}

User avatar
Analyst
Posts: 19
Joined: 09 Jul 2013
Has thanked: 3 times
Been thanked: 2 times

Re: How to Ensure Resolution is 1 Day?

Postby Analyst » 25 Sep 2013

Thanks for the quick response, Josh. I can also set that flag on the properties sheet in the scanner. It has the effect of freezing the study with yesterday’s data. So, you are correct, but I want the current value of the study.

To clarify … think about a 10 day simple moving average. This study changes during the day, as each tick updates the tenth value in the average, but the other nine values don’t change. It updates with each tick, but it only updates the current day.

So, for my Streak study … if we were up the last three days, it’s +3. Based on today’s intraday price, it might be up to +4. Instead, I have +22 because it’s counting ticks not days.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: How to Ensure Resolution is 1 Day?

Postby JoshM » 26 Sep 2013

To clarify … think about a 10 day simple moving average. This study changes during the day, as each tick updates the tenth value in the average, but the other nine values don’t change. It updates with each tick, but it only updates the current day.
I don't follow you here. Do you mean that your indicator recalculates the values for all previous x bars (and not only the recent)? If so, you have a coding error I suppose (loop somewhere?). But without posting code, we can only speculate.

At the risk of stating the obvious, have you tried to calculate your indicator only on bar close?

Code: Select all

if (Bars.Status == EBarState.Close)
{
// On bar close
}

User avatar
Analyst
Posts: 19
Joined: 09 Jul 2013
Has thanked: 3 times
Been thanked: 2 times

Re: How to Ensure Resolution is 1 Day?

Postby Analyst » 26 Sep 2013

I rewrote the study to work explicitly from its own previous value, this[1], instead of relying on Bars.Close. Not sure why, but that fixed it. Thanks again.


Return to “MultiCharts .NET”