0

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

  • An If statement you usually use inside a loop and will need to reference elements in an array using the indexer `myVar[index];` You can also use the `IIF(condition, truepart, falsepart)` to operate on entire arrays. `IIF((lowma > minHighPrice) AND (Close> Ref(High, 01), truepart, falsepart)` [AFL](https://www.amibroker.com/guide/h_understandafl.html) – Ceres Mar 07 '22 at 14:23

1 Answers1

0

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

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

Try to use Ref function

Dicer
  • 63
  • 1
  • 9