Page 1 of 1

Reset Study value each day-need help

Posted: 14 Oct 2013
by sptrader
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");

Re: Reset Study value each day-need help

Posted: 14 Oct 2013
by TJ
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?

Re: Reset Study value each day-need help

Posted: 14 Oct 2013
by sptrader
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 ?

Re: Reset Study value each day-need help

Posted: 14 Oct 2013
by TJ
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.