|
Josh McCormick
2020-07-11 21:05:20
|
|
I am working with a function that requires the input to be an integer, and only an integer.
The input value *cannot be an array*.
The problem *CANNOT BE SOLVED* like this:
cl = ref(close,0);
Why? Because cl is yet another array at the current offset.
Is there any way to create an integer type variable which holds the current single value from an array?
Actually, let me go ahead and give you the real problem.
period=Round (Ht_DCPeriod(),0);
s = relative_vigor_index_signal(period);
plot(s, "Signal", colorRed, ChartLine, StyleBringToFront|StyleWidth2);
I'm using HT_DCPeriod to provide my period. (The output is in the 10-30 range.) This works well for a number of indicators, but there are a few (like relative_vigor_index_signal) which just seems to barf on it. I've verified that I end up with an integer in the 10-30 range. And if I say "period=30" it works. But if I try an array of numbers (like close) it fails.
A message "Error in formula relative_vigor" flashes on the plot.
The code for relative_vigor_index_signal is as follows:
var p : int = period[0];
var formula : String = "p = " + p + ";v1 = ((close-open)+(2*Ref(close-open,1))+(2*Ref(close-open,2))+Ref(close-open,3))/6;v2 = ((high-low)+(2*Ref(high-low,1))+(2*Ref(high-low,2))+Ref(high-low,3))/6;d = iff(Sum(v2,p)==0, 0.0001, Sum(v2,p));rvi = Sum(v1, p)/d;rviS = (rvi+Ref(2*rvi,1)+Ref(2*rvi,2)+Ref(rvi,3))/6;";
result = cFunctions.CompileFormula(formula).GetVectorDouble("rviS");
Thanks again,
Josh
|
|