I am trying to write a code to calculate the total up move on a series of back to back up bars (or total down move on a series of back to back down bars...(this is only part of the code because I have to take into consideration the case when ROC(C,1,$)=0 which I have done in part of a code thats not below...)
A:= BarsSince(ROC(C,1,$)>0);
B:= BarsSince(ROC(C,1,$)<0);
If(ROC(C,1,$)<0,
If(Ref(ROC(C,1,$),-1)>0,ROC(C,1,$),
ROC(C,A,$)),
If(Ref(ROC(C,1,$),-1)<0,ROC(C,1,$),ROC(C,B
,$)))
but I keep in getting an error that I can only use a constant inside the ROC function.
In other words if I have 5 back to back up bars then I would find 5 by
BarsSince(ROC(C,1,$)<0)-->which should give you 5
Then I would want to calculate
ROC(C,BarsSince(ROC(C,1,$)<0,$)
to
find the total up move from the 5th up bar to the very start of the up
move of the 5 series up bars. but metastock is not allowing me to put
the barssince function inside of Roc or Ref function
So what do I do? How can I go around this? Any ideas would be very appreciated?
Thank you