Hameed Syed Abdul
Hameed Syed Abdul

Reputation: 1

AFL: Compare current close with previous high

I'm new to AFL. I want to check if the current candle close is greater than the previous high but I'm experiencing the following error. Can you help me in fixing this:

if ((lowma > minHighPrice) AND (Close[0] > High[-1]))

Error 10: Subscript out of range. You must not access array elements outside 0..(BarCount-1) range.You are attempted to access non-existing -1st element of array. Error 6: Condition in IF, WHILE, FOR statements has to be Numeric or Boolean type. YOu can not use array here. Please use [] to access array elements

if (lowma > minHighPrice) AND (Ref(Close, 0) > Ref(High,-1))

Error 6: Condition in IF, WHILE, FOR statements has to be Numeric or Boolean type. YOu can not use array here. Please use [] to access array elements

Thanks and regards, Hameed

Upvotes: 0

Views: 552

Answers (1)

Dicer
Dicer

Reputation: 85

Orginial Code: (Close[0] > High[-1])

My Suggestion: Close > Ref(Close,-1)

Try to use Ref function

Upvotes: 0

Related Questions