Indicators Report with many Indicators for only one symbol

Dear Sirs!

I want to make Report for many Indicators, like RSI, ADX, MACD, ROC.. for ONLY ONE SYMBOL.
The Report is two columns:

  1. Column one is all Indicators
  2. Column two is the values of them

The Report format is like this:

AMI Report

Could anyone help me?

Thank you very much!

Use Exploration's Addrow() function together with line

Filter = 0;

Also don't forget to add tab character \t in 1st argument of AddRow() to separate column input.

Also don't forget AddColumn/Addtextcolumn functions to initialize columns.

Output is solely based on AddRow in your case.

3 Likes

Thank you very much for your reply!

I code for many times, but the code do not run.

Could you give me this code?

Best Regards!

@kiennc, why don't you post your code (use the code blocks "</>"), so we can see what you are doing. Then perhaps we can see what you have missed or misunderstood.

2 Likes
_SECTION_BEGIN("Exploration Value of Indicators");

Filter = 0; 
AddTextColumn( FullName(), "Full name", 77);

AddRow("RSI", StrToNum(RSI(14), i));

_SECTION_END();

Here is my code.

Thank you!

Try setting Filter value to 1.

1 Like

Yes, I already set Filter = 1;

But it do not run too.

I only have the Help Guide in Ami like this:

SetOption("NoDefaultColumns", True );
Filter = 1;
AddColumn( Close, "Column1" );
AddColumn( Null, "Column2" );

for( i = 0; i < 10; i++ )
{
   AddRow( StrFormat( "row %g second column", i ) );
}

No @snoopy.pa30 and @kiennc ,
I explicitely wrote Filter = 0;
I do not write things out of the blue to waste time for creating post.

_SECTION_BEGIN("Exploration Value of Indicators");
///@link https://forum.amibroker.com/t/indicators-report-with-many-indicators-for-only-one-symbol/21972/7
SetOption("NoDefaultColumns", True);

/// Set Filter to 0 if output is solely based on AddRow() 
Filter = 0; 
///
/// Initiallize Columns
AddTextColumn( "", "Full name", 1);
AddTextColumn( "", "Indicator name", 1);
AddColumn( Null, "Value", 1.2);

AddRow(StrFormat("%s\tADX\t%g", FullName(), SelectedValue(ADX(14))));
AddRow(StrFormat("%s\tRSI\t%g", FullName(), SelectedValue(RSI(14))));
AddRow("");
_SECTION_END();

15

3 Likes

So with a bit of trial and error....

_SECTION_BEGIN("Exploration Value of Indicators");

SetOption("NoDefaultColumns", True ); 
Filter = 1; 
AddColumn( Null, "Column1" ); 
AddColumn( Null, "Column2" ); 

AddRow( "RSI\t" + LastValue(RSI(14))); 
 
_SECTION_END();
1 Like

Thank you @fxshrat and @snoopy.pa30 !

Yes, with your help, I have the code.

AMI Report

Yes, the result is my LOVE!

With this Reference, I hope I can add more Indicator.

One again, thank you very much!

@fxshrat,

Your solution(s) as always are great.

For us less experienced, I would struggle to understand having a filter value of 0, even though it is correct.

1 Like

Filter = 0; simply means Filter = False;

So that setting will not output AddColumn() / AddTextColumn() data/rows for entire analysis range of a symbol. It will simply disable array data output since as mentioned we just look for output based on AddRow().

AddRow() outputs independently from Filter setting and independently from applied analysis bars range.

AddColumn() / AddTextColumn() in upper code are used only for column initialization.

3 Likes

FYI, If you want to format cells then you can do it without using AddRow also...

Here is code

_SECTION_BEGIN("Exploration Value of Indicators");
/// Code source
/// @link https://forum.amibroker.com/t/indicators-report-with-many-indicators-for-only-one-symbol/21972/13
/// by fxshrat@gmail.com
/// Min. AmiBroker 6.20 required!
Version(6.20);
bi = BarIndex();
lbr = Status("lastbarinrange");
/// you have to modify below number 
/// depending on number of indicators!
num_indicators = 3;// your number of indicators
/// Set your indicators
indicator = Null;
if ( BarCount > num_indicators ) { 
	indicator[0] = 0;
	indicator[1] = LastValue(ValueWhen(lbr,RSI()));
	indicator[2] = LastValue(ValueWhen(lbr,ADX()));
	indicator[3] = LastValue(ValueWhen(lbr,MACD()));
}
/// Set Filter 
Filter = NOT IsNull(indicator); 
/// Exploration Output
SetSortColumns(1, 2);
SetOption("NoDefaultColumns", True);
AddTextColumn( FullName(), "Full name", 1, -1, -1, 150);
TextSelector = 1 * (bi == 1) + 2 * (bi == 2) + 3 * (bi == 3);
TextList = "-------- " + Name() + " --------\nRSI\nADX\nMACD";
bk_color1 = IIf(bi > 0, colorGold, -1);
bk_color2 = IIf(indicator > 0, colorGreen, colorRed);
AddMultiTextColumn(TextSelector, TextList, "Indicator name", 1, IIf(bi==0, colorWhite, colorBlack), bk_color1, 130);
AddColumn(IIf(bi > 0, indicator, Null), "Value", 1.2, -1, bk_color2);
_SECTION_END();

Which would look like this then
15

5 Likes

Dear @fxshrat !

I copy your code, but it show nothing.
Then I add my indicator as bellow:

_SECTION_BEGIN("Exploration Value of Indicators");
/// Code source
/// @link https://forum.amibroker.com/t/indicators-report-with-many-indicators-for-only-one-symbol/21972/13
/// by fxshrat@gmail.com
/// Min. AmiBroker 6.20 required!
Version(6.20);
bi = BarIndex();
lbr = Status("lastbarinrange");
/// you have to modify below number 
/// depending on number of indicators!
num_indicators = 3;// your number of indicators
/// Set your indicators

indicator[0] = 0;
indicator[1] = RSI(14);
indicator[2] = ADX(14);
indicator[3] = MACD(12, 26);
//indicator = Null;

if ( BarCount > num_indicators ) { 
	indicator[0] = 0;
	indicator[1] = LastValue(ValueWhen(lbr,RSI()));
	indicator[2] = LastValue(ValueWhen(lbr,ADX()));
	indicator[3] = LastValue(ValueWhen(lbr,MACD()));
}
/// Set Filter 
Filter = NOT IsNull(indicator); 
/// Exploration Output
SetSortColumns(1, 2);
SetOption("NoDefaultColumns", True);
AddTextColumn( FullName(), "Full name", 1, -1, -1, 150);
TextSelector = 1 * (bi == 1) + 2 * (bi == 2) + 3 * (bi == 3);
TextList = "-------- " + Name() + " --------\nRSI\nADX\nMACD";
bk_color1 = IIf(bi > 0, colorGold, -1);
bk_color2 = IIf(indicator > 0, colorGreen, colorRed);
AddMultiTextColumn(TextSelector, TextList, "Indicator name", 1, IIf(bi==0, colorWhite, colorBlack), bk_color1, 130);
AddColumn(IIf(bi > 0, indicator, Null), "Value", 1.2, -1, bk_color2);
_SECTION_END();

Then it do not run.
Could you please, correct for me?
Thank you very much!

No, no, no.
You do things completely incorrectly.
This is not what I have posted.
Remove it. It is incorrect use of AFL.

What I have posted works correctly.
If you do not get result output then you have not set to Range: All quotes.
But you have to set to All quotes ...
15
... because data get stored to bar indexes starting from index zero of entire array.

2 Likes

Great!

Thank you very much!

Here is code update which will work with other range settings also.
Note: analysis range's number of bars has to be minimum num_indicators+1 otherwise error will be returned reminding to increase analysis range.
Also note: only last bar of range is relevant for indicator value determination.

_SECTION_BEGIN("Exploration Value of Indicators");
/// Code source
/// @link https://forum.amibroker.com/t/indicators-report-with-many-indicators-for-only-one-symbol/21972/18
/// by fxshrat@gmail.com
Version(6.20);
bi = BarIndex();
fbr = Status("firstbarinrange");
lbr = Status("lastbarinrange");
first_bi = LastValue(ValueWhen(fbr,bi));
last_bi = LastValue(ValueWhen(lbr,bi));
bars = last_bi-first_bi+1;
/// you have to modify below number 
/// depending on number of indicators!
num_indicators = 3;// your number of indicators
/// Set your indicators
indicator = Null;
if ( bars > num_indicators ) { 
	indicator[first_bi+0] = 0;
	indicator[first_bi+1] = LastValue(ValueWhen(lbr,RSI()));
	indicator[first_bi+2] = LastValue(ValueWhen(lbr,ADX()));
	indicator[first_bi+3] = LastValue(ValueWhen(lbr,MACD()));
} else
	Error(StrFormat("Increase Analysis range to minimum %g bars", num_indicators+1));
/// Set Filter 
Filter = NOT IsNull(indicator); 
/// Exploration Output
SetSortColumns(1, 2);
SetOption("NoDefaultColumns", True);
AddTextColumn( FullName(), "Full name", 1, -1, -1, 150);
/// TextSelector and TextList have to be modified 
/// if you add/remove/change indicators!
TextSelector = 1 * (bi == first_bi + 1) +
               2 * (bi == first_bi + 2) +
               3 * (bi == first_bi + 3);
TextList = "-------- " +  Name() + " --------\nRSI\nADX\nMACD";
font_color1 = IIf(bi==first_bi, colorWhite, colorBlack);
bk_color1 = IIf(bi > first_bi, colorGold, -1);
bk_color2 = IIf(indicator > 0, colorGreen, colorRed);
AddMultiTextColumn(TextSelector, TextList, "Indicator name", 1, font_color1, bk_color1, 130);
AddColumn(IIf(bi > first_bi, indicator, Null), "Value", 1.2, -1, bk_color2);
_SECTION_END();

Correct range settings -> no error returned

15


15_1


Incorrect setting -> error returned

16

4 Likes

Dear @fxshrat !

First of all, I would like to thank you very much for your help!
My Report now nearly complete, beside the number of VOLUME is the short number like:

AMI Report

The code line in VOLUME is:

AddRow(StrFormat("%s\tVolume\t%g", FullName(), SelectedValue(V)));

But I need the Full Number for the VOLUME.

Could you tell me how can I do for it?
Thank you so much!

It is complete number.
It is just scientific notation.

To show it differently you may change format specifier from %g to %1.0f, for example.


Anyway... I have made an update (which includes general formatting).

...
Also I have added toggle setting to change between AddRow and AddColumn versions.
(Only difference is cell color formatting which you can not implement yet via AddRow)
...

Furthermore in AddColumn version I modified Filter and TextSelector to

Filter = NOT IsNull(indicators) AND bi <= first_bi+num_indicators;

and

TextSelector = 0;
for ( i = 1; i <= num_indicators; i++ )
	TextSelector += i * (bi == first_bi+i);

In AddRow version I modified to

format = "%s\t%s\t%1.2f";
for ( i = 0; i < num_indicators; i++ ) {
	indi = VarGet("indi"+(i+1));
	AddRow(StrFormat(format, full_nm, StrExtract(indi_list,i), SelectedValue(indi)));
}

Full Code:
(Also see marked Set Indicators sections in the code where you can add your further indicators)

_SECTION_BEGIN("Exploration Value of Indicators");
/// choose 1 (AddColumn version) or 0 (AddRow version)
vrs = ParamToggle("Version", "AddRow version|AddColumn version",1);
///
function lbr_value(indi) {
	global lbr;
	return LastValue(ValueWhen(lbr,indi));
}
// #########################################################################################################
if ( vrs > 0 ) {	
	/// Code source
	/// @link https://forum.amibroker.com/t/indicators-report-with-many-indicators-for-only-one-symbol/21972/18
	/// by fxshrat@gmail.com
	Version(6.20);
	bi = BarIndex();
	fbr = Status("firstbarinrange");
	lbr = Status("lastbarinrange");
	first_bi = LastValue(ValueWhen(fbr,bi));
	last_bi = lbr_value(bi);
	bars = last_bi-first_bi+1;	
	/// ####################################################################
	/// Set your indicators
	/// you have to modify below variables
	/// depending on number of indicators!
	indi_list = "ADX\nMACD\nRSI\nVolume";
	indicators = Null;
	num_indicators = StrCount(indi_list,"\n")+1;// your number of indicators	
	if ( bars > num_indicators ) { 
		indicators[first_bi+0] = 0;
		indicators[first_bi+1] = lbr_value(ADX());
		indicators[first_bi+2] = lbr_value(MACD());
		indicators[first_bi+3] = lbr_value(RSI());
		indicators[first_bi+4] = lbr_value(Volume);
		//add further here...
	} else
		Error(StrFormat("Increase Analysis range to minimum %g bars", num_indicators+1));
	/// ####################################################################
	/// Set Filter 
	Filter = NOT IsNull(indicators) AND bi <= first_bi+num_indicators; 
	/// Exploration Output
	SetSortColumns(1, 2);
	SetOption("NoDefaultColumns", True);
	AddTextColumn(FullName(), "Full name", 1, -1, -1, 150);
	TextSelector = 0;
	for ( i = 1; i <= num_indicators; i++ )
		TextSelector += i * (bi == first_bi+i);
	TextList = "-------- " + Name() + " --------\n"+indi_list;
	font_color1 = IIf(bi==first_bi, colorWhite, colorBlack);
	bk_color1 = IIf(bi > first_bi, colorGold, -1);
	bk_color2 = IIf(indicators > 0, colorGreen, colorRed);
	AddMultiTextColumn(TextSelector, TextList, "Indicator name", 1, font_color1, bk_color1, 130);
	AddColumn(IIf(bi > first_bi, indicators, Null), "Value", 1.2, -1, bk_color2);
// #########################################################################################################
} else { //--> AddRow() version
	///@link https://forum.amibroker.com/t/indicators-report-with-many-indicators-for-only-one-symbol/21972/7
	/// by fxshrat@gmail.com
	Version(6.0);
	/// ############################################
	/// Set your indicators
	indi_list = "ADX,MACD,RSI,Volume";
	indi1 = ADX(); indi2 = MACD(); indi3 = RSI(14); indi4 = Volume;
	num_indicators = StrCount(indi_list,",")+1;// your number of indicators	
	/// ############################################
	/// Set Filter to 0 if output is solely based on AddRow()
	Filter = 0; 
	/// Initialize Columns
	SetSortColumns(1, 2);
	SetOption("NoDefaultColumns", True);
	AddTextColumn("", "Full name", 1);
	AddTextColumn("", "Indicator name", 1);
	AddColumn(Null, "Value", 1.2);
	/// AddRow output
	AddRow(StrFormat("%s\t-------- %s --------", full_nm=FullName(), Name()));
	format = "%s\t%s\t%1.2f";
	for ( i = 0; i < num_indicators; i++ ) {
		indi = VarGet("indi"+(i+1));
		AddRow(StrFormat(format, full_nm, StrExtract(indi_list,i), SelectedValue(indi)));
	}
}
_SECTION_END();

8

5 Likes

Dear @fxshrat !

Thank you so much for your help!

1 Like