Hi, Thank you for the explanation.
> You still don't understand anything about zigzag algorithm. Of course, not. As I said, I am a complete novice to AB. I was using WL before and it does not have Zigzag at all. You are not correct when you say that Peak/Trough in WL is based on Zigzag or looks into the future. It never references any bar after the given one. It simply loops from 0 to the bar and finds min and max. Then, after a reversal happens, it assigns the last min or max to an array. That's all. Earlier I posted a question about SelectedValue or LastValue, but Mike warned me about the danger of Peak and TroughBar functions. So, I looked at AB help and it says only: "zig(ARRAY, change ) ... Calculates the minimum % change Zig Zag indicator. Caveat: this function is based on Zig-Zag indicator and may look into the future - this means that you can get unrealistic results when back testing trading system using this indicator. This function is provided rather for pattern and trend recognition formulas." As you see, this does not explain anything. What does "minimum % change" mean? When does it look into the future and how far? How unrealistic the results would be? How to delay the result to undo the effect of looking into the future? The help is not helpful. So, until you posted this script in your message, I had no way to understand Zigzag. Now I understood. Thank you. However, my original question was not about Zigzag (it was Mike, who raised warning about them). The question was about the proper way of rewriting scripts, which use SelectedValue or LastValue, to make them appropriate for backtesting and indicator drawing. I wonder whether someone could take a look and comment on my attempt to fix the script: http://finance.groups.yahoo.com/group/amibroker/message/148924 > PS. Removing my earlier response and repeating your post four times does not > add any strength to your argument. I never removed your response (I guess it is impossible to remove someone else's post). I did remove my own duplicated posts, which I accidentally posted after experiencing Yahoo server timeouts on Sunday evening. Thank you John
