I actually set up a loop with the same sell entry and exit conditions to set
the shorton variable right b4 my buy code and that seems to work.
SO no longer a chicken and egg. ALthough it took me forever to figure that out.
But that is how u learn.
--- In amibroker@yahoogroups.com, "Mike" wr
If you are trying to preserve a value between passes of the code, try looking
at StaticVarSet, StaticVarGet.
If you are talking about within a single pass of the code, then you have a
chicken and egg circular reference and will need to rethink your code.
You may find the use of intermediate var
Correct.
Mike
--- In amibroker@yahoogroups.com, "noah.bender" wrote:
>
> if what u say is true then even though the short gets set to 1 in the loop.
> when it passes through the code again it will get set to zero and then enter
> loop with a value of zero and not one?
> because each time the c
shorton=0;
for (i=0; i buy = a and b and c and shorton==1; // *double =* for conditional
statement
shorton=1; // shorton will be 1 for all i's except the first one
}
noah.bender wrote:
my theory was initially to reference the shorton.But I am running into
problems. I have tried using the
my theory was initially to reference the shorton.But I am running into
problems. I have tried using the ref function and the barcount function with no
luck.
It seems the code always reverts back to the initialization value of zero. It
is really frustrating. And I can't move the calculation of
if what u say is true then even though the short gets set to 1 in the loop.
when it passes through the code again it will get set to zero and then enter
loop with a value of zero and not one?
because each time the code passes through the value gets set to zero.
--- In amibroker@yahoogroups.
No. That is not correct.
It is the same variable being used both inside and outside of the loop. It will
have whatever value was last set on it regardless of whether the value was set
from within the loop or not.
Based on your sample code, the first reference to shorton within the loop will
se
i think i found the answer to my question by using a loop. If I am a correct
when using a loop as long as the variable is with in the loop as long as the
loop is running then it will not use value of the variable from out side the
loop.
for example
shorton =0 ;
for (i=o..)
(
code referenc