logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Knowland  
#1 Posted : Saturday, March 15, 2008 1:36:17 AM(UTC)
Knowland

Rank: Newbie

Groups: Registered, Registered Users
Joined: 3/15/2008(UTC)
Posts: 8

I need help with a simple indicator that will calculate intraday, the average volume for any particular time frame. The average volume from yesterday or previous days should not be included in the calculations. Each day is individually calculated. In other words, the volume used will be just for the time frame of that day. Therefore a volume moving average will not work. For instance, I need the indicator displayed on the 5 minutes volume chart. The indicator will calculate at the beginning of the day the average volume as each 5 minutes bar appears. This indicator will be a horizontal line projected across the chart with the volume bars either above or below the indicator line. The horizontal indicator (average volume) will keep adjusting up or down depending on the new 5 minutes volume bar.

Any help will be greatly appreciated, hope I was clear in my explanation.

Knowland
johnl  
#2 Posted : Sunday, March 16, 2008 10:15:37 PM(UTC)
johnl

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/7/2005(UTC)
Posts: 602

You may be able to do it if MS updates the entire screen on an update (every 5 minutes
in you case) or does it update just the new data point? Then you may want to play with the Lastvalue() function. If the Zig function corrects itself may give you a clue if it is possible.
Sorry for not being more clear.
wabbit  
#3 Posted : Monday, March 17, 2008 2:56:08 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Hi Knowland

Welcome to the Forum.

Please understand the purpose of the Forum is not to write your codes for you. The forum is designed to assist you to fix mistakes when you write your code or get stuck overcoming a limitation of the coding language or end up results that are far from what you expected.

When requesting coding assistance, to get a prompt reply you should post your best attempt at achieving the goal, along with a full explanation of what you think the code should be doing and a full explanation of why the code you posted is not achieving this goal. When it can be seen that you have put in some effort yourself, then Fourm members will cheerfully give you their time to help you. "Give a man a fish.... teach a man to fish..."

But how does one learn to write code in the first place? Read the MS Users Manual that came shipped with your copy of MS. After you have read this (cover to cover) a few times, download the free Equis Formula Primer from the downloads section, read this and work through the basic exercises designed to give more than enough knowledge to code the candlestick formations you are seeking, and much much more.

Try this as a basis for your solution:
Start by identifying the start of each trading day.
The use the Cum() and ValueWhen() commands to add up the volume for since you detected a new day. (Use caution when accumulating volume as MS does not deal with large numbers nicely!)
Divide by this volume by the number of bars since the new day was detected.

Have a crack, and post your best attempt to get this (as you called it) "simple indicator" working.


Hope this helps.

wabbit [:D]
Knowland  
#4 Posted : Monday, March 17, 2008 10:41:56 AM(UTC)
Knowland

Rank: Newbie

Groups: Registered, Registered Users
Joined: 3/15/2008(UTC)
Posts: 8

Hi Wabbit, thanks for the prompt response. Apologize for not presenting my calculations ahead of time. I mentioned that it is "simple" because I got it to partially work, except that it is not resetting the Cum(v) and the Cum(1) values from the previous day no matter what variations I've tried.

I have MS pro and all intraday data is in real time. I am trying to calculate the average volume for each bar for that particular day. A horizontal line (average volume) displays along with the volume chart. But the problem I am having is that the Cum(v) and the Cum(1) value are not resetting to 0 (zero) at the beginning of the new day, but takes the volume of all the previous days from the beginning of the chart. Therefore, I am not getting the average volume for only a particular day, but for all the days on the chart.

I have: If(dayofweek()=Ref(dayofweek(),-1), (Cum(V)/Cum(1)), Cum(V)=0 and Cum(1)=0


Your comments are well taken.
wabbit  
#5 Posted : Monday, March 17, 2008 4:13:47 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Knowland,

To do it one line would be nice, but you need to expand things out more.

Also you cannot "set" the values of Cum(1) and Cum(v), so you have to do something else, liek subtract value using ValueWhen().

This is what I came up with...

Code:

dom:=DayOfMonth();
cv:=Cum(V);

newDay:=dom<>Ref(dom,-1) OR Cum(1)=2;
sameDay:=dom=ValueWhen(1,Cum(1)=1,dom);

num:=cv+(sameDay*ValueWhen(1,Cum(1)=1,V))-ValueWhen(1,newDay,Ref(cv,-1));
avgVol:=num/(BarsSince(newDay)+sameDay+1);

{plot}
avgVol;


Work your way through the code to ensuring you understand what it is trying to do, ask questions if need be.

It hasn't been extensively tested... but I hope it helps.


wabbit [:D]

Knowland  
#6 Posted : Wednesday, March 19, 2008 12:06:30 PM(UTC)
Knowland

Rank: Newbie

Groups: Registered, Registered Users
Joined: 3/15/2008(UTC)
Posts: 8

Wabbit, thanks for the code. It is consistent with what I was aiming at and the main thing is that it works. Your code for this volume indicator has performed flawlessly and it has added depth to my trading. As we all know, volume precedes price!

For those interested in experimenting with it. This is what I did:
* Display the volume chart with Up Volume in green and Down Volume in Red (any color will do).
* Display Down Volume facing down and leave Up Volume facing up.
* Display the average volume indicator to the Up Volume and to the Down Volume
* Display OBV indicator (On Balance Volume) for better visual.
* Consecutive same color bars are consisten with the Fibonacci numbers. Most of the time between 3-5.

Happy trading to all of you.....thanks again, Wabbit
Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.