date and time of last compleed bar

Questions about MultiCharts and user contributed studies.
janus
Posts: 778
Joined: 25 May 2009
Has thanked: 45 times
Been thanked: 93 times

date and time of last compleed bar

Postby janus » 23 Jul 2009

I'm using the following piece of code to figure out the date and time of the last completed bar, and then convert the values to the appropriate formats to be used in statements like arrow drawing. It appears to be working fine. Is there a better way?

date_last_bar = JulianTodate(LastCalcJDate); // YYYMMdd

time_last_bar = StrToNum(FormatTime("HHmmss", LastCalcSSTime/(24.0*60.0*60.0))); // HHmmss

Arw_New_self_s(date_last_bar, time_last_bar, high+offset, True);

bowlesj3
Posts: 2134
Joined: 21 Jul 2007
Has thanked: 209 times
Been thanked: 422 times

Postby bowlesj3 » 24 Jul 2009

Hi Janus,

I am not sure what you are doing exactly but I use something like this.

If LastBarOnChart_s then
begin
Arw_New_self_s(date, time_s, high+offset, True);
end;

In my case I am not putting the arrows on subchart #2 so my command is just Arw_New_s

John.

janus
Posts: 778
Joined: 25 May 2009
Has thanked: 45 times
Been thanked: 93 times

Postby janus » 24 Jul 2009

Thanks, but I tried that. Although it works virtually all the time, on very rare occasions it places the arrow on the wrong bar. This appears to happen when the market is very quiet. I still use LastBarOnChart_s but I also use my code above to make sure I'm using the correct bar to display objects.

bowlesj3
Posts: 2134
Joined: 21 Jul 2007
Has thanked: 209 times
Been thanked: 422 times

Postby bowlesj3 » 24 Jul 2009

Actually in my case I offset the arrows back a ways but I execute the code once and on the last bar on the chart. In other words, I would never have run into any bugs.


Return to “MultiCharts”