Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 2/28/2006 Posts: 29
|
I am trying to accomplish a RealCode for what I call MACD Histogram "spikes" and "flats".
My definition of a MACD Spike is when calculating the difference between the current bar being greater than the previous bar calculation by greater than 100%.
MACD Spike example: bar 1: 0.50 minus (-) bar 2: 1.00 = 0.50 (previous bar)
bar 2: 1.00 minus (-) bar 3: 2.00 = 1.00 (current bar)
The above calculation illustrates a difference of bar 3 being greater by 200% of bar 2.
My definition of a MACD Flat is when calculating the difference between the current bar being less than the previous bar calculation by less than or equal to 50%.
MACD Flat example: bar 1: 0.50 minus (-) bar 2: 1.00 = 0.50 (previous bar)
bar 2: 1.00 minus (-) bar 3: 1.25 = 0.25 (current bar)
The above calculation illustrates a difference of bar 3 being less than bar 2 by 50%.
My intent is to incorporate both creating a RealCode for it. Please advice...
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I may be misunderstanding, but if you Drag and Drop the MACD Histogram into the Code tab of the RealCode Editor, it should create something similar to the first line of the following RealCode Rule for MACD Spikes:
'# MH = indicator.MACDHistogram
If System.Math.Abs(MH.Value - MH.Value(1)) > _
2 * System.Math.Abs(MH.Value(1) - MH.Value(2)) Then Pass
if you Drag and Drop the MACD Histogram into the Code tab of the RealCode Editor, it should create something similar to the first line of the following RealCode Rule for MACD Flats:
'# MH = indicator.MACDHistogram
If System.Math.Abs(MH.Value - MH.Value(1)) < _
System.Math.Abs(MH.Value(1) - MH.Value(2)) / 2 Then Pass
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/28/2006 Posts: 29
|
I failed to mention that when these rules become realized DO NOT PASS. In other words these rules should check for invalidation (fail-safe). How do I go about changing this rule to not pass?
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
There are two way easy ways to reverse the Rules (OK, there are probably lots of ways, but I'm going to present two). The first would be to use Not:
'# MH = indicator.MACDHistogram
If Not System.Math.Abs(MH.Value - MH.Value(1)) > _
2 * System.Math.Abs(MH.Value(1) - MH.Value(2)) Then Pass
The second would be to reverse the comparison:
'# MH = indicator.MACDHistogram
If System.Math.Abs(MH.Value - MH.Value(1)) <= _
2 * System.Math.Abs(MH.Value(1) - MH.Value(2)) Then Pass
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |