how to get the index of bar ?

 

aaa

if i move the mouse on the chart, the index of the specific bar is shown like the picture,

how can i get this index ? i means get the index of bar depends on the location of mouse....

i would like to express by comment() function.

Thanks a lot your help ~

 
wctmiami:
Print("Current bar for USDCHF H1: ",iTime("USDCHF",PERIOD_H1,0),", ",  iOpen("USDCHF",PERIOD_H1,0),", ",
                                      iHigh("USDCHF",PERIOD_H1,0),", ",  iLow("USDCHF",PERIOD_H1,0),", ",
                                      iClose("USDCHF",PERIOD_H1,0),", ", iVolume("USDCHF",PERIOD_H1,0));

What info do you get with this ??

 
wctmiami:

if i move the mouse on the chart, the index of the specific bar is shown like the picture,

how can i get this index ? i means get the index of bar depends on the location of mouse....

i would like to express by comment() function.

Thanks a lot your help ~

You can use the Crosshair tool (Ctrl+F). Click on last candle (index 0), hold down and move your mouse to the desired candle. First number is index.
 
deVries:


What info do you get with this ??


thanks, I just try to use this inform for checking the size of bar,

i tested, but they could't show up the index when i move the mouse point.

 
angevoyageur:
You can use the Crosshair tool (Ctrl+F). Click on last candle (index 0), hold down and move your mouse to the desired candle. First number is index.


yes, i can get the index of bar by crosshair tool,

but i need to comment(about index of bars) in the chart, cause for this value, i will calculate something.... impossible ??

 
have you tried CHARTEVENT_MOUSE_MOVE ?
 
qjol:
have you tried CHARTEVENT_MOUSE_MOVE ?


could you explain more ?

 
how to get the index of bar ?

Old post, but I found this thread because I wanted to be able to see the index of a bar.

The index is useful to me when writing indicators—especially when I have a problematic bar. I can dump debugging information for a very specific bar, like this:

if ( i == 31212 )
{
    PrintFormat("i [%d] rates_total [%d] time [%s] SizeBody [%f]",
                i,
                rates_total,
                TimeToString(time[i]),
                SizeBody(i)
                );
}

I call this using a scalpel instead of a sledgehammer.

So I created a simple indicator to be used as a tool to find this index number. Pretty simple, really. Hover over the bar to see the index number and time.

I've attached it for posterity.

It looks something like this:

Find index of a bar

Files:
Index.mq5  3 kb
Index.ex5  10 kb
 
Anthony Garot:

Old post, but I found this thread because I wanted to be able to see the index of a bar.

The index is useful to me when writing indicators—especially when I have a problematic bar. I can dump debugging information for a very specific bar, like this:

I call this using a scalpel instead of a sledgehammer.

So I created a simple indicator to be used as a tool to find this index number. Pretty simple, really. Hover over the bar to see the index number and time.

I've attached it for posterity.

It looks something like this:


Why have you attached mq5 code?

This section is for MT4 and mql4

 
Keith Watford:

Why have you attached mq5 code?

This section is for MT4 and mql4

Because it was an old post, the topic was germane, and I didn't notice the section.
Reason: