What is the "do nothing" function in thinkScript?

lmk99

Member
VIP
How to tell an indicator to plot nothing if a condition or variable is not met? In other words, I can't make the "else" condition something like "0" because then the plot will still appear with a 0 value. I just want the plot to only appear if the condition given in parenthesis after the "if" clause is met. "![Variable Name]" doesn't work and "false" doesn't work either. And I can't just daisy-chain the plots together since if I call the next plot that hasn't been defined yet (e.g. "else StrongBull" in the WeakBull plot script line) that doesn't work.

I have tried a number of ways to make this work but I can't figure it out. I haven't been able to find an answer in the Learning Center either.

Does anyone know how to accomplish what I'm trying to do? I imagine it would be simple if I wasn't missing something fundamental or obvious to how Thinkscript works.

Code:
plot Neutral = if (Score >= 4 and Score <= 6) then Score else !Neutral;
plot WeakBull = if (Score[0] > 7 and Score[0] < 11) then Score else !WeakBull;
plot StrongBull = if (Score[0] >= 11) then Score else !StrongBull;
plot WeakBear = if (Score[0] <= 3 and Score[0] >= -2) then Score else !WeakBear;
plot StrongBear = if (Score[0] < -2) then Score else !StrongBear;


Neutral.SetPaintingStrategy(PaintingStrategy.Values_above);
Neutral.SetDefaultColor(Color.Gray);
Neutral.SetLineWeight(5);

WeakBull.SetPaintingStrategy(PaintingStrategy.Values_above);
WeakBull.SetDefaultColor(Color.Plum);
WeakBull.SetLineWeight(5);

StrongBull.SetPaintingStrategy(PaintingStrategy.Values_above);
StrongBull.SetDefaultColor(Color.Magenta);
StrongBull.SetLineWeight(5);

WeakBear.SetPaintingStrategy(PaintingStrategy.Values_above);
WeakBear.SetDefaultColor(Color.Dark_Red);
WeakBear.SetLineWeight(5);

StrongBear.SetPaintingStrategy(PaintingStrategy.Values_above);
StrongBear.SetDefaultColor(Color.Light_Orange);
StrongBear.SetLineWeight(5);
 

Similar threads

Top