Exploration output - how to change default text alignment

The code below has TEXT columns are LEFT justified and NUMERIC columns are RIGHT justified.

This is, in fact, the default behavior but makes the readability of the report a little confusing.

It would be good if there were a way to re-adjust the column headers to left justification if needed.

Filter = Status( "lastbarinrange" ); 
SetOption( "Nodefaultcolumns", True ); 
AddTextColumn( Name(), "Ticker", 1, -1, -1, 80 );   
AddTextColumn( Interval(2), "TimeFrame", 1, -1, -1, 80 ); 
Addcolumn( O, "Open", 1.2, -1, -1, 60 ); 
Addcolumn( H, "High", 1.2, -1, -1, 60 ); 
Addcolumn( L, "Low", 1.2, -1, -1, 60 ); 
Addcolumn( C, "Close", 1.2, -1, -1, 60 ); 

I don't know what confuses you in the default output - I think the readability is really good:


... but if you really want to have all columns left side aligned, you can use only Text Columns:


Filter = Status( "lastbarinrange" ); 
SetOption( "Nodefaultcolumns", True ); 
AddTextColumn( Name(), "Ticker", 1, -1, -1, 80 );   
AddTextColumn( Interval(2), "TimeFrame", 1, -1, -1, 80 );
AddTextColumn(NumToStr(O, 1.2), "Open", 1.2, -1,-1, 60); 
// Or just AddTextColumn(""+O, "Open", 1.2, -1,-1, 60); 
AddTextColumn(NumToStr(H, 1.2), "High",1.2, -1,-1, 60); 
AddTextColumn(NumToStr(L, 1.2), "Low", 1.2, -1,-1, 60); 
AddTextColumn(NumToStr(C, 1.2), "Close", 1.2, -1,-1, 60); 

But if you would like to sort such columns, you have to take into account, that that sorting of string/text columns is performed in a different way than numeric ones. For this reason, it might not be optimal solution.


I tried to include a short snipit of code to work from. However, my snipit choice was not optimal.

Below is a picture that illustrates OpenDT and CloseDT that I would prefer to have at least a left justified header. I included some sample code from it as well below.


AddColumn( Null, "OpenDT", formatDateTimeISO, -1, -1, 160 ); 
AddColumn( Null, "CloseDT", formatDateTimeISO, -1, -1, 160 ); 

@tedpenner In your last reply, you didn't post the working example of the code and you didn't mention, that contrary to the code from your first post (which was misleading), actually you are using AddRow() to display data in the columns and AddColumn( Null, ...) is only used to format the Exploration's columns. I guess it is a continuation of this thread:


It would be nice, if you had mentioned all that information because using AddColumn() and AddtextColumn() differes from using AddRow(). If you find using AddRow() difficult (and in my opinion using it just to be able to append percent sign (%) to each row might not be justified it in case of the users who are not acquainted well enough with Exploration), just use the two other functions which are simpler to use and which had been used for years before AddRow() was implemented. But if you want to keep using the AddRow() code and just need a left justified header (without pondering alternative solutions) you can quickly implement the simplest one:


AddColumn( Null, "OpenDT                                  ", formatDateTimeISO, -1, -1, 160 ); 
AddColumn( Null, "CloseDT                                  ", formatDateTimeISO, -1, -1, 160 ); 

I agree but the person that was helping me did not want all the information made public. I was just trying to respect those wishes. Thank you very much for the info and I appologize for the lack of clarity.

Are you talking about @fxshrat who has written the initial code? That would be strange, because he has made the code public, pasting it on the forum:

It is a very nice example of using AddRow(). I study all @fxshrat codes and treat them as inspiration in my ongoing search for the optimal AFL code :wink: I bet that, apart from Tomasz, he is currently the most proficient AB user, but occasionally some of his codes might be too sophisticated for the beginners who might want to start from some simpler/basic solutions and then (if they need to) move on to the more ambitious ones...


1 Like

Yes, he is the one that asked me not to post it.