Exploration output not displaying as desired

Hi,

I have written a small exploration code that scans symbols that have recently broken support lines: Support 1 and Support 2 and moved upwards.

Here is the piece of code:

PDH = TimeFrameGetPrice( "H", inDaily, -1 );
PDL = TimeFrameGetPrice( "L", inDaily, -1 );
PDC = TimeFrameGetPrice( "C", inDaily, -1 );
PV = Prec( ( ( PDH + PDL + PDC ) / 3 ), 2 );
R1 = Prec( ( 2 * PV - PDL ), 2 );
S1 = Prec( ( 2 * PV - PDH ), 2 );
R2 = Prec( ( PV + ( PDH - PDL ) ), 2 );
S2 = Prec( ( PV - ( PDH - PDL ) ), 2 );
pI = LastValue( PV, 1 );
cR1 = LastValue( R1, 1 );
cS1 = LastValue( S1, 1 );
cR2 = LastValue( R2, 1 );
cS2 = LastValue( S2, 1 );
s1c = Cross( C, cS1 );
s2c = Cross( C, cS2 );
sup_cross = WriteIf( s1c, "S1", WriteIf( s2c, "S2", "" ) );
sup_colors = IIf( s1c, colorLime, IIf( s2c, colorGreen, colorDefault ) );
Parameters = s1c OR s2c;
Filter = Parameters;
AddTextColumn( sup_cross, "Crossover", 1, colorDefault, sup_colors );
SetSortColumns( 2 );

Here is the output:

Capture

Surprisingly in the output, I am not able to see "S1" or "S2" labels in the "Crossover" column and they are mostly empty. Can somebody identify what I am missing in the code?
Any help is much appreciated.

First issue:

When posting the formula, please make sure that you use Code Tags (using </> code button) as explained here: How to use this site.

Using code button

Code tags are required so formulas can be properly displayed and copied without errors.

Second issue:

You are not reading the docs:
https://www.amibroker.com/f?addtextcolumn

that explains the results you are getting

Also here:

Third issue

You are not searching the forum before posting. Always make a search.

If you looked at existing posts you will get this:

https://forum.amibroker.com/search?q=AddTextColumn

The answer to your question is posted on this forum dozens of times.

1 Like

Thanks Tomasz for pointing out to put the code in Tags. I will remember it from next time. Actually the code tag was hidden in the "settings gear icon" and that's why I couldn't see it in first place. Sincere apologies for that.

Regarding the solution you mentioned, I already tried the solutions mentioned in previous posts on the forum. But still no luck!

Here is the code and the screenshot:

PDH =  SelectedValue(TimeFrameGetPrice( "H", inDaily, -1 ));
PDL =  SelectedValue(TimeFrameGetPrice( "L", inDaily, -1 ));
PDC =  SelectedValue(TimeFrameGetPrice( "C", inDaily, -1 ));
PV = Prec( ( ( PDH + PDL + PDC ) / 3 ), 2 );
R1 = Prec( ( 2 * PV - PDL ), 2 );
S1 = Prec( ( 2 * PV - PDH ), 2 );
R2 = Prec( ( PV + ( PDH - PDL ) ), 2 );
S2 = Prec( ( PV - ( PDH - PDL ) ), 2 );
R3 = Prec( ( PDH + 2 * ( PV - PDL ) ), 2 );
S3 = Prec( ( PDL - 2 * ( PDH - PV ) ), 2 );

s1c = Cross( C, S1 );
s2c = Cross( C, S2 );
s3c = Cross( C, S3 );

co = WriteIf( s1c, "S1", WriteIf( s2c, "S2", WriteIf( s3c, "S3", "" )));

Parameters = s1c OR s2c OR s3c;
Filter = Parameters;

AddTextColumn( co, "Cross", 1.0, colorDefault, colorDefault, 170 );

Capture3

Please tell how to put the respective labels ("S1" or "S2" or "S3") in the "Cross" column?
Any help is much appreciated.

Thanks,
Sandeep

You still did not read the links I gave you.
You should be using the answer from the thread I pointed out earlier: Unexpected result using AddTextColumn - #6 by beppe

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.