Write automatically in the title, name of the AFL file name?

Hello,
is there is a way to write automatically in the title, name of the AFL file name?

for example, if I make and save an afl name it bollinger AFL 1.1111, in the title chart would be automatically write :
bollinger AFL 1.1111. AAPL Daily 10-Jun-18 O= etc

then if I make change on the AFL and change it name to bollinger AFL 2.3, the title would also automatically write
bollinger AFL 2.3. AAPL Daily 10-Jun-18 O= etc

I think it would be handy to have that kind of option

thanks

Hi Guntur,

There might be other direct shortcuts to get the AFL filename that I am not aware of. Would be more than happy to see one. Anyways, below is what I have done using simple String Manipulations.

_SECTION_BEGIN( "BBand" );
	 p = Param( "Periods", 15, 2, 200, 1 );
	 width = Param( "Stnd. Dev.", 2, 1, 5, 1 );
	 arr = ParamField( "Array", 4 );

	 bbt = BBandTop( arr, p, width );
	 bbb = BBandBot( arr, p, width );
	 
	 //---------String Manipulations to get the filename---------
	 FormPath = GetFormulaPath();
	 Reduced1 = StrLeft( FormPath, StrLen( FormPath ) - 4 );
	 FormName = Reduced1;
	 for( i = 0; i < StrCount( Reduced1, "\\" ); i++ )
	 {
	 	 LastCharPos = StrFind( FormName, "\\" );
	 	 FormName = StrRight( FormName, StrLen( FormName ) - LastCharPos );
	 }
	 //----------------------------------------------------------
	 
	 // http://www.amibroker.com/kb/2015/02/13/customizing-chart-titles/
	 Title = FormName + StrFormat(". {{NAME}} " + FullName() + 
	 " - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +
	 WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) );
	 
	 Plot( C, "", colorDefault, styleCandle );
	 Plot( bbt, "", colorGreen, styleLine );
	 Plot( bbb, "", colorRed, styleLine );	 
_SECTION_END();

Cheers!

Hi sikatgigi

Minor adjustments required to fit your monitor or screen - Manual name change required

Hope its what you are after..

Skate

////////////////////////////////////////////////////////////////////////////////////
/////Bollinger Strategy Name
////////////////////////////////////////////////////////////////////////////////////
x=Param("xposn",1,0,1000,1);
y=Param("yposn",1,0,1000,1);
GfxGradientRect(1, 1, 1801, 40, colorGrey50, colorDarkGrey);
GfxSetBkMode(0);
GfxSelectFont("Georgia", 18, 500, False);
GfxSetTextColor(colorWhite);
GfxTextOut("Bollinger AFL1.1111  Strategy", x+800, y+4);
GfxSelectFont("Tahoma", 17, 300, False);
GfxSetTextColor(colorYellow);
GfxTextOut(Name(), x+30, y+3);
GfxSelectFont("Century Gothic", 10, 100, False);
GfxTextOut(FullName(), x+85, y+9);
GfxSelectFont("Century Gothic", 15, 100, False);
GfxSetTextColor(colorWhite);
GfxTextOut(Date(), x+1690, y+5);
GfxSelectFont("Comic Sans MS", 15, 500, False);
GfxSetTextColor(colorYellow);
GfxTextOut(Interval(2), x+1590, y+2);
////////////////////////////////////////////////////////////////////////////////////
/////High, Open, Low Close
////////////////////////////////////////////////////////////////////////////////////
GfxGradientRect(1, 40, 1801, 55, colorGrey50, colorDarkGrey);
GfxSetBkMode(0);
GfxSelectFont("Areal", 9, 200, False);
GfxSetTextColor(colorWhite);
GfxTextOut("High:"+WriteVal(H,1.3), x+1420, y+40);
GfxSelectFont("Areal", 9, 200, False);
GfxSetTextColor(colorWhite);
GfxTextOut("Low:"+WriteVal(L,1.3), x+1520, y+40);
GfxSelectFont("Areal", 9, 200, False);
GfxSetTextColor(colorWhite);
GfxTextOut("Open:"+WriteVal(O,1.3), x+1620, y+40);
GfxSelectFont("Areal", 9, 200, False);
GfxSetTextColor(colorWhite);
GfxTextOut("Close:"+WriteVal(C,1.3), x+1720, y+40);
GfxSelectFont("Areal", 13, 100, False);
GfxSetTextColor(colorWhite);
GfxTextOut("Created for: sikatgigi", x+30, y+38);

Function by Tomasz Janeczko from the old Yahoo list:

function GetFormulaName()
{   // by T.Janeczko
	return StrExtract( StrExtract( GetFormulaPath(), -1, '\\' ), -2, '.' );
} 

Title = GetFormulaName();
7 Likes

OMG thx a lot all of you :blush::blush::blush: