You might also want to consider GetValueAt() instead of barsAgo. It works everywhere and is more predictable. You access the value at a specific bar. Bars ago has its limitations and may not always give you the correct value that you’re anticipating. Look at NT Best Practices page for details.
seems like im getting extra bars from somewhere. “spoofing my RAM” i changed my code to only update on bar 2, but my bars ago kreeps backwards on the ERROR, I have extreme amounts of ULTRASOUND in my room that is affecting my memory stack with no one to report it to ..
not sure that is the answer as i dont need a price, i only need a reference to time. for draw region purpose. " asks for bars ago" which is variable changing on new bar.
if i was able to draw region starting at “time” instead of bars ago this would be AWESOME.
This is the syntax if you have a single data series. If there are multiple data series in your code, then you’ll have to use the right Times[index] for the bars that are in progress.
You can probably simplify it as below and this should work in all cases assuming your indexing is correct.
Time now > Times[BarsInProgress].GetValueAt(CurrentBars[BarsInProgress])
Time 10 bars ago: Times[BarsInProgress].GetValueAt(CurrentBars[BarsInProgress]-10)
OK, I’m trying to help here, but maybe I don’t understand all the details. I just gave you the syntax of how to grab the time for a given bar. You’ll need to figure out the rest of the syntax since I don’t have your code.
Explain to me in English what you’re trying to do and I’ll give you the syntax you need. Are you trying to draw a ray that starts on the last bar of the chart (or a few bars back) and point to the right?
Or maybe post your exact Draw.Ray() line and tell me what error you’re getting and maybe I can help.
I agree with fc77, posting the error and the exact code would be very helpful. One question I have is: are you doing your draw work in OnBarUpdate() or OnRender()? There can be some subtle differences depending on the context you’re using.
there is no error to speak of but the value of the variable should not change but remain the same anchor point.
The error is the spoofing, which causes extra bars to be introduced. thus causing the script to repeat the math logic because it runs on price change not bar close,
solution: change anchor to time , or change math to only run on “new bar” this may still get spoofed.
Draw.Ray() example above is the actual snippet im working on, i know it involves [0],[0],[0] or something like that.
-10 for the end bars ago would actually be in the future. I’m not sure that’s defined behavior. Ray’s automatically extend infinitely in the direction they point.
If you want the ray pointed left (from now to 10 bars ago):