Random code copy-pasted from the Internet does not work, was: Dear Sir and Senior

Dear Sir and Senior

I just got AFL Explorel from my friend, he said it was very good. But when I tried exploring, it was empty and didn't work. Can you help me fix it. Thank's very much

_SECTION_BEGIN("P/L % Change over Time with Beta Correlation");
	TtD_Param		=	ParamList("Period","Day to Date|Week to Date|Month to Date|Year to Date",0);
	IDX_Param		=	ParamStr("Reference Market Index Symbol","GroupID(1)");  
	FDayMonth		=	BarsSince(Month() != Ref(Month(),-1));
	FDayYear		=	BarsSince(Year() != Ref(Year(),-1));
	TtD_Period		=	IIf(TtD_Param	==	"Day to Date",1,
						IIf(TtD_Param	==	"Week to Date",DayOfWeek(),
						IIf(TtD_Param	==	"Month to Date",FDayMonth,
						IIf(TtD_Param	==	"Year to Date",FDayYear,0))));
	IDX_Close		=	Foreign(IDX_Param,"Close");
//		P/L % Change
	TtD_Change		= 100 * (Close - Ref(Close, -TtD_Period) ) / Ref(Close, -TtD_Period);
//		Beta Correlation in Time from Index
	Beta			=	(( TtD_Period * Sum(ROC( C,1) * ROC(IDX_Close,1),TtD_Period )) -
						(Sum(ROC(C,1),TtD_Period) *
						Sum(ROC( IDX_Close,1),TtD_Period))) /
						((TtD_Period * Sum((ROC(IDX_Close,1)^2 ),TtD_Period)) -
						(Sum(ROC(IDX_Close,1 ),TtD_Period)^2 ));
	AddColumn		(Beta,"(Beta)",1.2,IIf(Beta>0,colorGreen,colorRed));						

Check the links that show up by a simple Google search. The code that you have pasted, is a part of one of them (probably the first one).

1 Like

Thanks for helpfull., I'm already try and try You link. But still canot use Beta column.


Sorry to say!

Till the time you keep copy/pasting codes written by others without understanding them, you will face these kind of issues...


@Batupermata, is there a reason you're not asking the friend who provided this "very good" exploration why it's not working? No one here knows what data you're using, which options you've selected, what timeframe/periodicity is active... that makes it very hard to help you troubleshoot. You might want to start by reviewing this post: How to ask a good question


Thank you very much for your help and concern, maybe coding explorer is too difficult. I'd better just skip it.