following expression generates type error in Explorer. It runs without any error with AFL editor. If I check the type of the operands they are all numbers. No arrays at all.
if (PosSize == 0 AND Holding == Name())
{
Sell = True;
SellPrice = Close;
}
Double click on error line and the manual page that will open, i.e. THIS PAGE: http://www.amibroker.com/guide/errors/6.html And that is what you need to read to learn what is wrong with your formula.
What I am confused here is that PosSize and Holding are not array types they are numbers. I checked their type with typeof().
The code worked fine with AFL editor and debugger but not with Explore.
style, I cannot use them inside if-expression. They cause type error in Explore. The Explore identifies them as array types while AFL editor/debugger identify them as scalar types. This is a frustrating situation.
Really don’t argue with the compiler. If compiler tells you that you have an error it means that you have an error. Computers don’t make mistakes.
If program generates an error 6 it means that you used ARRAY.
Your “checks” mislead you. StaticVarGet would give you NULL (which is a NUMBER) if static variable is NOT defined (not present), but it will give you ARRAY if you have written array to static variable..
You are doing coding mistake described precisely in the error page I already pointed out to you. PosSize variable is AN ARRAY. Use _TRACE and it will be all clear to you
PosSize = StaticVarGet("PosSize" + symbol);
_TRACE( "Type of variable is " + typeof( PosSize ) );
Sometimes it takes a shift in the thinking to get a good understanding of AmiBroker AFL.
I tell people to think of variables like a Row in Excel, with the dates in the columns.
Your code should only reference Up and to the Left in the excel example.
So consider every variable an array, and hopefully this idea can help with your thinking in your programming.