AFL equivalent:

SetBarsRequired( 100000, 0 );
ATRMulti = 2.8;
ATRPeriod = 22;

AvPrc = (High + Low + Close) / 3;
calc = AvPrc - ATR(ATRPeriod ) * ATRMulti;

result = calc;

previous = Null;

for( i = 1; i < BarCount; i++ )
{
  if( Close[ i - 1 ] >= previous AND calc[ i ] <= previous )
    result[ i ] = previous;

  previous = result[ i ];
}

Plot( result, "result", colorRed );

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "Amit Ehrenreich" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, March 24, 2008 7:41 PM
Subject: RE: [amibroker] Help with PREVIOUS function


> Hi Dawsonsg,
>
> Can you explain what you're trying to achieve? Does the PREVIOUS function 
> refers to the previous value in the array? I would be 
> happy to help.
>
>
> Regards,
>
> Amit Ehrenreich
> Market Testing Wizards
> www.markettestingwizards.com
>
> ________________________________
>
> From: [email protected] on behalf of dawsonsg
> Sent: Fri 3/21/2008 5:14 PM
> To: [email protected]
> Subject: [amibroker] Help with PREVIOUS function
>
>
>
> Hi Guys,
>
> Can someone please give me a hand with converting a metastock formula
> using PREVIOUS to Metastock. I believe I am supposed to be using a
> FOR loop to do it but am not sure where to start. I have been pointed
> to http://www.amibroker.com/guide/afl/afl_view.php?ama 
> <http://www.amibroker.com/guide/afl/afl_view.php?ama>
>
> and have also found a mentioned at the link below
>
> http://www.mail-archive.com/[email protected]/msg11900.html 
> <http://www.mail-archive.com/[email protected]/msg11900.html>
>
> but still am not sure where to start. The formula is below. I dont
> want someone to do this for me but if they could give me a start I'd
> appreciate it.
>
> //ATRMulti := Input("ATR multiplier:", 0, 99999, 2.8);
> //ATRPeriod := Input("Number of bars in ATR:", 1, 99999, 22);
>
> ATRMulti = 2.8;
> ATRPeriod = 22;
>
> AvPrc = (HIGH + LOW + CLOSE) / 3;
> calc = AvPrc - ATR(ATRPeriod ) * ATRMulti;
>
> If(Ref(CLOSE, -1) < PREVIOUS, calc,
> If(calc > PREVIOUS, calc,
> PREVIOUS))
>
> Regards
> Steve
>
>
>
>
>
> ------------------------------------
>
> Please note that this group is for discussion between users only.
>
> To get support from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
>
> For other support material please check also:
> http://www.amibroker.com/support.html
> Yahoo! Groups Links
>
>
>
> 

Reply via email to