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

Notification

Icon
Error

Options
Go to last post Go to first unread
sdgms  
#1 Posted : Friday, December 27, 2013 11:59:26 PM(UTC)
sdgms

Rank: Newbie

Groups: Registered, Registered Users, Unverified Users
Joined: 12/22/2013(UTC)
Posts: 8

Hi,
I am trying to combine all the OptionGreeks and plot all together in a single indicator for a particular strike price. Here is my formula:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
temp:=Input("CALL:1, PUT:2, FUTURECALL:3, FUTUREPUT:4",1,4,1);
strikeprice:=Input("Strike Price",0000000,111111,0);
expirydate:=Input("Expiry Date in YYMMDD format",000001,991231,991231);
interestrate:=Input("Interest Rate",0,24,12);
dividendrate:=Input("Dividend Rate",0,100,25);

IF(temp=1, type:=EC,
IF(temp=2, type:=EP,
IF(temp=3, type:=FC,
IF(temp=4, type:=FP, type:=EC))));

OptionDelta:=DELTA(type,expirydate,strikeprice,interestrate,dividendrate);
OptionGamma:=GAMMA(type,expirydate,strikeprice,interestrate,dividendrate);
OptionVega:=VEGA(type,expirydate,strikeprice,interestrate,dividendrate);
OptionTheta:=THETA(type,expirydate,strikeprice,interestrate,dividendrate);
OptionPrice:=Option(type,expirydate,strikeprice,interestrate,dividendrate);
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

The above formula does not work because Metastock Formula Language does not allow data assignment in the IF condition.
Alternatively, any thoughts on how to pass on EC, EP, FC, FP to the option greek functions in the above formula?

Regards,
sdg
MS Support  
#2 Posted : Monday, December 30, 2013 1:27:00 PM(UTC)
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,960

Thanks: 92 times
Was thanked: 155 time(s) in 150 post(s)
You cannot define a variable inside an IF statement, but you can use an IF statement inside of a variable. Variables must also be a numeric value (i.e. 0, 1, or a formula that produces a number).

You would likely have to write each possible formula combination in their long form, along these lines:

EC:=If(Temp=1,Delta(EC,Expirydate,Strikeprice,Interestrate,Dividendrate),0)

I didn't go through all the possible nestings you'd have to do to pull this off completely but hopefully this gives you an alternate way of viewing the problem.
sdgms  
#3 Posted : Friday, January 3, 2014 9:35:57 PM(UTC)
sdgms

Rank: Newbie

Groups: Registered, Registered Users, Unverified Users
Joined: 12/22/2013(UTC)
Posts: 8

MS Support, Thank you for the response. I would continue with that IF statement.
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.