| 
 PureBytes Links 
Trading Reference Links 
 | 
Hi all..
I'm trying to write a routine/function that will do the following on an
array passed to it..
When the array is going down (ie Arr[i] < Arr[i-1]) then array remains at
the last point that Arr[i] >= Array[i-1]
But when the trend changes, and Arr[i]>Arr[i-1] then reset the stop loss
back to Arr[i-1]
I've tried this code fragment, but it doesn't work as expected..
EnableScript ( "JScript" );
<%
  BC = VBArray( AFL ("BC" ) ).toArray();
  BD = new Array();
  BD = BC;
 for (var i=0;i<BD.length;i++)
  {
   if(BC[i]>BC[i-1])
    BD[i]=BC[i];
  else
    BD[i] = BD[i-1];
 }
}
AFL.Var("bot") = BD;
%>
Plot(Bot,"Bot - Sell if below",colorRed,styleLine);
Can anyone help..
Bruce
Perth, Australia
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
 |