Module 1: Starting to Program

If-Statements

1 Topic
Module 2: Indicators and Functions

Useful Functions

1 Topic
Trading Indicators

1 Topic
Module 3: Variables

Module 4: Inputs

Module 5: Exit Techniques

Module 6: Stop Orders and Limit Orders

Module 7 Using Multiple DataStreams in a Strategy

Final Strategy Coding Project

Module 8: Plot Studies and Their Uses

Module 9: Writing to Files

Module 10: How to Code Your Own Indicators and Functions

- What a function is
- How functions are used with inputs

In the previous lesson we used different conditions which consisted of comparing different values such as the close and open prices to each other.

When we’re using conditions like **close > open** , then this works fine. However, when we start to move into more advanced mathematical formulas, having to type the code for each calculation becomes very time consuming.

Now, this is where functions come in handy.

In short, a function in Easylanguage is a separate calculation that you can call in your strategy, and that returns the value of the formula it contains.

That is, the calculation is coded inside another Easylanguage file, which you can access from your strategy.

This is also how we use trading indicators. We use a function that contains the calculation for the indicator, and the only thing we need to do is to call the function by its name, and insert the parameters we want the indicator to use.

If you remember from the lesson on timeexits, we used barssinceentry, which is a function and reserved word, to know how many bars that had passed since we entered the trade.

In other words, barssinceentry contains a calculation that returns the number of bars from the last entry. And by calling barssinceentry in our strategy, we get back this value.

Some functions will have inputs where you’ll have to insert a number or bar value that they will use for the calculation. This is done inside round brackets, where you just specify the value or values you want the function to use.

For example, here you have the maxlist-function which requires that you insert a series of values, of which it will return the highest.

Maxlist(Open, Close, 50, 20);