Is It Possible To ...

Questions about MultiCharts and user contributed studies.
User avatar
furytrader
Posts: 354
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 217 times

Is It Possible To ...

Postby furytrader » 23 Dec 2011

I am working on a project that involves plotting the average price versus the cumulative volume. In other words, the chart would show each day's average price on the Y-Axis, and the cumulative volume on the X-Axis. During the periods where there was very low trading activity, you would see several data points "bunched up" horizontally, whereas if there was a lot of activity (with high volumes), each successive day would be more spread out horizontally.

Here's my question: is it possible to create with EasyLanguage an indicator that doesn't use time as the x-axis unit? If so, how?

I know that MultiCharts has the ability to create volume (or "contract" bars), but that's not the same thing exactly. I am not looking to plot the open-high-low-close for a given amount of trading volume, but rather one data point (the average price) with the cumulative volume being used as the x-axis.

Any thoughts or insights would be appreciated!

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Is It Possible To ...

Postby TJ » 23 Dec 2011

I am working on a project that involves plotting the average price versus the cumulative volume. In other words, the chart would show each day's average price on the Y-Axis, and the cumulative volume on the X-Axis. During the periods where there was very low trading activity, you would see several data points "bunched up" horizontally, whereas if there was a lot of activity (with high volumes), each successive day would be more spread out horizontally.

Here's my question: is it possible to create with EasyLanguage an indicator that doesn't use time as the x-axis unit? If so, how?

I know that MultiCharts has the ability to create volume (or "contract" bars), but that's not the same thing exactly. I am not looking to plot the open-high-low-close for a given amount of trading volume, but rather one data point (the average price) with the cumulative volume being used as the x-axis.

Any thoughts or insights would be appreciated!
can you draw a diagram to illustrate? (with notes)

User avatar
furytrader
Posts: 354
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 217 times

Re: Is It Possible To ...

Postby furytrader » 23 Dec 2011

Sure, attached is a sample chart.

Although it looks like a normal "close only" chart, note that the X-axis is labeled as cumulative volume - as a result, at certain junctions on the X-Axis (such as around 0.4 and 0.9), there are "bunches" of orange data points, whereas at other parts of the X-Axis (between 0.3 and 0.4, for example), the orange points are more spread out horizontally.
Attachments
Sample MIDAS Chart.png
(58.23 KiB) Downloaded 715 times

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Is It Possible To ...

Postby JoshM » 23 Dec 2011

For real-time data something like this can probably be done.

Let's say you want to plot volume in 1000's (like the image). Then you could count the volume for each trade, keep a running total, and as soon as the volume reach 1000, you calculate the average price and plot that on the chart (with the x being volume of 1000, and y the average price). Then the volume counter get resets, and count it's way up to the next 1000. (However, you probably mean something else than this "simple" solution).
Although it looks like a normal "close only" chart, note that the X-axis is labeled as cumulative volume - as a result, at certain junctions on the X-Axis (such as around 0.4 and 0.9), there are "bunches" of orange data points, whereas at other parts of the X-Axis (between 0.3 and 0.4, for example), the orange points are more spread out horizontally.
I don't follow this. What does a "bunches" represent in this chart? As I understand you correctly, that chart uses cumulative volume and average price. If there occurs bunches of orange dots, would that mean that the average is of a changing length? (In other words, as the average would be calculated each time at 1000 volume (i.e. sum of those trades divided by 1000), you won't see any bunches but orange points laying 1000 cumulative volume apart).

Perhaps I'm missing something, :)

Regards,
Josh

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Is It Possible To ...

Postby TJ » 23 Dec 2011

Sure, attached is a sample chart.

Although it looks like a normal "close only" chart, note that the X-axis is labeled as cumulative volume - as a result, at certain junctions on the X-Axis (such as around 0.4 and 0.9), there are "bunches" of orange data points, whereas at other parts of the X-Axis (between 0.3 and 0.4, for example), the orange points are more spread out horizontally.
Cumulative volume is simply Volume plus previous bar's volume.

You can achieve that with a volume bar chart, with a cumulative indicator.

User avatar
furytrader
Posts: 354
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 217 times

Re: Is It Possible To ...

Postby furytrader » 23 Dec 2011

Thank you both for your ideas and feedback. Let me try to clarify this (and perhaps I am the one who is confused!)

Let's imagine that the constituent data is daily data. As with daily data, you have the OHLC and daily volume. From the OHLC data, you can generate the average price of the day (H+L)/2. You can also calculate the cumulative volume as of that day by adding the day's volume to the summed volumes of all the previous days.

So each point now has two dimensions: the average price on the day and the associated cumulative volume. Let's generate some sample data like this:

Day 1: Avg. Price = 20, Volume = 100, Cum. Vol = 1000 (this includes the sum of prior days' volume, not shown here)
Day 2: Avg. Price = 21, Volume = 200, Cum. Vol = 1200
Day 3: Avg. Price = 20, Volume = 100, Cum. Vol = 1300
Day 4: Avg. Price = 17, Volume = 1700, Cum. Vol = 3000
Day 5: Avg. Price = 12, Volume = 3700, Cum. Vol = 6700
Day 6: Avg. Price = 13, Volume = 300, Cum. Vol = 7000

Okay, so for each day you have an average price and you have the cumulative volume associated with that day.

Now, as you can see, if you plotted cumulative volume on the X-Axis, Days 1, 2 and 3 will be "bunched" together on the X-Axis because the associated cumulative volumes for those days are close together: 1000, 1200, 1300.

However, Day 4, which has a much higher cumulative volume, will be further to the right on the x-axis, because cumulative volume is that much higher. So too will day 5. Day 6 will be somewhat close to Day 5 on the X-Axis, because the cumulative volume reading is only 300 higher.

Does that make sense?

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Is It Possible To ...

Postby JoshM » 23 Dec 2011

Now, as you can see, if you plotted cumulative volume on the X-Axis, Days 1, 2 and 3 will be "bunched" together on the X-Axis because the associated cumulative volumes for those days are close together: 1000, 1200, 1300.

However, Day 4, which has a much higher cumulative volume, will be further to the right on the x-axis, because cumulative volume is that much higher. So too will day 5. Day 6 will be somewhat close to Day 5 on the X-Axis, because the cumulative volume reading is only 300 higher.

Does that make sense?
Yes, I think it understand it now FuryTrader. It couldn't resist the urge to try and code it, so something like this?
scr.188.png
Example with dots
(67.16 KiB) Downloaded 697 times
I don't have any time left today, and don't know how much time there is this weekend, but here's what I have so far. Even if it's completely something else than what you intend, perhaps it can give you an useful idea:

Code: Select all


Variables:
IntraBarPersist UpdateCounter(0),
IntraBarPersist VolumeCounter(0),
IntraBarPersist SumOfPrices(0),
IntraBarPersist PrevVolume(0),
averagePrice(0), IntraBarPersist condVolCounter(0);

Arrays:
myAvgPrices[](0);

once cleardebug;

// Since we cannot do a tick-by-tick analysis on historical data, we need real-time or PlayBack data
if (GetAppInfo(aiRealTimeCalc) = 1) then begin

// Reset variables
if (BarStatus(1) = 0) then begin
condVolCounter = 0;
SumOfPrices = 0;
end;

// Count volume
if (BarStatus(1) = 0) then
VolumeCounter = VolumeCounter[1] + (UpTicks+DownTicks)
else
VolumeCounter = VolumeCounter + ((UpTicks+DownTicks) - PrevVolume);

UpdateCounter = UpdateCounter + 1;
SumOfPrices = Close + SumOfPrices;


// Debugging
Print(TimeNow, "Volume : ", NumToStr(upticks + downticks, 0), " volume counter: ", VolumeCounter, " volumeCounter[1]: ", VolumeCounter[1],
" barStatus: ", BarStatus(1), " Close: ", Close, " prevVol: ", PrevVolume);
//: Debugging


// If volume is more than 999, we want to calculate the average price
if (VolumeCounter > 999) then begin

condVolCounter = condVolCounter + 1;

// Set the dynamic array to the length of the number of times this bar that the volume exceeded 999
Array_SetMaxIndex(myAvgPrices, condVolCounter);


// Debugging
Print(TimeNow, "Volume is ", VolumeCounter, " arrya length: ", array_getmaxindex(myavgprices), " condVolCounter: ", condVolCounter);
//: Debugging


// Calculate average
averagePrice = SumOfPrices / UpdateCounter;

// Store the average price in an array, so that it can be used in plotting
myAvgPrices[condVolCounter] = averagePrice;

// Plot the dots, depending on how many times the volume passed > 999 in *this* bar. If you
// plot a high volume instrument, or bars with long duration, this list needs to be expanded.
Switch(condVolCounter) begin
Case 2:
Plot1(myAvgPrices[1], "Dot1");
Plot2(myAvgPrices[2], "Dot2");
Case 3:
Plot1(myAvgPrices[1], "Dot1");
Plot2(myAvgPrices[2], "Dot2");
Plot3(myAvgPrices[3], "Dot3");
Case 4:
Plot1(myAvgPrices[1], "Dot1");
Plot2(myAvgPrices[2], "Dot2");
Plot3(myAvgPrices[3], "Dot3");
Plot4(myAvgPrices[4], "Dot4");
Default:
Plot1(myAvgPrices[1], "Dot1");
end;

// Reset volume
VolumeCounter = VolumeCounter - 1000; // Keep the remaining volume above 1000

end; //: Volume > 999

PrevVolume = UpTicks + DownTicks;

end; //: Realtime data check
Edit: you could also do this with Text_New_s, but then a) you'll need an array with looping and b) text drawing is slow and memory intensive (at least here :)), so that's why I've chosen for a Plot solution.

Regards,
Josh

User avatar
furytrader
Posts: 354
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 217 times

Re: Is It Possible To ...

Postby furytrader » 23 Dec 2011

Wow! Thank you for doing this - I look forward to trying this out, although I ma be delayed because of the holidays. This looks great though!

User avatar
furytrader
Posts: 354
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 217 times

Re: Is It Possible To ...

Postby furytrader » 30 Dec 2011

Thanks again - this has given me a lot to think about. I think the approach that you're describing is the correct one. This really helps.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Is It Possible To ...

Postby JoshM » 31 Dec 2011

Glad I could be of (some) help FuryTrader. :) Have a great 2012!


Return to “MultiCharts”