This is my first message on the forum. I wish I had bought Amibroker a long time ago! Incredible the quality and versatility of this software!
I am a novice at AFL and I am trying to learn how to develop my custom indicators and strategies. I am trying to develop a very simple indicator, but I am having problems with it.
The rules of the indicator are very simple:
If the Close of this bar is equal the highest close of 20 bars ago the value of the indicator is 1.
If the Close of this bar is equal the lowest close of 20 bars ago the value of the indicator is -1.
As you can see I am trying to create a flag. That way the value of the indicator always has to be 1 or -1 and should keep and show the value of the indicator the last time that hit the upper band or the lower band.
I have tried with the next code, but unfortunately it does not work:
Valor = IIf(Close == HHV (Close,20), 1 , IIf(Close == LLV (Close,20), -1 , 0)); // Here the problem is that it shows the 0 value when it should show 1 or -1. Plot( Valor, "Flag Indicator", colorWhite );
Perhaps is there a simple way of solving this problem? Any help would be very appreciate. Thank you!