Hello-
I'm trying to create a function that uses 2 data streams with different timeframes (data1, data2,...). Does anyone here have an example of how to do this? Is it similar to using 2 datasets in an indicator or strategy?
Thank you
Create Function multiple timeframes
-
- Posts: 29
- Joined: 15 Aug 2012
- Has thanked: 2 times
- Tammy MultiCharts
- Posts: 200
- Joined: 06 Aug 2020
- Has thanked: 6 times
- Been thanked: 65 times
Re: Create Function multiple timeframes
Hello Masber2000,
As a reference you can view the script of the pre-built Indicator Correlation that compares 2 data series.
There is a function Correlation( IndepData, DepData, Length) which uses Data 1 and Data 2 as inputs:
Here is the code of the function:
As a reference you can view the script of the pre-built Indicator Correlation that compares 2 data series.
There is a function Correlation( IndepData, DepData, Length) which uses Data 1 and Data 2 as inputs:
Code: Select all
inputs:
IndepData( Close of data1 ),
DepData( Close of data2 ),
Code: Select all
inputs:
Indep( numericseries ),
Dep( numericseries ),
Len( numericsimple) ;
variables:
var0( 0 ) ;
if Len > 0 then
begin
var0 = 0 ;
for Value1 = 0 to Len - 1
begin
condition1 = ( ( Indep >= Indep[1] and Dep >= Dep[1] )
or ( Indep < Indep[1] and Dep < Dep[1] ) )[Value1];
if condition1
then
var0 = var0 + 1 ;
end ;
Correlation = 2 * var0 / Len - 1 ;
end
else
Correlation = -2 ;
-
- Posts: 29
- Joined: 15 Aug 2012
- Has thanked: 2 times
-
- Posts: 310
- Joined: 02 Nov 2010
- Has thanked: 26 times
- Been thanked: 23 times
Re: Create Function multiple timeframes
Hi Tammy,
could you write please the cointegration function please?
https://corporatefinanceinstitute.com/r ... tegration/
https://it.mathworks.com/discovery/cointegration.html
could you write please the cointegration function please?
https://corporatefinanceinstitute.com/r ... tegration/
https://it.mathworks.com/discovery/cointegration.html