[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to keep a value in a variable over consecutive bars?


  • To: "Gary Fritz" <fritz@xxxxxxxx>
  • Subject: Re: How to keep a value in a variable over consecutive bars?
  • From: "carrslem" <carrslem@xxxxxxx>
  • Date: Sun, 16 May 2004 13:10:51 -0700

PureBytes Links

Trading Reference Links

Keep in mind that I did not actually assign a value to the variable at every
tick - although the function was CALLED at every tick (because I had
selected "update-on-every-tick"), I assigned a value to the variable only
under certain circumstances (the highest value of some expression DURING the
period represented by the current bar).  Although I have since forgotten the
algorithm, I did at the time determine how they determined the final value
of the variable and, as I recall, it was bizarre.  It definitely was NOT, as
you suggested, the final value which I assigned during that bar.

Also, I suggested to them a couple of solutions to the
different-result-on-historical-data problem, but as far as I know, they
never implemented any of them.  My principal gripe was that nowhere were
users warned of this counterintuitive "feature" - it is contrary to a
fundamental principal of programming language design, that the value
assigned to a variable within a program is retained until the programmer
reassigns it (or, in some languages, until the context changes unless the
variable is declared as "global").

Best regards,
Carroll


> > "update on every tick" feature to be only an approximation of the
> > end-of-bar value and, therefore, do NOT retain such values beyond the
> > close of the bar. A further reason given was that retaining the
> > intra-bar value would cause results on "historical" data to differ
> > from real-time results (because calculations on historical data use
> > only the OHLC bar data, not tick data).
>
> Both are true, although I don't think that's what Abhijit was
> asking.
>
> Changes to EL variables don't "stick" until the end of the bar.
> Otherwise you could have a chart that displayed one set of values
> if built in realtime, and a totally different set of values if
> you closed and re-opened the chart, or toggled the status on the
> indicator.
>
> > Because I was not assigning the bar's closing value to the variable,
> > it was getting "restored" to something else - I believe it was the
> > closing vakue of the PREVIOUS bar, or something equally bizarre!
>
> No, it should be the final value you assign in THAT bar.
>
> Gary