Mark candle with volume 125% or more above 5 bar average


Category:
0
0

Hi Pete, I hope everything is great with you! Thanks for all the great work you do, everyone absolutely appreciates it a lot!

My question is, how I could set up to display a symbol such as a circle with a color blue (at some position such as below) on a particular candle if a condition is met, such as if the candle’s volume is at least 25% higher than the average of the previous 5 candles? Would really appreciate your help – thank you!

Marked as spam
Posted by (Questions: 2, Answers: 1)
Asked on February 14, 2020 3:05 pm
139 views
0
Private answer

Thanks so much for your kind words and feedback. Very glad you took the time to post your question.

I updated the question title to more clearly explain the context of your question. The original title used was: "show circle on candle if condition met". Unfortunately this question title would fit about 80% of the posts in the Chart Studies topic. Virtually all of the solutions in the chart studies topic have to do with creating conditions in code and plotting a symbol above or below the candle. There are dozens examples in the forum, all available within a few clicks of the mouse.

So rather than point you in the direction of a few of those examples I will provide the specific solution to your request. I have taken the time to add some user inputs so the solution will be applicable to the largest possible audience. Below to code I have included some details to help you understand what the code is doing and how we get this to plot the "circle" under the candles when the condition is true.

input length = 5;
input averageType = AverageType.SIMPLE;
input percentThreshold = 25.0;
def volumeAverage = MovingAverage(averageType, volume, length);
plot signal = if volume > volumeAverage * (1 + percentThreshold * 0.01) then low else Double.NaN;
signal.SetPaintingStrategy(PaintingStrategy.POINTS);
signal.SetDefaultColor(Color.BLUE);
signal.SetLineWeight(4);

The code computes the 5 bar moving average of the volume. Then for each bar it checks if the current volume is 125% or more of the 5 bar average. The signal is generated so that if true the signal value is the low of the candle. If false then the signal value is Double.NaN. We do this so when the signal is false it produces no plot whatsoever. Then we apply a painting strategy called "POINTS". Which can be adjusted through the user settings to any of the other symbols included with Thinkorswim plot statements. Hope that helps you learn how to do this for other applications.

Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on February 14, 2020 7:41 pm