Function which can alter previous values.

Questions about MultiCharts .NET and user contributed studies.
User avatar
tito0224
Posts: 15
Joined: 01 May 2013
Has thanked: 2 times
Been thanked: 6 times

Function which can alter previous values.

Postby tito0224 » 30 May 2013

I would like to use a Function, or a VariableObject or VariableSeries where I could alter previous values using barsBack.

For example:

Code: Select all


protected override void Create()
{
// create variable objects and function objec
values = new VariableSeries<int>(this);
}

protected override void CalcBar()
{
values.Set(barsBack, newValue);
}
Is this possible?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Function which can alter previous values.

Postby Henry MultiСharts » 31 May 2013

Hello tito0224,

You cannot assign "historical values" to a variable. You can assign current value during script calculation, then you can reference the assigned values.

User avatar
tito0224
Posts: 15
Joined: 01 May 2013
Has thanked: 2 times
Been thanked: 6 times

Re: Function which can alter previous values.

Postby tito0224 » 31 May 2013

Well what is the best way to accomplish building an indicator where your historical values can be updated until a certain point then locked in.

For example, I need to count how many bars have closes greater then the previous bar. For each bar that closes greater than the previous bar I store the count as the current value. These bars need to be sequential, and once I hit my target number say - 10. I can lock in all the values, however is I get my count up to 7 and then bar 8 doesnt close greater than the previous bar then I need to go back in time and set all those bar count values to 0.

Any suggestions?

MidKnight
Posts: 343
Joined: 12 Aug 2012
Has thanked: 123 times
Been thanked: 56 times

Re: Function which can alter previous values.

Postby MidKnight » 03 Jun 2013

Hi there,

The logic sounds a bit odd...using your example, you say "lock in", does that mean only once the value is locked in, then you want to do some sort of calculation with this bar counting part of the code? Or are you doing calculations with the bar counting part even when it is not locked in? Or do you want to alter past historical values to get the holy grail (sic) of trading?

There should be no reasons to have to adjust historical values, and I'm sure what you want to accomplish can be done with a different approach or a tweak in logic once we understand some more detail of what you are doing.

With kind regards,
MK

User avatar
tito0224
Posts: 15
Joined: 01 May 2013
Has thanked: 2 times
Been thanked: 6 times

Re: Function which can alter previous values.

Postby tito0224 » 05 Jun 2013

The logic sounds a bit odd...using your example, you say "lock in", does that mean only once the value is locked in, then you want to do some sort of calculation with this bar counting part of the code?
Yes. As soon as the count hits a certain number it will be considered complete and locked in and only then will it be used. But if the count fails to reach the desired level, then the whole series of counts will be disregarded.

Or do you want to alter past historical values to get the holy grail (sic) of trading?


I only wish to alter past historical counts when the counts fail to reach the desired level. Since I would never react to anything unless it hits the required level. I just want to be able to have the counts set to zero so they wont show up on the charts anymore.

Thanks for the help.

MidKnight
Posts: 343
Joined: 12 Aug 2012
Has thanked: 123 times
Been thanked: 56 times

Re: Function which can alter previous values.

Postby MidKnight » 05 Jun 2013

OK, so why not only plot when the count reaches your threshold and is locked in? You don't have to plot every bar, only the ones that matter (to you).

With kind regards,
MK

User avatar
tito0224
Posts: 15
Joined: 01 May 2013
Has thanked: 2 times
Been thanked: 6 times

Re: Function which can alter previous values.

Postby tito0224 » 05 Jun 2013

OK, so why not only plot when the count reaches your threshold and is locked in? You don't have to plot every bar, only the ones that matter (to you).
In historical mode this is fine, but in real time during the course of trading the user wants to watch the charts and see the counts forming. So the user can see that we are approaching a count of 7 etc...


Return to “MultiCharts .NET”