ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Average volume line on the bottom chart
Posted by dave on Dec-08-2022 08:45
Attachments:
Hi,
I'm trying to draw the average volume line, but it's drawing it on the main chart, not the bottom (volume) chart.

I'm using the financesymbols.cs code as a starting point, and added the following code (found on the forums) for adding a volume line.

            // Add a volume indicator chart (75 pixels high) after the main chart, using
            // green/red/grey for up/down/flat days
            c.addVolIndicator(75, 0x99ff99, 0xff9999, 0x808080);

            ArrayMath am = new ArrayMath(volData);
            double maxVol = am.max();
            if (maxVol >= 1000000000)
                am.div(1000000000);
            else if (maxVol >= 1000000)
                am.div(1000000);
            else if (maxVol >= 1000)
                am.div(1000);


            //add 50 day volume average line
            double[] myMovingAvg = am.movAvg(50).result();
            Layer layer = c.addLineIndicator2(mainChart, myMovingAvg, 0xcc6600, "");
            layer.moveFront();
            layer.setUseYAxis2();

I understand what it's doing, I just don't know the API well enough to move it to the bottom.

Thanks!
example.png

  Re: Average volume line on the bottom chart
Posted by dave on Dec-08-2022 08:46
(hit send too fast)

How do I move the average vol line to the bottom?

Thanks!

  Re: Average volume line on the bottom chart
Posted by dave on Dec-08-2022 21:49
fyi..figured it out. I needed to add my indicator to the vol chart (didn't realize the addVol(..) method returned a chart)


            var volChart = c.addVolIndicator(75, 0x99ff99, 0xff9999, 0x808080);

            ArrayMath am = new ArrayMath(volData);
            double maxVol = am.max();
            if (maxVol >= 1000000000)
                am.div(1000000000);
            else if (maxVol >= 1000000)
                am.div(1000000);
            else if (maxVol >= 1000)
                am.div(1000);



            //add 50 day volume average line
            double[] myMovingAvg = am.movAvg(50).result();
            c.addLineIndicator2(volChart, myMovingAvg, 0xcc6600, "Vol(50)");