# MetaStock Programming Language – Input ‘On Balance Volume Indicator’

Posted in Blog This is a continuation of our series on the basics of MetaStock Programming Language and MetaStock market data. In this post we are going to talk about ‘On Balance Volume Indicator’, something that you need to know as a Metastock Expert.

Figure 2.8 –Input ‘On Balance Volume’ Indicator

When looking at the code, can you identify each separate component of the input function? i.e the prompt text, minimum value, maximum value and default value. The astute reader may have realised that inputs are most effective when used in conjunction with variables that use a single value, as shown in the above example.

Note that more than one input can be used in a formula. In fact up to 6 inputs can be used in a formula. Remember our example from the variables section?

We could rewrite this to include the input function.

x:=Input(“Enter the short-term moving average value”,2,9,5);

y:= Input(“Enter the medium-term moving average value”,10,19,10);

z:= Input(“Enter the long-term moving average value”,20,29,20); C > Mov(C, x, E) AND

Mov(C, x, E) > Mov(C, y, E) AND Mov(C, y, E) > Mov(C, z, E)

Now, each time we plot this as an indicator all of the inputs required would appear in a dialog before the indicator is plotted.

Language

If we did plot this as an indicator a ‘1’ would be displayed every time all of the conditions were true (we’ll learn more about indicators later). Thus, if the close was greater than the short moving average, the short term moving average was greater than the medium term moving average and the medium term moving average was greater than the long term moving average, then a value of ‘1’ would be plotted, otherwise the indicator would remain ‘0’.

There are a few rules to follow when using input functions. Firstly, since an input function by its nature requires an input, it can only be used in The Indicator Builder. That is to say it can’t be used in explorations, system tests and experts.

Secondly, and more importantly, in most cases you will have to assign the input() function to a variable. This is because the input() function cannot be embedded within other functions. For example, the following use of the input() function is not valid:

mov(close, input(“Enter the short-term moving average value”,1,21,7), s); This can be modified allowing for the use of the input function.

periods:= Input(“Enter the moving average value”,1,21,7); Mov(CLOSE,periods,SIMPLE)

As you can see inputs allow for great versatility within coding.

Now you know these Metastock tips and input ‘On Balance Volume Indicator’. In our next post, we will be presenting some exercises regarding Price Array Identifier and Arithmetic Operators. Do you want to learn how to use MetaStock formula like an expert? Just click here to learn more tips from the pros.

Watch this video for a quick introduction to MetaStock Basics.