I'm passing an array to a function which finds a swing point. It correctly finds the first swingpoint, but on subsequent function calls, it keeps using the same values for it's local array, instead of reading the values from the array that's passed to it.
Here are the relevent code snippets:
IN FILE Parent.efs:
function swinghigh(Instance,aSwPrice,Strength,Length) {
if(Instance == null) {
Instance = 1;
}
if(aSwPrice == null) {
return ("no prices");
}
if(Strength == null) {
Strength = 1;
}
if(aSwPrice[Length+1] == null) {
return ("not enough prices");
}
aPoint = aSwPrice; // must pick a different var to pass to the SwingPoint function
debugPrintln("**SwingHigh-RS " +getMonth(0)+"/"+getDay(0)+" "+getHour(0)+":"+getMinute(0)+" [0]: "+aPoint[0]+" [6]: "+aPoint[6]);
vsw = call("SwingPoint.efs", aPoint,Length,Strength,Strength,Instance,1);
return vswb[1]; //return bar at swingh high
}
function main() {
...some other code...
var nBarState = getBarState();
if(nBarState == BARSTATE_NEWBAR) {
aCloses.pop();
aCloses.unshift(0);
aCloses[0] = close();
rs1last=swinghigh(1,aCloses,1,20);
}
return rs1last;
}
*****************************
IN FILE SwingPoint.efs:
// finds a swinghigh or low point
function main(aswptPrice,Length,LeftStrength,RightStrength, Instance,HiLo) {
debugPrintln("--BEGIN--SwingPoint " +getMonth(0)+"/"+getDay(0)+" "+getHour(0)+":"+getMinute(0)+" price: "+aswptPrice[0]+" [1]"+aswptPrice[1]);
....some more code......
In examing the debug output, the array "aPoint" in the swinghigh function correctly shows the latest history or closing prices. BUT, the debug statement in SwingPoint.efs ALWAYS shows the FIRST set of closing prices that filled the array, even as the timestamps keep incrementing for each bar on the chart!
anyone have any ideas?
thanks!
Here are the relevent code snippets:
IN FILE Parent.efs:
function swinghigh(Instance,aSwPrice,Strength,Length) {
if(Instance == null) {
Instance = 1;
}
if(aSwPrice == null) {
return ("no prices");
}
if(Strength == null) {
Strength = 1;
}
if(aSwPrice[Length+1] == null) {
return ("not enough prices");
}
aPoint = aSwPrice; // must pick a different var to pass to the SwingPoint function
debugPrintln("**SwingHigh-RS " +getMonth(0)+"/"+getDay(0)+" "+getHour(0)+":"+getMinute(0)+" [0]: "+aPoint[0]+" [6]: "+aPoint[6]);
vsw = call("SwingPoint.efs", aPoint,Length,Strength,Strength,Instance,1);
return vswb[1]; //return bar at swingh high
}
function main() {
...some other code...
var nBarState = getBarState();
if(nBarState == BARSTATE_NEWBAR) {
aCloses.pop();
aCloses.unshift(0);
aCloses[0] = close();
rs1last=swinghigh(1,aCloses,1,20);
}
return rs1last;
}
*****************************
IN FILE SwingPoint.efs:
// finds a swinghigh or low point
function main(aswptPrice,Length,LeftStrength,RightStrength, Instance,HiLo) {
debugPrintln("--BEGIN--SwingPoint " +getMonth(0)+"/"+getDay(0)+" "+getHour(0)+":"+getMinute(0)+" price: "+aswptPrice[0]+" [1]"+aswptPrice[1]);
....some more code......
In examing the debug output, the array "aPoint" in the swinghigh function correctly shows the latest history or closing prices. BUT, the debug statement in SwingPoint.efs ALWAYS shows the FIRST set of closing prices that filled the array, even as the timestamps keep incrementing for each bar on the chart!
anyone have any ideas?
thanks!
Comment