Rank: Member
Groups: Registered, Registered Users, Subscribers Joined: 6/26/2007(UTC) Posts: 12
|
Hi guys, I have a handsome problem using technical analysis for our stock market which just switched from periodic order matching (3 times a day) to continuous order matching. Very often some stocks have equal O,H,L and C values. Now that I want to create some customized indicators using these values in the formula. Examples: var1:=(C-O)/(H-L); var2:= [(C-L)-(H-C)]/(H-L);. if H=L (which means C=O=H=L), can I define var1 and var2 to be 1 if the stock closes higher today than yesterday, and -1 if the stock closes lower today than yesterday?
Many thanks for any help.
|
|
|
|
Rank: Member
Groups: Registered, Registered Users, Subscribers Joined: 6/26/2007(UTC) Posts: 12
|
Continuing from the above post, assuming what I intend to do is rational, here is the formula I use:
net:=If(H=L,If(C>Ref(C,-1),1,If(C<Ref(C,-1),-1,0)),(C-O)/(H-L)); Cum(net*V)
However, Metastock keeps informing of the error "division by zero". Really don't know why it doesn't work. I would much appreciate your helping me to correct the formula.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
Try this code with simple Division by Zero error-traping:
-------------------------------------
range:=Max(H-L,.000001); net:= If(H=L, If(C>Ref(C,-1),1, If(C<Ref(C,-1),-1,0)),(C-O)/range);
Cum(net*V)
-------------------------------------
jose '-)
|
|
|
|
Rank: Member
Groups: Registered, Registered Users, Subscribers Joined: 6/26/2007(UTC) Posts: 12
|
Hi there,
Tried to search this on the web but I did not find any. Is it possible to return a non-number value in Explorer colums? Example, I use a formula to tell if macd() is up and positive. I can naturally use two columns, one for "up" and one for "positive". But in case I already use up the columns and there's only one left, can this column be made to retunr "up.pos" characters?
Another problem still, if I want to return the date from x bars ago, how could I do? Is date a variable like C, H, L etc.? Does Explorer return a date?
Thanks
|
|
|
|
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)
|
mastermedea wrote:...can this column be made to retunr "up.pos" characters? The short answer is, no. MetaStock (generally) only deals with numerical information, not text. You might try assigning values to each of the conditions then adding them together; up=1, positive=2 so if the value is up AND positive the return will be 3. If you are going to assign multiple values then you might want to consider summing powers of 2 (simulating binary bit-wise operations) mastermedea wrote:Does Explorer return a date? Again, the short answer is no. You can build a date by perfoming some mathematical operations on Year(), Month() and DayOfMonth(), but all the explorations will only return these values for the last bar of the loaded chart, unless you combine these with the ValueWhen() function too. Watch out for precision errors that will start to occur if you try to create the date as a long integer value, I recommend making a format more like YYYY.MMDD. On both of these issues, there are many posts already in the Forum. Hope this helps. wabbit [:D]
|
|
|
|
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.