Dynamically use EncodeColor() in Title

Any ideas on how to dynamically change the Title colors, in particular, the values?

I want to use the EWOColor for the entire Title color, so that the title is either UpColor or DownColor.
With EncodeColor(EWOColor), I receive an error:

I tried a simpler syntax, but I am still unable to change the color for the {{VALUES}}

EWOColor = IIf( ElliottWaveOsc > 0, UpColor, DownColor );
Title = EncodeColor(colorYellow) + "{{NAME}} - " + _Default_Name() +  "{{DATE}}:"  + EncodeColor(colorYellow) + "{{VALUES}}"  ; 
Plot( ElliottWaveOsc, " " ,EWOColor, ParamStyle( "Style", styleHistogram | styleThick, maskHistogram  ));

This is what I see. I was expecting the values to be yellow, not white.

You may want to visit “Writeif” function.


Sanjiv Bansal

@Sumangalam Thanks! I replaced a line of code as you suggested. That works and solves half the issue.
The value is still coming out white! Any other ideas?

Title = WriteIf(ElliottWaveOsc > 0,EncodeColor(colorGreen),EncodeColor(colorRed)) + "{{NAME}} - " + _Default_Name() +  "{{DATE}}:"  + "{{VALUES}}"  ; 

Please check if it helps?


Sanjiv Bansal

AmiBroker specifically uses white on black or black on white for readability.
As I wrote many times, people seriously underestimate the amount of thinking that was put into AmiBroker. We have tested all combinations including writing values with color and it is bad idea.
Really if you have blue or red plot the value is very unreadable if you try to write blue on black.
So just don’t do that.

And as for why your code does not work - because it is wrong. You are not writing the values yourself. Your code is using default rendering anyway (the {{VALUES}} INCLUDE color switching). If you used StrFormat instead of {{VALUES}} it would work.

1 Like

@Tomasz First, thank you for the response. I do agree that reading red on black background is harder to read. I use it to highlight an exception condition.

The following line of code achieved my desired result to control the color for the value.

Title =  WriteIf(ElliottWaveOsc > 0,EncodeColor(colorGreen),EncodeColor(colorRed)) + "{{NAME}}" +" | " + _Default_Name() + " | "+ "{{DATE}}" +" | "  + NumToStr(ElliottWaveOsc, 1.5)   ; 

@Tomasz Second, speaking on my own behalf (and perhaps others?), I have a programming background.

I am exceptionally impressed with the extraordinary amount of forethought and engineering that went into Amibroker. I hope my questions and suggestions are taken only as constructive end-user feedback, and not as any criticism whatsoever.

I absolutely LOVE the feature set. I continue to discover (with the help of this forum and other users) new ways to put this Amibroker to work in ways I could was never able to imagine with other products!

But, I am a Greedy End User! I want more features, more ease-of-use, more functions and more pre-set templates and charts. LOL!

Thank you again. Please continue enhancing this great product!