Add more then two true in TextSelector

add more then two true TextSelector

RSI_IND=RSI(10);

BRSI1= RSI_IND < 30  AND RSI_IND >25;
BRSI2= RSI_IND < 25 AND RSI_IND >20 ;
BRSI3= RSI_IND < 20 ;  
BRSI4= cross( RSI_IND, 30 );
BRSI5= cross( 30, RSI_IND );






/*testind = 
 WriteIf( RSI_IND < 25 AND (Ref(RSI_IND,-1) >25 OR Ref(RSI_IND,-2) >25) ,"START BUY ZOON" ,
        WriteIf( RSI_IND < 20 AND (Ref(RSI_IND,-1) >20 OR Ref(RSI_IND,-2) >20) ,"CONFIRM BUY ZOON" ,
        WriteIf( RSI_IND < 20 AND (RSI_IND  > Ref(RSI_IND,-1) AND RSI_IND  > Ref(RSI_IND,-2)) ," BUY UP" ,
        WriteIf (RSI_IND < 20 , "BUY ZOON :" ," no"))));*/
       
       TextSelector = 1 * BRSI1  + 2 * BRSI2 + 3 * BRSI3 + 4 * BRSI4 + 5 * BRSI5 ; 
       TextList = "No signal\nSTART BUY ZOON\nCONFIRM BUY ZOON\nBUY ZOON\njust crossed above 30\njust crossed below 30";
       
       Filter=1;
       AddColumn(RSI_IND,"rsi",1.2,colorDefault,colorDefault);
       AddColumn(BRSI1,"s1",1.2,IIf(BRSI1,colorGreen,colorRed),colorDefault);
       AddColumn(BRSI2,"s2",1.2,IIf(BRSI2,colorGreen,colorRed),colorDefault);
       AddColumn(BRSI3,"s3",1.2,IIf(BRSI3,colorGreen,colorRed),colorDefault);
       AddColumn(BRSI4,"s4",1.2,IIf(BRSI4,colorGreen,colorRed),colorDefault);
         AddColumn(BRSI5,"s5",1.2,IIf(BRSI5,colorGreen,colorRed),colorDefault);
  //AddTextColumn(testind, "test", 1.0, colorDefault, colorDefault,100);
  AddMultiTextColumn(TextSelector, TextList  ,"check", 1.0, colorDefault, colorDefault,100);

when two or more are true , it will not show in the exploration

how to add all the true togethers if it is happened ?

test5

i tried to modify fxshrat code but I could not

Exploration Multi timeframe chart

and is it possible to add the value to TextSelector
thank you

Yes it's possible, as the post you referenced clearly shows. You just need to pay attention to the details. In particular, notice these things:

  • The TextSelector values for the 3 underlying conditions are all powers of 2: 1, 2, 4
  • The TextList contains 2^n = 8 different strings

In your example, you have 5 underlying conditions, so your TextList would need to have 2^5 = 32 different strings corresponding to every possible combination of the 5 conditions.

Personally, I would just replace your s1...s5 column headings with more descriptive names like "Start Buy Zoon", "Confirm Buy Zoon", etc. as that will be much simpler to code and will convey the same information.

1 Like

now it is ok so far for this issue

RSI_IND=RSI(10);

below_30=  cross( 30, RSI_IND );
START_BUY_ZOON= RSI_IND < 30  AND RSI_IND >25;
CONFIRM_BUY_ZOON= RSI_IND < 25 AND RSI_IND >20 ;
above_30= cross( RSI_IND, 30 ); 
Buy_ZOON= RSI_IND < 20 ; 




//s4= RSI_IND < 20 ;

/*testind = 
 WriteIf( RSI_IND < 25 AND (Ref(RSI_IND,-1) >25 OR Ref(RSI_IND,-2) >25) ,"START BUY ZOON" ,
        WriteIf( RSI_IND < 20 AND (Ref(RSI_IND,-1) >20 OR Ref(RSI_IND,-2) >20) ,"CONFIRM BUY ZOON" ,
        WriteIf( RSI_IND < 20 AND (RSI_IND  > Ref(RSI_IND,-1) AND RSI_IND  > Ref(RSI_IND,-2)) ," BUY UP" ,
        WriteIf (RSI_IND < 20 , "BUY ZOON :" ," no"))));*/
       
       TextSelector = 1 * below_30  + 2 * START_BUY_ZOON + 4 * CONFIRM_BUY_ZOON + 8 * above_30 + 9 * Buy_ZOON ; 
       TextList = "No signal\nbelow_30\nSTART_BUY_ZOON\nbelow_30 & nSTART_BUY_ZOON\nCONFIRM_BUY_ZOON\nbelow_30 & CONFIRM_BUY_ZOON\nSTART_BUY_ZOON & CONFIRM_BUY_ZOON\nbelow_30 & START_BUY_ZOON & CONFIRM_BUY_ZOON \n"+
                   "above_30\nBuy_ZOON";
       
       //TextSelector = 1 * Cond1 + 2 * Cond2 + 4 * Cond3 + 8 * Cond4 + 16 * Cond5 + 32 * Cond6 + 64 * Cond7; // etc.
/* would give 0 if no signal, 1 if Cond1, 2 if Cond2, 3 if Cond1 and Cond2, 4 if Cond3, 5 if Cond1 and Cond3, 6 if Cond2 and Cond3, 7 if Cond1 and Cond2 and Cond3, 8 if Cond4 ... */
       Filter=1;
       AddColumn(RSI_IND,"rsi",1.2,colorDefault,colorDefault);
       AddColumn(below_30,"below_30",1.2,IIf(below_30,colorGreen,colorRed),colorDefault);
       AddColumn(START_BUY_ZOON,"START_BUY_ZOON",1.2,IIf(START_BUY_ZOON,colorGreen,colorRed),colorDefault);
       AddColumn(CONFIRM_BUY_ZOON,"CONFIRM_BUY_ZOON",1.2,IIf(CONFIRM_BUY_ZOON,colorGreen,colorRed),colorDefault);
       AddColumn(above_30,"above_30",1.2,IIf(above_30,colorGreen,colorRed),colorDefault);
         AddColumn(Buy_ZOON,"Buy_ZOON",1.2,IIf(Buy_ZOON,colorGreen,colorRed),colorDefault);
  //AddTextColumn(testind, "test", 1.0, colorDefault, colorDefault,100);
  AddMultiTextColumn(TextSelector, TextList  ,"check", 1.0, colorDefault, colorDefault,100);

According to your instructions, I should put the probabilities in order of their occurrence
Until the seventh possibility became clear as below

//TextSelector = 1 * Cond1 + 2 * Cond2 + 4 * Cond3 + 8 * Cond4 + 16 * Cond5 + 32 * Cond6 + 64 * Cond7; // etc.
/* would give 0 if no signal, 1 if Cond1, 2 if Cond2, 3 if Cond1 and Cond2, 4 if Cond3, 5 if Cond1 and Cond3, 6 if Cond2 and Cond3, 7 if Cond1 and Cond2 and Cond3, 8 if Cond4 ... */
what is after 8
If I have more than five possibilities and they conflict with each other like 1 and 2 and 3 and 5

test6

is it possible to add the value of RSI at the end of the condition ?

In fact, I was getting dizzy by the possibilities and they are only three interconnected
What if they were five or more?

Is there a code to identify the possibilities and collect them, if any?
I mean, if there are 4 possibilities that combine them together
using ( for )

TextSelector is really hard if there are more then 3 conditions

thank you

is this the code

Returning Non Null values of a vector

code by fxshrat

/// @link http://forum.amibroker.com/t/returning-non-null-values-of-a-vector/2036/6
/// snippet for AddMultiTextColumn function
/// text output only if single condition of seven is true.
/// 
TextList = "";
for( i = 0; i <= 64; i++) {
	switch( i ) {
		case 1:		TextList += "1";	break;
		case 2:		TextList += "2";	break;
		case 4:		TextList += "4";	break;
		case 8:		TextList += "8";	break;
		case 16:	TextList += "16";	break;
		case 32:	TextList += "32";	break;
		case 64:	TextList += "64";	break;
		default: break;
	}
	TextList += "\n";
}

text output only if single condition of seven is true

only for one

No, you just need to think it through.

Why don't you try it and see!

1 Like

i tried it and as it was stated above

how to add the event value to the Textlist

test7

thank you

this what i com up with as my understanding for TextList

test8

image

how to add the RSI value to the end of the TextList

thank you

i try to use the code below but not working

RSI_IND=RSI(10);

below_30=  cross( 30, RSI_IND );
START_BUY_ZOON= RSI_IND < 30  AND RSI_IND >25;
CONFIRM_BUY_ZOON= RSI_IND < 25 AND RSI_IND >20 ;
above_30= cross( RSI_IND, 30 ); 
Buy_ZOON= RSI_IND < 20 ; 




//s4= RSI_IND < 20 ;

/*testind = 
 WriteIf( RSI_IND < 25 AND (Ref(RSI_IND,-1) >25 OR Ref(RSI_IND,-2) >25) ,"START BUY ZOON" ,
        WriteIf( RSI_IND < 20 AND (Ref(RSI_IND,-1) >20 OR Ref(RSI_IND,-2) >20) ,"CONFIRM BUY ZOON" ,
        WriteIf( RSI_IND < 20 AND (RSI_IND  > Ref(RSI_IND,-1) AND RSI_IND  > Ref(RSI_IND,-2)) ," BUY UP" ,
        WriteIf (RSI_IND < 20 , "BUY ZOON :" ," no"))));*/
       var = ValueWhen( below_30, Close );
       varelement = SelectedValue( below_30 );
        ss=ValueWhen(below_30,RSI_IND);


       TextSelector = 1 * below_30  + 2 * START_BUY_ZOON + 4 * CONFIRM_BUY_ZOON + 8 * above_30 + 9 * Buy_ZOON ; 
       TextList = "No Signal "+ Prec(RSI_IND,2) + "\nbelow_30\nSTART_BUY_ZOON\nbelow_30 & START_BUY_ZOON RSI= "+ Prec(ss,2)+ "\nCONFIRM_BUY_ZOON\nbelow_30 & CONFIRM_BUY_ZOON\nSTART_BUY_ZOON & CONFIRM_BUY_ZOON\nbelow_30 & START_BUY_ZOON & CONFIRM_BUY_ZOON \n"+
                   "above_30\nBuy_ZOON";
       
       //TextSelector = 1 * Cond1 + 2 * Cond2 + 4 * Cond3 + 8 * Cond4 + 16 * Cond5 + 32 * Cond6 + 64 * Cond7; // etc.
/* would give 0 if no signal, 1 if Cond1, 2 if Cond2, 3 if Cond1 and Cond2, 4 if Cond3, 5 if Cond1 and Cond3, 6 if Cond2 and Cond3, 7 if Cond1 and Cond2 and Cond3, 8 if Cond4 ... */
       Filter=1;
       AddColumn(RSI_IND,"rsi",1.2,colorDefault,colorDefault);
       AddColumn(below_30,"below_30",1.2,IIf(below_30,colorGreen,colorRed),colorDefault);
       AddColumn(START_BUY_ZOON,"START_BUY_ZOON",1.2,IIf(START_BUY_ZOON,colorGreen,colorRed),colorDefault);
       AddColumn(CONFIRM_BUY_ZOON,"CONFIRM_BUY_ZOON",1.2,IIf(CONFIRM_BUY_ZOON,colorGreen,colorRed),colorDefault);
       AddColumn(above_30,"above_30",1.2,IIf(above_30,colorGreen,colorRed),colorDefault);
         AddColumn(Buy_ZOON,"Buy_ZOON",1.2,IIf(Buy_ZOON,colorGreen,colorRed),colorDefault);
  //AddTextColumn(testind, "test", 1.0, colorDefault, colorDefault,100);
  AddMultiTextColumn(TextSelector, TextList  ,"check : "+ round(RSI_IND ), 1.0, colorDefault, colorDefault,100)

image

thank you

i used DateTime(); and ValueWhen

RSI_IND=RSI(10);

below_30=  cross( 30, RSI_IND );
START_BUY_ZOON= RSI_IND < 30  AND RSI_IND >25;
CONFIRM_BUY_ZOON= RSI_IND < 25 AND RSI_IND >20 ;
above_30= cross( RSI_IND, 30 ); 
Buy_ZOON= RSI_IND < 20 ; 

      
       dt = DateTime();
       tt=ValueWhen( below_30, dt ) ;
       rr=ValueWhen( tt, RSI_IND ) ;
       ClP = ValueWhen(DateTime(),rr,1);
        
       TextSelector = 1 * below_30  + 2 * START_BUY_ZOON + 4 * CONFIRM_BUY_ZOON + 8 * above_30 + 9 * Buy_ZOON ; 
       TextList = "No Signal "+ Prec(ClP,2) + "\nbelow_30"+ Prec(rr,2)+"\nSTART_BUY_ZOON\nbelow_30 & START_BUY_ZOON RSI= "+ Prec(ClP,2)+ "\nCONFIRM_BUY_ZOON\nbelow_30 & CONFIRM_BUY_ZOON\nSTART_BUY_ZOON & CONFIRM_BUY_ZOON\nbelow_30 & START_BUY_ZOON & CONFIRM_BUY_ZOON \n"+
                   "above_30\nBuy_ZOON";
                   
       
       //TextSelector = 1 * Cond1 + 2 * Cond2 + 4 * Cond3 + 8 * Cond4 + 16 * Cond5 + 32 * Cond6 + 64 * Cond7; // etc.
/* would give 0 if no signal, 1 if Cond1, 2 if Cond2, 3 if Cond1 and Cond2, 4 if Cond3, 5 if Cond1 and Cond3, 6 if Cond2 and Cond3, 7 if Cond1 and Cond2 and Cond3, 8 if Cond4 ... */
       Filter=1;
       AddColumn(RSI_IND,"rsi",1.2,colorDefault,colorDefault);
       AddColumn(tt,"tt",formatDateTime,1.2,colorDefault,colorDefault);
       AddColumn(rr,"rr",1.2,colorDefault,colorDefault);
       AddColumn(ClP,"ClP",1.2,colorDefault,colorDefault);
       AddColumn(below_30,"below_30",1.2,IIf(below_30,colorGreen,colorRed),colorDefault);
       AddColumn(START_BUY_ZOON,"START_BUY_ZOON",1.2,IIf(START_BUY_ZOON,colorGreen,colorRed),colorDefault);
       AddColumn(CONFIRM_BUY_ZOON,"CONFIRM_BUY_ZOON",1.2,IIf(CONFIRM_BUY_ZOON,colorGreen,colorRed),colorDefault);
       AddColumn(above_30,"above_30",1.2,IIf(above_30,colorGreen,colorRed),colorDefault);
         AddColumn(Buy_ZOON,"Buy_ZOON",1.2,IIf(Buy_ZOON,colorGreen,colorRed),colorDefault);
  //AddTextColumn(testind, "test", 1.0, colorDefault, colorDefault,100);
  AddMultiTextColumn(TextSelector, TextList  ,"check : "+ round(RSI_IND ), 1.0, colorDefault, colorDefault,100);

it shows in the column but different with textlist

image

why AB is doing that ?

i don't know even though we start to like each other .

dear Tomasz

is it possible to add the value of the indicator with the same date to the TextList.

No, that is not possible. It is not obvious why you're trying to put so much information into a single text column, but perhaps your needs would be better served by just writing data to a text/CSV file.

1 Like

dear mradtke

thank you for your reply

i will make different indicator in exploration with conditions as rsi and others
when i add the value of the indicator in the and of the text i will not need to add Columns for the indicator

like the current value of the indicator i add it in the title as below

image

but i was thinking if there is away to add the value by comparing the date of the event to the date Column and add the value of the indicator in that date ( the front of the date) to the text based in the sorting

i am not able to explain it right . forgive me

thank you

if i try to use for statement it will work.

can not be done in AB

thank you

Moderator comment: that’s false assumption based on lack of knowledge

I like the title

AmiBroker - much more than just ordinary technical analysis software

Remember that you can just use AddRow function where you can freely output ANYTHING

https://www.amibroker.com/f?addrow

There are simply no “impossible” things in AmiBroker, you just may not be aware how to do use existing functionality

This is the solution
I forgot that you are the owner