Create Function multiple timeframes

Questions about MultiCharts and user contributed studies.
masber2000
Posts: 29
Joined: 15 Aug 2012
Has thanked: 2 times

Create Function multiple timeframes

Postby masber2000 » 04 Jan 2021

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

User avatar
Tammy MultiCharts
Posts: 200
Joined: 06 Aug 2020
Has thanked: 6 times
Been thanked: 65 times

Re: Create Function multiple timeframes

Postby Tammy MultiCharts » 04 Feb 2021

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:

Code: Select all

inputs: IndepData( Close of data1 ), DepData( Close of data2 ),
Here is the code of the function:

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 ;

masber2000
Posts: 29
Joined: 15 Aug 2012
Has thanked: 2 times

Re: Create Function multiple timeframes

Postby masber2000 » 29 Mar 2021

Thank you kindly for the suggestion!

bomberone1
Posts: 310
Joined: 02 Nov 2010
Has thanked: 26 times
Been thanked: 23 times

Re: Create Function multiple timeframes

Postby bomberone1 » 13 Apr 2021



Return to “MultiCharts”