1) I first define two dataseries, say dataseries1 and dataseries2. Within the onbarupdate() method, dataseries1 is calculated. This dataseries needs not be changed.
2) I then define a parameter, in this case a double, whose value is an average of dataseries1 since the beginning of the trading day (it is actually a ratio of dataseries1 divided by barssincesession).
3) I then define a binary (int) whose value is 0 or 1 depending on whether dataseries1 is larger or smaller than the parameter.
4) Here is the key part. I let the value of dataseries2 to be the multiple of dataseries1 and the binary value:
dataseries2[0]=dataseries2[1]+binary*dataseries1[0].
However,I'm pretty sure that the dataseries2 calculated this way will reflect all the parameter value which changes on each bar update. What I really want is to recalculate dataseries2 (the whole series, not just dataseries2[0]) using the latest parameter value (the whole plot for dataseries 2 from the beginning of the trading day on will therefore change upon a new bar, as opposed to just the latest value changing. With each new bar of the trading day, the value of dataseries2 since the beginning of the trading day is recalculated using the latest parameter value -> binary value, but the values in prior trading days are not recalculated). Is there a way to do that? I can supply my source code if further clarification is needed.
Thanks!
Comment