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

Notification

Icon
Error

Options
Go to last post Go to first unread
theghost  
#1 Posted : Tuesday, September 30, 2008 10:08:43 AM(UTC)
theghost

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/4/2005(UTC)
Posts: 63
Location: Poole Dorset England

Hello Everyone,
I hope someone can help me.
While volume today is largely an overrated indicator IMO, at specific times it is a very power sign of a shift or change in ownership of a stock. but a change in the ownership of a stock leads to a change in the direction of the stock. Colour-coded volume just makes it visually easier to identify the volume associated with up, down and neutral bars.

I am looking to plot volume in 3 colours within 1 window.
If the volume is up it would be Green
If the volume is down it would be Red
If the volume has closed the same as it opened (IE candlestick Harami cross) it would be blue.

I'm quite new to coding, but I have come across up and down volume which had to be plotted seperately as follows;
Up;
If(C>=Ref(C,-1),V,0)
(
Plotted as Histogram
Down;
If(C<Ref(C,-1),V,0)
Plotted as Histogram in same window

But,, I'm having trouble plotting Neutral:-(
If someone can help me with this I would be most grateful.
Also, if there is a way to plot all 3 colours in an inner window at the same time?
Just an extra thought.

Many thanks to you all.


theghost  
#2 Posted : Sunday, October 5, 2008 1:05:02 AM(UTC)
theghost

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/4/2005(UTC)
Posts: 63
Location: Poole Dorset England

Hello Everyone.
With regards top my post for a "Triple Colour Coded Volume indicator."

I'm very sorry but I seem to have been very bland in my post, not being specific in exactly what I would like to be able to achieve and also where my knowledge of formulas is practically above zero I have been a little confused myself.
If I'm confused, then how is anyone able to help if I don't know exactly what I'm looking to do ! :-)

So here goes,
I think I can clarify the situation.

Firstly, I've dug deep into the forum and some other websites.
I found here ;

http://forum.equis.com/forums/thread/23864.aspx
Different colours for volume bars

An excellent post/threads regarding volume.
I really like Henry1224 formula

Up:=If(C>Ref(C,-1),V,0);
dn:=If(C<Ref(C,-1),v,0);
Neutral:=If(C=Ref(C,-1),v,0);
up;Dn;Neutral;

As this plotted all 3 colours within an inner window in 1 go

I also liked Wabbit's suggestion here;
http://forum.equis.com/viewtopic.php?t=3913
to synchronise coloured volume to price volume colour.

Regarding above threads, these are all great but I notice they are always looking to colour the volume (I think) relating to the previous days close

What I am looking to construct is a triple coloured volume indicator that mirrors the price regarding the same day open and close relationship.

I'll explain further.

Here is what I would like to achieve;

1. If today's close is higher than today's open then volume colour would be green.
2. If today's close is lower than its open the volume colour would be red.
3. If today's close is the same as it's opening price the volume colour would be blue.

So the volume colour only relates to it's open and closing price , not to the previous days close.

I'm just not sure how to write this.
Looking at henry's formula;

Up:=If(C>Ref(C,-1),V,0);
dn:=If(C<Ref(C,-1),v,0);
Neutral:=If(C=Ref(C,-1),v,0);
up;Dn;Neutral;



I thought it might be something like this;

Up:=If(C>open,V,green);
dn:=If(C<open,v,red);
Neutral:=If(C=open),v,blue);
up;Dn;Neutral;

As you can see,,, Not a clue.
I'm determined to try a bit harder and crack this,,, (4am,, now 7.50am:-(
After looking in metastock help (Index,, Reference Function helped me a lot),, trial and error and trying to think a bit logically, I've come up with this,,
Seems to work, I think,,
I had to change things around abit,, Plotted as histogram

Up:=If(OPEN<Ref(CLOSE,-0),V,0);
dn:=If(OPEN>Ref(CLOSE,-0),V,0);
Neutral:=If(OPEN=Ref(CLOSE,-0),V,0);
up;Dn;Neutral;


So now it will pick up neutral volume (Harami),,, and colour is coded to price Open / Close relationships.

Please, if there are any good coders reading this,, if you could just confirm if I have written this correctly.
Tried my best. I think it's ok, but not sure.

I hope this might be of some use to people out there if it is ok.
I couldn't have written it without analysing some of the other posts on this forum.
Thank you all.[:)]
wabbit  
#3 Posted : Sunday, October 5, 2008 5:26:22 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)
You're very close to the solution...

Code:

up:=If(CLOSE>OPEN,V,0);
dn:=If(CLOSE<OPEN,V,0);
neutral:=If(CLOSE=OPEN,V,0);
{plot}
up; {green}
dn; {red}
neutral; {blue}


or alternatively without the If()

Code:

up:=V*(CLOSE>OPEN);

dn:=V*(CLOSE<OPEN);

neutral:=V*(CLOSE=OPEN);

{plot}

up; {green}

dn; {red}

neutral; {blue}




Select each element in the return plot and colour as required; save as a template to avoid having to reformat each time.


Hope this helps.

wabbit [:D]

theghost  
#4 Posted : Wednesday, October 8, 2008 4:48:08 PM(UTC)
theghost

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/4/2005(UTC)
Posts: 63
Location: Poole Dorset England

Many many thanks for your reply Wabbit.
sorry for my late reply,, (I hate 12 hour night shifts:-)).

I've tried both your suggestions, and both do the trick, many thanks.

As to how/ why they are written differently, and if 1 is written better (wrong word:better, but not sure how else to describe it) than the other.

I have recently purchased Metastock Pro, and next mth should have a live data feed through quote center.


I'm trying to understand how you have written them.
I'm new to language /formulas etc.
(I did visit your website and see that you have a degree in Mathematics/bachelor of Science etc,,, so this coding must be second nature to you now) :-)
I know how to use a caculator :-)
I'm look at the manual page 418,, to try and understand the formulas you wrote.
* = Multiple
V= Volume
If (Page 422)= Kind of if then xyz =abc, then true (I think)

So 1st formula
up:=If(CLOSE>OPEN,V,0);
Means;
I think;
If the close is greater than the open today, volume is up
dn:=If(CLOSE<OPEN,V,0);
If the close is less than the open today, volume is down
neutral:=If(CLOSE=OPEN,V,0);
If close is same as the open, todays volume will be neutral
PROBLEM: I don't understand the next bit Wabbit, why you mention
{plot}
up; {green}
dn; {red}
neutral; {blue}

Have you added that just so as to tell me Wabbit that they should be coloured that way? As If I create a new indicator the information, or as 3 seperate indicators for up, down, neutral in indicator builder, then just import into a new inner window; it always imports/shows as a red line,, and I colour them myself,, (and do as you suggested,, save as tempate when finished.)

Didn't know what the {} meant,,
Wiki'd it as trouble in Index finding out,
http://en.wikipedia.org/wiki/Table_of_mathematical_symbols
Seems to just be brackets! :-) Example:{a,b,c} means the set consisting of a, b, and c.
If I plot
second Formula
up:=V*(CLOSE>OPEN);
Means; close if greater than open, multiply by volume, and will be up
dn:=V*(CLOSE<OPEN);
Means;
Means; close if less than open, multiply by volume, and will be down
neutral:=V*(CLOSE=OPEN);
Means; close equals the open, multiply by volume, and will be neutral.
=================================================
To sum up,, have plotted the indicator fine, saved as template fine.
1. Just not sure what this means/ is included for;
{plot}
up; {green}
dn; {red}
neutral; {blue}

2. These are written for EOD data,, but would they work on intra day data, as I think they would need to be written slightly differently, I think?

Example
Formula now for up bar
up:=If(CLOSE>OPEN,V,0);

But because intra day bars, say a 1 minute bar couldn't just use the word CLOSE, would have to be something like PRICE NOW is Greater than its OPEN?
Would it be somthing like;
"If todays price (Example 1 minute bar) is above its opening price then its volume will be up colour ,,green,, if todays price bar (Example 1 minute) has fallen and is now below or crossed below its open then todays volume bar will be red,, and if it closes same as open it will be blue.

Just a thought.

Again, many many thanks for your reply Wabbit.
Regards
TheGhost



wabbit  
#5 Posted : Wednesday, October 8, 2008 10:39:55 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)
Code:

up:=If(CLOSE>OPEN,V,0);

says, "if the value of CLOSE is greater than the value of OPEN then assign the value of VOLUME to the variable 'up', if the CLOSE is not greater than OPEN then assign zero to the variable 'up'."

MS can evaluate equality-type expressions to return values as TRUE or FALSE, represented as integers 1 and 0 respectively (i.e. Boolean comparison). We can use this to perform some operations such as we have seen:
Code:

up:=V*(CLOSE>OPEN);

In this instance the terms in brackets are evaluated: if the term in the brackets is TRUE (1) then V * 1 = V is assigned to the variable 'up' If the term in brackets is FALSE (0) then V * 0 = 0 is assigned to the variable. It works the same as an If() statement:
Code:

variable:=If(statement, 1, 0);

but I think its easier to maintain in the code to use the Boolean comparison and also is slightly faster than the If() statement. (The speed difference in a single indicator is not significant, but in optimising system tests and large explorations, the speed difference is measurable).

The use of the curly braces {} simply indicates comments, used to make the reading and/or understanding of codes easier for the reader, MS ignores anything in these braces, with the exception that comments are still counted in the character limit for each function.

You can return a number of values from a single function. In this case we return three values from the one function, up, dn, and neutral. When you plot this indicator in an inner window, it will draw three lines. You can format all three lines as a single indicator by fashioning the indicator properties, or you can fashion each element in the indicator by selecting the element (with the mouse) and setting the individual element colour, linestyle, width etc.


Hope this helps.

wabbit[:D]



uasish  
#6 Posted : Wednesday, October 8, 2008 11:46:20 PM(UTC)
uasish

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 8/13/2005(UTC)
Posts: 170

Thanks: 7 times

Wabbit,

This Boolean comparison done by MS in the bracket without If function is another thing i have learnt from you ,Thks once again .

Asish

theghost  
#7 Posted : Thursday, October 9, 2008 12:56:14 AM(UTC)
theghost

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/4/2005(UTC)
Posts: 63
Location: Poole Dorset England

Many Thanks For your in depth reply Wabbit, much appreciated.

My Default Template is coming on nicely now!
I will close this thread, but just have a couple of questions if I may.
First
===
When you write code on this forum, how do you make it show in a new inner box in your post Wabbit, so it stands out from the text?
I thought it might be;
Code:


??
Just so I know if I have to post some.
I did try and look, went to the download area and downloaded a pdf called Metastock Tips,, but couldn't see any reference in how to do this.

Second;
=====
Can we/ or are able to post images?
I see you have an image section with a few photos on by administrators etc.
I would like to post a template if I may, with accompanying info; it might if it help some MS users


Third (and Last) :-)
==========
The formula for Triple Coloured Volume is now;
Name
Triple Coloured Volume
Formula
up:=V*(CLOSE>OPEN);
dn:=V*(CLOSE<OPEN);
neutral:=V*(CLOSE=OPEN);
{plot}
up; {green}
dn; {red}
neutral; {blue}
==============

I am trying to also plot a Moving average within the inner window of this Triple Coloured Volume Indicator.
When I try to just drop in the MA from the Indicator quick List it displays wrong,, it either displays as a flat line on the zero line or displays wildly,, as if it's following the actual price bar chart.

I'm looking to plot a 5 period Simple Moving Average of the Volume,, on the volume, so I can see at a glance if the days volume is above average.
I've tried insertinglines of code for MA into the formula, but to be honest, I'm just guessing,, it's trial and error,, need to learn more,, getting late now though,, tried these;
up:=V*(CLOSE>OPEN);
dn:=V*(CLOSE<OPEN);
neutral:=V*(CLOSE=OPEN);
Mov(C,5,E);
{plot}
up; {green}
dn; {red}
neutral; {blue}

Didn't work:-(
==============
Tried;
====
up:=V*(CLOSE>OPEN);
dn:=V*(CLOSE<OPEN);
neutral:=V*(CLOSE=OPEN);
Mov(C,5,E)*V;
{plot}
up; {green}
dn; {red}
neutral; {blue}

Didn't work
===============
Tried
===
up:=V*(CLOSE>OPEN);
dn:=V*(CLOSE<OPEN);
neutral:=V*(CLOSE=OPEN);
Mov(C,5,E)*up;dn;neutral;
{plot}
up; {green}
dn; {red}
neutral; {blue}

Didn't Work
==============
Tried
====

up:=V*(CLOSE>OPEN);
dn:=V*(CLOSE<OPEN);
neutral:=V*(CLOSE=OPEN);
Mov(C,5,E)*(up AND dn AND neutral);
{plot}
up; {green}
dn; {red}
neutral; {blue}

Didn't work.
Hey Ho,
Time for bed.
Again,, many thanks for your in depth reply Wabbit.

I'll try tomorrow again,, see if I can plot a 5 period MA of the Volume in the inner window.
:-)
Thank you all.
PS.
I hope you don't roll around laughing too much with my coding! [:)]



wabbit  
#8 Posted : Thursday, October 9, 2008 4:42:17 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)
theghost wrote:
When you write code on this forum, how do you make it show in a new inner box in your post Wabbit, so it stands out from the text?
I thought it might be;
Code:



Use: * code * (without the spaces) to define the start of the code segment.
Use: * /code * (without the spaces) to define the end of the code segment.

theghost wrote:
Can we/ or are able to post images?
I see you have an image section with a few photos on by administrators etc.
I would like to post a template if I may, with accompanying info; it might if it help some MS users

See http://forum.equis.com/forums/thread/19928.aspx(CLOSE=OPEN);
{plot}
Mov(VOLUME,5,E);
up; {green}
dn; {red}
neutral; {blue}
[/code]


Hope this helps.

wabbit [:D]

P.S. I think you'd benefit from attempting the exercises in the free Quis Formula Primer; see the downloads section.
theghost  
#9 Posted : Thursday, October 9, 2008 11:13:36 AM(UTC)
theghost

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/4/2005(UTC)
Posts: 63
Location: Poole Dorset England

Brilliant!
Many thanks for all your help on this Wabbit.
Case closed.

A Triple Coloured Volume with Moving Average!
Excellent.
Many many thanks

TheGhost
(Formula Primer being downloaded now [:)]), many thanks for the suggestion, will definately help me 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.