The arguments for IIf are (condition, truearray, falsearray). In your first and second lines, you use a value for the "falsearray", not an array.
Also, you seem to be trying to repeat the last value for volume when it isn't up or down - that is, repeat the last down volume on an up day. That will cause a falsely weighted average. For example, in a strong up trend, the down-volume average could consist of repeated entries of the last down day's volume. I don't have a good work-around, unless I knew a little more about what you are trying to accomplish. - Bill --- In [email protected], "l_abarr" <[EMAIL PROTECTED]> wrote: > > I'm new at this. I'm getting an error in the first line because the > variable 'upvol' hasn't been initialized. I want UpVol to remain the > same as yesterday if C < O. Thanks for any help! > > UpVol =IIf(C > O, V, Ref(UpVol,-1)); > DownVol =IIf(C < O, V, Ref(DownVol,-1)); > Period = Param("Period",3,2,10,1); > UpVolAvg = EMA( UpVol, Period ) ; > DownVolAvg = EMA( DownVol, Period ) ; > Plot(UpVolAvg,"UpVolume", colorGreen); > Plot(DownVolAvg, "DownVolume", colorRed); >
