I am trying to code supertrend formula in array:
BASIC UPPERBAND = (HIGH + LOW) / 2 + Multiplier * ATR
BASIC LOWERBAND = (HIGH + LOW) / 2 - Multiplier * ATR
FINAL UPPERBAND =
IF( (Current BASICUPPERBAND < Previous FINAL UPPERBAND) OR
(Previous Close > Previous FINAL UPPERBAND)) THEN
(Current BASIC UPPERBAND) ELSE Previous FINALUPPERBAND)
FINAL LOWERBAND =
IF( (Current BASIC LOWERBAND > Previous FINAL LOWERBAND) OR
(Previous Close < Previous FINAL LOWERBAND)) THEN
(Current BASIC LOWERBAND) ELSE Previous FINAL LOWERBAND)
SUPERTREND = IF(Current Close <= Current FINAL UPPERBAND )
THEN Current FINAL UPPERBAND ELSE Current FINAL LOWERBAND
Below is the AFL:
_AT = ATR(10);
_MT = 3;
_PC = Ref(C, -1);
BUB = ((High+Low)/2) + (_AT*_MT);
BLB = ((High+Low)/2) - (_AT*_MT);
P_FUB = // I am stuck in defining the Prev value for Final upper band. can isnull be used?
FUB = IIf(BUB <= P_FUB OR _PC >= BUB,BUB,P_FUB);
Thank you.
Any help much appreciated.
BASIC UPPERBAND = (HIGH + LOW) / 2 + Multiplier * ATR
BASIC LOWERBAND = (HIGH + LOW) / 2 - Multiplier * ATR
FINAL UPPERBAND =
IF( (Current BASICUPPERBAND < Previous FINAL UPPERBAND) OR
(Previous Close > Previous FINAL UPPERBAND)) THEN
(Current BASIC UPPERBAND) ELSE Previous FINALUPPERBAND)
FINAL LOWERBAND =
IF( (Current BASIC LOWERBAND > Previous FINAL LOWERBAND) OR
(Previous Close < Previous FINAL LOWERBAND)) THEN
(Current BASIC LOWERBAND) ELSE Previous FINAL LOWERBAND)
SUPERTREND = IF(Current Close <= Current FINAL UPPERBAND )
THEN Current FINAL UPPERBAND ELSE Current FINAL LOWERBAND
Below is the AFL:
_AT = ATR(10);
_MT = 3;
_PC = Ref(C, -1);
BUB = ((High+Low)/2) + (_AT*_MT);
BLB = ((High+Low)/2) - (_AT*_MT);
P_FUB = // I am stuck in defining the Prev value for Final upper band. can isnull be used?
FUB = IIf(BUB <= P_FUB OR _PC >= BUB,BUB,P_FUB);
Thank you.
Any help much appreciated.