Skip to main content

Adaptive Price Channel for Amibroker (AFL)

claux about 15 years ago Amibroker (AFL)

  • Rating:
    5 / 5 (Votes 1)
  • Tags:
    amibroker, channel

This indicator reflects the prices trend within a channel formed by two adaptive moving averages.

Screenshots

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN( "Adaptive price channel" );
//Adaptive Price Channel
Plot( C, "", colorBlack, styleCandle );
Lookback = 20;
MaxLookback = Param( "Max Lookback period",
                     40, 20, 60, 5 );
MinLookback = Param( "Min Lookback period",
                     20, 10, 20, 5 );
Vol = StDev( C, 30 );
Change = ( Vol - Ref( Vol, -1 ) ) / Ref( Vol, -1 );
StartBar = BeginValue( BarIndex() ); ;
FinishBar = EndValue( BarIndex() );
i = StartBar;

for ( i = StartBar + 31; i < Finishbar; i++ )
{
    Lookback[I] = round( Lookback[I-1] * ( 1 + Change[I] ) );

    if ( Lookback[I] > MaxLookback )
    {
        Lookback[I] = MaxLookback;
    }

    if ( Lookback[I] < MinLookback )
    {
        Lookback[I] = MinLookback;
    }
}

HighChannel = Ref( HHV( H, Lookback ), - 1 );
LowChannel = Ref( LLV( L, Lookback ), -1 );
Plot( HighChannel, "", colorBlue, styleDots |
      styleNoRescale | styleNoLine );
Plot( LowChannel, "", colorRed, styleDots |
      styleNoRescale | styleNoLine );
_SECTION_END();

0 comments

Leave Comment

Please login here to leave a comment.