I have written a strategy that successfully compiles but when I go to enable it, it won't stay enabled. I've gone through section by section and line by line to determine which part of my code is not able to enable and this is the part giving me trouble:
This is located in a for loop where I am trying to compare close values in the past to the value 1 in front and 1 behind the current value being evaluated.
if(Close[i] > Close[i + 1] && Close[i] > Close[i - 1])
{
ArrayPeak[1,j] = Close[i];
j = j + 1;
}
if(Close[i] < Close[i + 1] && Close[i] < Close [i - 1])
{
ArrayValley[1,k] = Close[i];
k = k + 1;
}
This section is comparing the values generated by the previous section to determine an overall trend.
if(ArrayPeak[0,0] > ArrayPeak[0,1] && ArrayPeak[0,0] > ArrayPeak[0,2] && ArrayPeak[0,1] > ArrayPeak[0,2] && ArrayValley[0,0] > ArrayValley[0,1] && ArrayValley[0,0] > ArrayValley[0,2] && ArrayValley[0,1] > ArrayValley[0,2])
{
TrendUpward = true;
}
if(ArrayPeak[0,0] < ArrayPeak[0,1] && ArrayPeak[0,0] < ArrayPeak[0,2] && ArrayPeak[0,1] < ArrayPeak[0,2] && ArrayValley[0,0] < ArrayValley[0,1] && ArrayValley[0,0] < ArrayValley[0,2] && ArrayValley[0,1] < ArrayValley[0,2])
{
TrendDownward = true;
}
Both of these sections independently do not allow the code to enable successfully.
Am I declaring and using these arrays incorrectly? And can I not use a variable inside the Close[]?
Thank you
Jeff

Comment