Hi Graham I am only a novice coder and similar to your associate, don't know loops. But as no response has come in two days I will try to answer your question, as I understand it.
As you know the xaProfitStop xTimeStopPer and xaReversionValue can be coded in AFL. But I believe to include the xDisasterStop your associate will have to stick with a loop. I believe this because it has been often reaffirmed. [See below] If your associate can code MetaStock he/she could most likely understand the loop you have provided, plug it in for the disaster stop in the future, and possibly subtract or add sections as needed. The good news is [in my experience], to explore trading methods the necessity for loops is rare. directaim ================== The way I see it, there is a logical problem with trying to do this with purely array maths. I think it has to be done iteratively using a loop. The problem is that you want to create a buy array first, then use HighestSince(Buy, ...) as part of the definition of the sell array. What you really mean though is highest since the buy signal JUST IMMEDIATELY after the most-recent sell signal, but with array maths you can't reference a previous sell signal during the definition of the sell array. So you have a Catch-22 in that you can't remove redundant buy signals until the sell array has been defined, but can't define the sell array with HighestSince(Buy, ...) while there are redundant buy signals. Unless array maths is changed to allow iterative definitions, whereby an array could be defined based on earlier values of the same array in the same statement, I think you will need to use a loop. Regards, GP ============================= In short: RECURSIVE calculations need a FOR loop and [] operator http://www.amibroker.com/guide/keyword/for.html "For" loop and array subscript operator [] gives you access to INDIVIDUAL values. Best regards, Tomasz Janeczko ==============================
