PureBytes Links
Trading Reference Links
|
Gary,
Interesting to note that I tried using Value1 in TS2k as he did and
it DOES reset to 0 except on bar 10. I then declared a variable and it
did not reset. I never use the built in variables so I did not realize
that would happen.
Regards, Randall
Friday, August 10, 2001, 13:24:55, you wrote:
>> In easy language, if I want a variable that I can set it a bar and
>> remains the same until I change it, how would I do that?
> Just set a value on any variable. It will retain that value until
> you change it to something else.
>> Variables MyNum(0);
>> If BarNumber = 10 then MyNum = Close;
>> If I'm anywhere but the 10th bar, MyNum will equal 0.
> I believe you're confused about how variables work. MyNum will be 0
> until you set it to Close on the 10th bar, because the "Vars"
> statement initialized it to 0 **before the first bar**. It *DOES
> NOT* keep setting it to that value on every bar.
> After bar 10, MyNum contains the value of Close from the 10th bar.
> If you don't change it to another value, it will retain the value of
> the 10th bar close on the 100th, 1000th, or Nth bar.
> Gary
|