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

Why this doesn't work? Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
Nelane
Posted : Wednesday, October 13, 2010 12:06:34 PM
Registered User
Joined: 10/7/2004
Posts: 56
'# period = userinput.integer = 10
Dim MinL As Single
MinL = Price.MinLow(Period)
plot = MinL.AVG(Period)
Bruce_L
Posted : Wednesday, October 13, 2010 12:33:27 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I'm not a programmer, but I'll try to explain it the best I can.

MinL is a variable of the Single data type (it only returns one value). You would need something that returns a RealCodeIndicatorCalculation data type (which returns a dated series of values) to chain the methods together because AVG(Period) requires multiple values for its calculations.

The RealCode API lists the outputs types of the RealCode Methods and Properties.

There isn't a method that returns a minimum as a RealCodeIndicatorCalculation data type of which I am aware.

So you could do a Moving Average first and then a minimum (which would obviously not return the same Value):

'# Period = UserInput.Integer
Plot = Price.MovingAverage(Period).MinLow(Period)

But not a minimum first and then a Moving Average without importing the minimum as an Indicator (the first line was created by Dragging and Dropping a Max or Min of Line Indicator into the RealCode Editor).

'# MoMo = chart.MaxorMinofLine
'# Period = UserInput.Integer = 10
Plot = MoMo.AVG(Period)

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Nelane
Posted : Wednesday, October 13, 2010 2:20:20 PM
Registered User
Joined: 10/7/2004
Posts: 56
I thought there was only a syntax error in that code. This explanation would have never occured to me. You probably explain things better because you're not a programmer.

I looked up in RealCode API the difference between MovingAverage and AVG methods however I noticed that neither MovingAverage(period, barStyle) nor AVG(period, barStyle) work when I copy-paste into editor the examples given:

Plot = price.MovingAverage(30,RealCodeIndicator.BarValue.High).XAVG(5)

plot = price.AVG(30,RealCodeIndicator.BarValue.Low).Value


AVGH, AVGL, AVGO cannot be used to chain more functions with, so how to use average of High or Low with other functions?
Bruce_L
Posted : Wednesday, October 13, 2010 2:42:20 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I think you need to substitute the Indicator of interest for RealCodeIndicator. So the first example would actually look like:

Plot = Price.MovingAverage(30, Price.BarValue.High).XAVG(5)

While the second example would actually look like:

Plot = Price.AVG(30, Price.BarValue.Low).Value

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Nelane
Posted : Wednesday, October 13, 2010 2:59:47 PM
Registered User
Joined: 10/7/2004
Posts: 56
AAhh! Of course.

Thank you, Bruce.
Bruce_L
Posted : Wednesday, October 13, 2010 3:01:34 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You're welcome.

-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.