troubleshooting code for Price Momentum Oscillator function  [SOLVED]

Questions about MultiCharts and user contributed studies.
mattyham
Posts: 4
Joined: 04 Mar 2015
Has thanked: 1 time

troubleshooting code for Price Momentum Oscillator function

Postby mattyham » 18 Feb 2016

Hi all. I have been trying to create an indicator for a Price Momentum Oscillator (PMO). I have created a function that is returning the following error: "floating-point invalid operation. To calculate the PMO, the calculation includes the value of the PMO on the last bar. I think the problem is that since there is no value for PMO on the first bar (because it hasn't been calculated yet), I am getting this error. But that may be incorrect... Anyone have any ideas? (Note: I also created a rate of change function called PMOROC, which is very basic and that the PMO references. It seems to be working fine.)

The code for the PMO function is as follows:

inputs: Len1( numericsimple ), Len2( numericsimple ) ;

variables: var1( 0 ), var2( 0 ), var3( 0 ), var4( 0 ) ;

var1 = PMOROC( close, 1 ) ; ///1 period ROC as per DecisionPoint's calculation
var2 = 2 / Len1 ; ///1st custom smoothing constant
var3 = 2 / Len2 ; ///2nd custom smoothing constant
var4 = ((var1*var2) + (var4[1]*(1-var2)))* 10 ; ///1st custom EMA of ROC

PMO = ((var4-PMO[1])*var3) + PMO[1] ///2nd custom EMA of ROC}

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: troubleshooting code for Price Momentum Oscillator funct  [SOLVED]

Postby TJ » 18 Feb 2016

Hi all. I have been trying to create an indicator for a Price Momentum Oscillator (PMO). I have created a function that is returning the following error: "floating-point invalid operation. To calculate the PMO, the calculation includes the value of the PMO on the last bar. I think the problem is that since there is no value for PMO on the first bar (because it hasn't been calculated yet), I am getting this error. But that may be incorrect... Anyone have any ideas? (Note: I also created a rate of change function called PMOROC, which is very basic and that the PMO references. It seems to be working fine.)

The code for the PMO function is as follows:

inputs: Len1( numericsimple ), Len2( numericsimple ) ;

variables: var1( 0 ), var2( 0 ), var3( 0 ), var4( 0 ) ;

var1 = PMOROC( close, 1 ) ; ///1 period ROC as per DecisionPoint's calculation
var2 = 2 / Len1 ; ///1st custom smoothing constant
var3 = 2 / Len2 ; ///2nd custom smoothing constant
var4 = ((var1*var2) + (var4[1]*(1-var2)))* 10 ; ///1st custom EMA of ROC

PMO = ((var4-PMO[1])*var3) + PMO[1] ///2nd custom EMA of ROC}

See post #3
viewtopic.php?f=16&t=10811

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: troubleshooting code for Price Momentum Oscillator funct

Postby TJ » 18 Feb 2016

ps.
see post #1 & #2
[FAQ] How to Post Codes (... so that people can read)
viewtopic.php?f=16&t=11713


Return to “MultiCharts”