@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.
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.
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 ...
... because data get stored to bar indexes starting from index zero of entire array.
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();
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();