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)
|
I am by no means an 'expert' formula writer so I can't vouch for the validity of your formula in general, I can tell you a couple issues you might encounter.
HHV and LLV both include the 'current bar' in their # of periods. So C > HHV(C,14) would never be true, because the Close could not be greater than itself. To deal with this, you can either use the REF function around the HHV / LLV functions, or you can use Greater Than or Equal To / Less Than or Equal To operators instead: >= or <=
A slightly modified formula using the REF function listed below:
If(RSI(9) < Ref(HHV(RSI(9),14),-1) AND CLOSE > Ref(HHV(CLOSE,14),-1),1,0) OR If(CLOSE > Ref(LLV(CLOSE,14),-1) AND RSI(9) < Ref(LLV(RSI(9),14),-1),1,0)
As a general rule, whenever you encounter problems with formulas, it is best to break the formula up into it's individual parts, and plot them as an indicator. By doing so, if you were to create an indicator with: C > HHV(C,14) as the formula, you would see that it remains at 0 all the time, meaning your formula could never be true while it contains the above criteria.
|