.

Adaptive Price Channel - Amibroker AFL Code

Click Image To Enlarge. Please Rate And Comment.


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,"",colorPink,styleThick | styleNoRescale);
Plot(LowChannel,"",colorSeaGreen,styleThick | styleNoRescale );

GraphXSpace=7;
Previous Post Next Post