PureBytes Links
Trading Reference Links
|
At 12:07 PM 1/12/2005, you wrote:
>I am trying to figure out a way to determine, at a point mid chart, how many
>bars follow on the chart. Big picture, I want to do things to tls on chart
>if they are at least 50 bars from the end, otherwise leave them alone. Any
>ideas?
>
>Only thing I have come up with is to calc an implied bar # for
>currentdate/currenttime (it is ok if this isn't perfect vis-a-vis holidays),
>but that seems like a pain, as I want it to work on every time frame.
>
>Muchos gracias,
>Chris
Hi Chris,
Here's a scheme that would work if you could put up with loading the chart twice. Might also work automagically if you use MaxBarsBack set to auto, since I think the study may actually run twice in that mode.
Have the study save its bar number to a unique global variable on the last bar, using If OnLastBar.
To do the trendline work, on each bar fetch the last bar variable from the global variable and check the difference between the current bar and that last bar number. Only do the work if the difference is > 50.
Someone also posted a method a while back about using Text objects on the chart in place of global variables, in effect using them as static storage. So, you could try writing the bar number into a Text label on the last bar instead if you don't want to bother with a global variable DLL. This approach is kind of nice since you get to see the stored value without any extra work.
HTH,
Mike Gossland
|