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

Re: EL functions at End of Chart.



PureBytes Links

Trading Reference Links

> I have two questions about how TS behaves with regard to variables at the
>end of a ?? minutes per bar chart.
>
>For example, if I had an indicator on a 5 minute bar chart and it contained
>the following code, what would be the value of X *for the last bar after 5
>minutes*?
>
>Assume the following: (a) X = 0 before entering the last bar. (b) There are
>100 ticks that happen during the last bar.
>
>**CODE**
>var: X(0);
>
>X=X+1;
>**END CODE**
>
>In other words, if the 5 minute bar chart is ticking along and the clock
>turns 11:55 (and thus starting a new bar), what is the value of X above
>after 12:00 rolls along if 100 ticks occured between 11:55 and 12:00?


Deming Replied: At the end of the second bar, x=2.  The number of ticks
which make up the bar have no effect on the calculation. The variables (X)
are updated on the final tick of a 5 min bar.

>
>Second question:
>
> How do you write your EL code to detect that the last bar is being
>calculated again? Hence, as in the above scenario, how do you detect that
>the current calculation is the first tick (after 11:55) as opposed to any
>other tick of that bar?


First you must turn on "Update Every Tick" then it will process your code on
every tick of the bar. There is no easy way to detect what tick (first vs.
second) of bar you're on. It can be done using Global Variables or HashNums
products. You can learn more about these products at:
http://www.investlabs.com

These products allow you to perform intra bar calculations. For example with
your example, X would equal 100 if the 5-min bar consisted of 100 ticks.