I can't understand Exercise 14 of Metastock Formula Primer

#1
Hi,

I am learning how to write formulas in Metastocks.
I was following some exercise until I was ask to do this.

Question: Suppose you wanted to vary the ROC() function based on the RSI. When the 14-period RSI is getting near its overbought and oversold regions, the rate f change might be far more important then when the RSI is in its mid-ranges. Taking such a premise as truth, you might wish to use a 1-period rate of change in the overbought and oversold ranges and a 3 period rate of change elsewhere. Write a forumla to do this and name it Variable ROC Average. Use the same 20-Period moving average and treat values above 70 and below 30 as overbought and oversold ranges.

My answer is this:
If((RSI(14)>70) OR (RSI(14)<30),Mov(ROC(C,1,$),20,S), Mov(ROC(C,3,$),20,S))

This is the correct answer:
Mov((If(RSI(14)>70 OR RSI(14)<30,ROC(C,1,$),ROC(C,3,$))),20,S)

I thought they are logically the same but the graph produced are quite different. What is wrong with my formula??? Did I missed something? Hope someone can enlighten me.
 

SwamiNathan

Well-Known Member
#2
wuming79,

Lets consider Your ans is A and "Your correct ans " is B.

In A, When the RSI is in extreme levels (i.e. above 70 or below 30), Moving average of ROC(C,1,$) is considered otherwise the otherone is taken. Threfore the nett indicator will contain many sharp up and falls.

B is nothig but the moving average of the whole result. That is When the RSI is in extreme levels ROC(C,1,$) (NOT the mov of ROC) is considered. When Moving ave is applied to the whole data, the data gets smoothened.

So you get a smoother indicator for B and volatile results for A.

The diff is for A u use mov ave to get the result. For B u use Mov Ave to smoothen the result.

B is logically correct.