Reset Study value each day-need help

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Reset Study value each day-need help

Postby sptrader » 14 Oct 2013

Is there an "easy" way to reset a study value to zero, so the study values are new on each day ?

For example I'd like this simple momentum study to begin at zero at the beginning of each day..(rather than carry over values from the previous day)...(I understand it will take 10 + bars to begin plotting each day...)...

Code: Select all

Input:Len(10);
vars:mom(0);
mom = c - average(c,Len);
plot1(mom,"momentum");

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Reset Study value each day-need help

Postby TJ » 14 Oct 2013

Is there an "easy" way to reset a study value to zero, so the study values are new on each day ?
For example I'd like this simple momentum study to begin at zero at the beginning of each day..(rather than carry over values from the previous day)...(I understand it will take 10 + bars to begin plotting each day...)...

Code: Select all

Input:Len(10);
vars:mom(0);
mom = c - average(c,Len);
plot1(mom,"momentum");
Anything is possible... if you can quantify it and articulate it, you can code it.

If the first bar of the day is zero,
how do you propose to calculate the 2nd bar?

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Reset Study value each day-need help

Postby sptrader » 14 Oct 2013

I assume the 1st actual calculation would begin on bar # 10 ... since it's C-ave(c,10)..
So would I have to collect the bar data using an array ? or just a variable ?

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Reset Study value each day-need help

Postby TJ » 14 Oct 2013

I assume the 1st actual calculation would begin on bar # 10 ... since it's C-ave(c,10)..
So would I have to collect the bar data using an array ? or just a variable ?
You can let the formula calculate as usual.

you need to set up a counter...
to count the first 10 bars (or Len).
Simply start plotting at the 10th bar. For the first 9 bars, plot as zero.


Return to “User Contributed Studies and Indicator Library”