Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Difference in Moving Averages Values Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
evanm
Posted : Saturday, May 15, 2010 12:17:55 PM
Registered User
Joined: 9/18/2008
Posts: 65
I am trying to calculate the Top of a Bollinger Band Value - Less the Top of the Keltner Band Value (as well as the difference between the bottom values).
What i did was assign moving averages witha period of one to each of the top and bottoms of the bollinger bands and Keltner channels.
Now this is where I am stuck How can i write a script that will allow me to come up with a value between the two and have it then pass or not pass my test....
What i want to do is the following... If:
'*** MA=TopBollinger Moving Avg
'*** MA1=BottomBollinger Moving Avg
'*** MA2=TopKeltner Moving Avg
'*** MA3=BottomKeltner Moving Avg
I want
MA.value - MA2.value = TopDifference and then take
Ma3.value - Ma1.value = BottomDifference and then
Take the Difference between both Top & Bottom = TotalDifference If Total Difference < 0.75 Then Pass
Please Help
Thanks
EvanM
jas0501
Posted : Saturday, May 15, 2010 1:40:15 PM
Registered User
Joined: 12/31/2005
Posts: 2,499

In V5 you can reference the top and bottom channels:

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0
www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:bb Kelt diff
'|******************************************************************

'# BBTop = chart.BollingerBands.0
'# BBBottom = chart.BollingerBands.1
'# KCTop = chart.KeltnerChannels.0
'# KCBottom = chart.KeltnerChannels.1

Dim diff As Single

diff = (BBtop.value - BBBottom.value) - _
 (KCTOP.VALUE - KCBottom.value)
plot = diff

I plotted it to see the plot adn added a horizontal pointer at 0.75, then just add a condition based on the plot. The code could just be a condition. Make the code a condition instead of an indicator and  instred of plot = diff use:

If diff > 0.75 then
   pass
endif


evanm
Posted : Saturday, May 15, 2010 2:03:55 PM
Registered User
Joined: 9/18/2008
Posts: 65
THanks
But i am in version 4
How can i do that in version 4.
EvanM
Bruce_L
Posted : Monday, May 17, 2010 11:02:09 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
evanm,
StockFinder 4 is pretty much the same thing except that you'll need to add 1-Period Moving Averages to the Bollinger Bands and Keltner Channels. You'll Drag and Drop the Moving Averages into the Code tab of the RealCode Editor to create the four lines starting '# (so don't copy those lines, create them by Dragging and Dropping the Moving Averages) and then change variable names to match those given in jas0501's example.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

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.