Transparent "color" for dynamic color

Is there any way to create a dynamic color where the False of the IIF statement is something like 'null', 'clear', or 'transparent'?

Thanks.

Matt

There is no transparent color but you can plot only some of the bars if you pass NULL in actual array to be plotted:

// Null does not plot anything
Plot( IIF( C > MA( C, 10 ), Close, Null ), "Price", colorDefault );
3 Likes

Tomasz,

Thanks for replying. Before I wrote my post, I tried that. Here is the background and my result:

  • I'm using bars, not candles.
  • My bars are black and a thickness of 2.
  • Here is the code:
dynacolor = IIf(idid,ParamColor("ID Color",colorOrange),Null);
PlotOHLC(O,H,L,C,"OHLC",dynacolor,style=styleBar,0,0,0,level,thickness);
  • idid is my definition of Inside Day, which is different than AmiBroker's definition. (Here is the difference: For two bars having the exact same size, the second one is an Inside Day in my definition, but not in AmiBroker's.)
  • Level and Thickness are parameters I created.
  • I set thickness to 2 in order to match the regular plot's size.
  • I set level (zorder) to be higher than my regular plot.

The result when I plot this is that bars that are not Inside Days change to Gray. They are no longer Black. It had the appearance that Null averaged Black with "nothing" and essentially halved the Black intensity, making it Gray.

But, there may be another reason for the color becoming gray. Am I doing something wrong?

Thanks.

Matt

Tomasz,

Oh, I misunderstood you! Yes, I see now that I pass the Null to the conditions describing when I want it painted and I then pass that to the Plot function. Brilliant. I see it now. I apologize for my prior post, as I was responding to what I THOUGHT you said and not what you actually said.

I will try to read more carefully in the future.

Thanks.

Matt

1 Like

As I wrote, use Null in DATA array, not color array. Color must not be null.

You should be using:

color = ParamColor("ID Color",colorOrange);

Plot( IIF( idid, C, Null ),"OHLC",color ,styleBar,0,0,0,level,thickness);

I am using Plot() because OHLC prices are used implictly when you draw bars or candles.

2 Likes

Tomasz,

Our posts crossed in Cyberspace. :slight_smile: I tried to post mine before you had to respond once again to me. Again, I apologize.

Matt

I just want to confirm to everyone, Tomasz' solution worked perfectly! Thanks again, Tomasz for the kind help!

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