Why is following AFL statement :
InLongPos = IIf(Buy==1,1000,IIf(Sell==1,0,Ref(InLongPos,-1)));
giving me a different result as following ForLoop :
for ( i=1; i<BarCount; i++ )
{
if (Buy[i]==1)
InLongPos[i] = 1000;
else
{
if (Sell[i]==1)
InLongPos[i] = 0;
else
InLongPos[i] = InLongPos[i-1];
}
}
The result I am getting from the ForLoop is correct. The first
statement gives me a wrong answer. I want to get 1000 in InLongPos
after Buy and before Sell ... When testing the statement in Excel
it works fine with : =IF(A6=1;1000;IF(B6=1;0;C5)) ...
What's wrong ?