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

Help in Blocks with Moving Averages Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
dah1147
Posted : Wednesday, July 23, 2008 1:28:19 PM
Registered User
Joined: 2/13/2005
Posts: 10
Hello,
I'm a new Blocks user and have a question on how to code a formula.

I want to add the delta of two moving averages to one of the averages.

Thanks for your help.
Julia_O
Posted : Wednesday, July 23, 2008 2:25:12 PM


Worden Trainer

Joined: 4/26/2007
Posts: 508
dah1147,

We're glad to help in any way we can.  Are you wanting one plot that is equal to the difference between the two individual moving averages?  If so, no need to code.  All you'll need to do is to plot both  individual moving averages.  Then drag the first moving average to the second.  When you release your hold, select Create Indicator from the menu.  Now select Difference.  The new plot that appears is equal to the difference between the two moving averages.

Let us know if you had something else in mind or if you need to follow-up.

Hope that helps-
Julia
dah1147
Posted : Wednesday, July 23, 2008 3:10:43 PM
Registered User
Joined: 2/13/2005
Posts: 10
Julia,
Thanks for your quick response and your accurate response; however, I didn't get quite the result I wanted and I need to sum the two and then divide by two. Can I do that as simply?

Thanks.
Julia_O
Posted : Wednesday, July 23, 2008 3:54:09 PM


Worden Trainer

Joined: 4/26/2007
Posts: 508

The easiest way to do this will be to write a tiny bit of code.  No sweat, though.  Here's what you should do:

1. make sure both moving averages are visible on your chart
2. Select RealCode Editor from the Home Ribbon.  From its menu, select Indicator.  Name the indicator as you wish
3. You will need to create variables for each individual moving average plot, so... drag one of the moving average plots from the chart into the code editor.  Make sure you hit enter to start a new line.  Then drag the other moving average plot into the code editor.  Notice that both are labelled 'MA' by default.  Assign the second MA something to differentiate it; I made the second MA MA2 instead as shown below.

Here's what you should see in the code editor so far:

'# MA = indicator.MovingAverage.3
'# MA2 = indicator.MovingAverage

Now hit enter to work on a new line and enter the following code:

plot = (ma.value+ma2.value)/2  

That's it.  Hit Apply and you're all set.  Let me know if you need anymore help.

Best,
Julia

dah1147
Posted : Wednesday, July 23, 2008 4:58:25 PM
Registered User
Joined: 2/13/2005
Posts: 10
Thank you very much.
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.