FindBar maximum

Questions about MultiCharts and user contributed studies.
k-hen
Posts: 8
Joined: 08 Dec 2009

FindBar maximum

Postby k-hen » 14 Jan 2010

Hi,
I'm trying to use FindBar with the aiRightDispDateTime value to create a customized data window - but it's returning '-1' when it's too many bars back from the last bar (~100). Can anyone help clarify what might be happening? Should I write a custom findbar function instead of using the built-in one or am i missing something?

Any help would be appreciated - thanks very much.

I'm using 6.0B2.

Code: Select all

variables:
s(symbol),
lbj(0.00), lbd(0), lbt(0), lb(0)
//last bar julian, date & time, last bar (visible)
;
if lastbaronchart then begin
lbj=GetAppInfo(aiRightDispDateTime); //right-most datetime (julian)
lbd=JulianToDate(lbj); //right most date
lbt=datetime2eltime(lbj); //right most time
lb=FindBar(lbd, lbt);

print(s+", lbj: "+numtostr(lbj,4)
+", lbd: "+numtostr(lbd,0)
+", lbt: "+numtostr(lbt,0)
+", lb: "+numtostr(lb,0)
);
end;

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 14 Jan 2010

go to Format Study,

Under Properties tab

set the Max numbre of bars study will reference

to User Specified

User avatar
RobotMan
Posts: 375
Joined: 12 Jul 2006
Location: Los Altos, California, USA
Has thanked: 31 times
Been thanked: 13 times
Contact:

Postby RobotMan » 14 Jan 2010

I wrote something a while back. you might look at it for example code. I don't know if it will help or not.

http://forum.tssupport.com/viewtopic.php?t=5889

k-hen
Posts: 8
Joined: 08 Dec 2009

Postby k-hen » 15 Jan 2010

TJ, when I do that I get an error alert about the series length. I'll try to get the exact message but I'm away from my computer until next week.

Bob, yes I'd read that post and used it in my test code - which I believe is correct - thanks for posting, it helped me out.

brodnicki steven
Posts: 407
Joined: 01 Jan 2008
Been thanked: 3 times

Postby brodnicki steven » 15 Jan 2010

I wrote something a while back. you might look at it for example code. I don't know if it will help or not.

http://forum.tssupport.com/viewtopic.php?t=5889

* Thanks for that code RobotMan, I still use a variation of it, since your original post. Very slick solution !

k-hen
Posts: 8
Joined: 08 Dec 2009

Postby k-hen » 19 Jan 2010

Hi, I just wanted to provide an update -
Setting an explicit user specified max bars back value in the study properties produced a 'not enough series length' error. Likewise setting a fixed MBB for "Value1 = Close[MBB]" produced the same error - both likely because my instrument data series does not go back that far.

But by simply leaving the max bars back setting to 'auto-detect' and then using

Code: Select all

value1 = close[barnumber-1];


i was able to get it to work across the entire data series - presumably this is because the findbar/built-in functions alone are not enough to get the auto-detect bars back to be updated.

Thanks everyone for your help!

Kevin


Return to “MultiCharts”