Module 1: Starting to Program
Module 2: Indicators and Functions
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

How to Code Multiple Data streams in a Strategy

In this Lesson You'll Learn:

When using multiple datastreams in Easylanguage, there are some things you need to consider. 

For instance, trying to combine delayed data with live data will cause the infamous warning that reads: “You may not mix symbols with different delays in the same window” .

How to Code Multiple Data streams in a Strategy

In order to combine two datastreams, they must have the same delay. That is, they all need to be either delayed or live data.

To tell if the data is live or delayed, you may check the symbol name. If it contains        “(D)” it’s delayed, while it should be live if it’s missing.

Below you see a delayed symbol.

How to Code Multiple Data streams in a Strategy

Inserting the Second Data Stream.

To use a second data stream, you first need to insert the second symbol onto a chart window. 

You do this by right-clicking the chart window and selecting “insert symbol“. In the window that pops up, you may insert the name the new symbol, and click “Ok.”

Now you should see that there is a second symbol applied to the chart window, like below.

How to Code Multiple Data streams in a Strategy

If you want to edit the timeframe of any of the symbols, you right-click the chart and select “format symbol“. Then select the symbol you want to edit, and click “format”.

How to Code Multiple Data streams in a Strategy

How to Reference the Second Datastream in Easylanguage

To reference the second data stream in Easylanguage, you type “data2” after the bar value you’re referencing. For instance, you get the close of the second data stream by typing “close data2”

 

Close data2

You may also call indicators and functions this way. See the examples below:

rsi(close,2) data2

Highest(high,5) data2

More Examples

Below we go long if the close of the first datastream crosses over the moving average of the second datastream

if close crosses over average(close,50) data2 then buy next bar open;

In the example below we compare the volume of the previous bar to that of the current bar.

 

If volume data2 > volume[1] data2 then buy next bar open;

 

Note: You may use several data streams in a strategy. Each datastream is labeled in the order in which it appears on the chart, from top to bottom. Thus the third symbol becomes data3, the fourth data4 and so on.

In the next section you’ll find a couple of exercises!

Lesson Content
0% Complete 0/1 Steps

Login to Your Account



Signup Here
Lost Password