[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Variable period channel - need help with formula



PureBytes Links

Trading Reference Links

I was trying to create a variable-period channel indicator, as follows:

Days:= Round(150/ADX(14));
HHV(H,Days);
LLV(L,Days);

[Note: The round function is merely to round up or round down the resulting
fraction to the nearest integer].

However, I get this error message: "This variable or expression must contain
only constant data" (referring to the variable 'Days' in the HHV & LLV
arguments). [Note: the error message is also there when I substitute
PriceChannelHigh(Days) for HHV(H,Days) and PriceChannelLow(Days) for
LLV(L,Days)].

One workaround I came up with is to modify the Days argument, as follows:

Days:= LastValue(Round(150/ADX(14)));
HHV(H,Days);
LLV(L,Days);

However, while this makes the error message go away, it results in a price
channel that is based on the last value of 150/ADX(14) and this is constant
across the entire chart. This, of course, defeats the purpose of the
indicator as I want the channel length to vary with the 14-day ADX across
the entire chart - thus, when ADX is high, the channel length will be short
& vice versa.

Can anyone suggest a solution? Thanks.

Shashi