How show different timeframe charts with different parameter of same AFL

Hi everyone,

i am having problem , setting one same AFL with different parameter for different time frames..when watching all time frames at the same time
( daily with n=25, monthly n=20, quartly n=15, yearly n=3 )

*i.e. if i set n = 25 (parameter ) in daily chart & than when i shift to yearly, it remains n=3, *
which is not useful, i need n=3 for yearly.

i need it lock different n parameter for different time frames, to see it easily.

its a trend following afl, known as KPL swing indicator.

Thank you very much.

Screenshot 2020-06-03 20.13.42

Following is the AFL code. written by kamlaesh langote.

_SECTION_BEGIN("KPL Swing");
//Save indicator as "kplswing.afl" in C: program files > Amibroker > Formulas > Custom folder and then drag and drop indicator on price window.
//Copyright Kamalesh Langote. Email:kpl@vfmdirect.com. Visit http://www.vfmdirect.com/kplswing for latest code and updates
//You can use in indicator mode (chart) or scanner (generate buy/ sell signals).
//Risk management: do not risk more than 1% of your capital on any trade.
//Avoid trading in futures unless you are well capitalised.

no=Param( "Swing", 20, 1, 100,1 );

res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
tsl=IIf(avn==1,sup,res);

Plot(tsl, _DEFAULT_NAME(), colorblack, styleStaircase);
Plot(IIf(C>tsl,HHV(LLV(L,no/2),no/2),LLV(HHV(H,no/2),no/2)),"SL",colorLightGrey,styleStaircase);
arrows=Cross(C,Ref(res,-1))*shapeUpArrow + Cross(Ref(sup,-1),C)*shapeDownArrow;
PlotShapes(arrows,IIf(C>tsl,colorGreen,colorIndigo),0,IIf(Cross(C,Ref(res,-1)),Low,High));

//Scanner mode
Buy=Cross(C,Ref(res,-1));
Sell=Cross(Ref(sup,-1),C);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

_SECTION_END();

You have to create New Blank Chart but not New Default Chart. Default chart will have same ChartID for all chart tabs and so if you change Param* it will be changed for all charts to same value. If you create Blank Chart then Param will remain fix per chart tab once it is set and not being modified per chart.

13


If you look for fix values per interval then use Interval() function.

switch ( Interval(2) ) {
	case "Monthly":
		no = 20;	break;		
	case "Quarterly":
		no = 15;	break;		
	case "Yearly":
		no = 3;	break;		
	case "Daily":     
	default:       
		no = 25;	break;
}

printf( "no: %g", no);

res=HHV(H,no);
sup=LLV(L,no);

Besides you should read here first (before creating post). Please apply code tags button for inserting code to a post.

4 Likes

thanx fxshrat for replying the solutions,
and that too with screenshot...

regarding, the code you provided,
should i insert that in existing AFL ?
sorry for asking such things, as i am no coder .

again. thanx.

worked like a dream.

thanx for solution.

1 Like

@kalpenpatel,
Great but if you want to mark something as solution then you rather should mark the post that actually solved your issue but not a post asking question(s).