Referencing data and data[1]

D

dodoei

New member
Sorry if this is too dumb, but I couldn't find it in the documents. Is Data or Data[1] representing the current bar information whether it's the bar itself or some other derivative information? What I found out is that when using addchartbubble, the price location input can not take Data, it has to be Data[1] to display the bubble text.

EDIT: related is Data and Data[0] the same thing?

Thanks
 
Last edited:
T

tomsk

Well-known member
VIP
Sorry if this is too dumb, but I couldn't find it in the documents. Is Data or Data[1] representing the current bar information whether it's the bar itself or some other derivative information? What I found out is that when using addchartbubble, the price location input can not take Data, it has to be Data[1] to display the bubble text.

EDIT: related is Data and Data[0] the same thing?

Thanks

Absolutely not true, post your script so folks can help you with the issue
You can reference any bar so long as there is data there
 
D

dodoei

New member
Yes, the code is very simple

This works and shows the bubble text with values for the last bar at Friday's close

AddChartBubble(IsNaN(close) and !IsNaN(close[1]), close[1], AsText(close[1]), Color.RED, yes);

Both the following not working, no bubble text showing

AddChartBubble(IsNaN(close) and !IsNaN(close[1]), close, AsText(close), Color.RED, yes);
AddChartBubble(IsNaN(close) and !IsNaN(close[1]), close[0], AsText(close[0]), Color.RED, yes);

Is it because close and close[0] is supposed to be the current running bar (or the next running bar when the market reopens?) In any case, right at this moment close[1] gives the last bar information. Should I expect close or close[0] start working when the market reopens?

Thanks!
 
T

tomsk

Well-known member
VIP
You seem to have the time condition defined incorrectly.
Here's the correct definition to display a bubble for the last bar on the chart

AddChartBubble(!IsNaN(close) and IsNaN(close[-1]), close, AsText(close), Color.RED, yes);

Note that this also works but then those two are equivalent statements, so no need to over complicate things

AddChartBubble(!IsNaN(close) and IsNaN(close[-1]), close[0], AsText(close[0]), Color.RED, yes);
 

Similar threads

Top