Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 3/5/2009(UTC) Posts: 5
|
Hi all,
I am new to coding. Hope someone can help me.
Example below:
if close > open then execute this statement. if close < open then execute this statement. if close = open then execute this statement.
Any help is appreciated.
fankc
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 602
|
try something like below:
a1:=If((C>O),then_do_this,else_do_that); a2:=If((C<O),then_do_this,else_do_that); a3:=If((C=O),then_do_this,else_do_that); a1+a2+a3
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 3/5/2009(UTC) Posts: 5
|
Hi johnl,
Thank you for your reply.
Actually I was thinking of trying to plot support and resistance line on price chart base on condition of the open and close.
So if close>open, then will use a formula to calculate, and if close<open, then use another formula to calculate, and if close = open, then use another formula to calculate.
The metastock if function consists of if the condition is True, it will print this result else another result.
Problem is I don't know what to put in the third parameter(i.e else) of the if function.
Hope you can help me.
Thank you.
fankc
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Unverified Users Joined: 7/12/2007(UTC) Posts: 134 Location: Perth Western Australia
|
Hi fankc,
Try nesting the "If " function but remember to place an additional right parenthesis for each nested "If " function.
If(C=O,1st formula,If(C>O,2nd formula,3rd formula))
The interpretation being: If C=O, then execute 1st formula, if C>O ,then execute 2nd formula, otherwise execute 3rd formula (which implies that C<O).
Cheers, oz
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 3/5/2009(UTC) Posts: 5
|
Hi oztrader,
I manage to get the code done with your help.
Thank you for your time and help.
fankc
|
|
|
|
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.