Paint candles where volume is greater than 60 period average


Category:
0
0

Hi Pete how are you? is it possible to color yellow all the candles that have 3000000 or more in volume excluding the last candle? thanks in advance for your time.

Marked as spam
Posted by (Questions: 8, Answers: 23)
Asked on April 14, 2020 12:00 pm
126 views
0
Private answer

Every post in this forum should provide solutions that are applicable to the broadest portion of our audience. Fixed values such a 3 million volume is applicable to a very narrow list of stocks and time frames. It may work for your small list of stocks and specific time frame. But tomorrow that value may be meaningless within that same list of stocks and time frame. Much more useful to have something that will automatically be appropriate regardless of the stock or time frame selected. So let's try to construct this in a way that would apply to all stocks.

Here are some examples of how you would rephrase your specifications to have a much broader application:

  1. Volume greater than average volume over "x" periods
  2. Item one but instead we say volume "x" percent or greater than average over "y" periods
  3. Volume greater than previous "x" bars
  4. Item 3 but instead we say volume "x" percent or greater than previous "y" bars
  5. Instead of volume use one of the built-in studies that converts volume into an oscillator that can then be used to determine when extreme volume has appeared.

Ok, there is a nearly endless list of other ways you can do this. But please don't ever try to nail things down to a hard coded value. Much better to apply some statistical tools and formulas to make something that automatically adjusts to the widest range of stocks and time frames.

Edit: Based on feedback from the author of the post I have a solution. The request is for a chart study that paints candles yellow where the volume is greater than 60 period average volume.

input length = 60;
def averageVolume = Average(volume, length);
def lastBar = !IsNaN(close) and IsNaN(close[-1]);
AssignPriceColor(if !lastBar and volume > averageVolume then Color.YELLOW else Color.CURRENT);

Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on April 14, 2020 2:36 pm
0
Thank for the advice Pete, ok lets try Volume greater than average over the last 60 bars not including todays bar. Thanks! This is for a daily chart.
( at April 14, 2020 4:38 pm)
0
I have updated my response to include the code for this request. I have also updated the question title to reflect the context of the request.
( at April 14, 2020 5:21 pm)
0
Thanks works great as always!
( at April 14, 2020 6:25 pm)