It seems that function BarStatus(1)=1 does not work same as TS, it works more like LastBarOnChart. If applied to a strategy it does not show historical orders-only works in realtime.
Input: Length(10);
If BarStatus(1)=1 then Buy Next Bar at HighestFC(C,Length) + 1 Point Stop;
SetExitOnClose;
BarStatus ?
Re: BarStatus ?
[quote]It seems that function BarStatus(1)=1 does not work same as TS, it works more like LastBarOnChart. If applied to a strategy it does not show historical orders-only works in realtime.
Input: Length(10);
If BarStatus(1)=1 then Buy Next Bar at HighestFC(C,Length) + 1 Point Stop;
SetExitOnClose;[/quote]
I don't know why you would check for BarStatus(1)=1 ? As I understand it , All that tells you is that Data stream 1 had a tick come in. More frequently, barstatus is used to check for the close of a bar on a data stream i.e. Barstatus(1)=2 .
J~
Input: Length(10);
If BarStatus(1)=1 then Buy Next Bar at HighestFC(C,Length) + 1 Point Stop;
SetExitOnClose;[/quote]
I don't know why you would check for BarStatus(1)=1 ? As I understand it , All that tells you is that Data stream 1 had a tick come in. More frequently, barstatus is used to check for the close of a bar on a data stream i.e. Barstatus(1)=2 .
J~
[quote]As far as i have tried, barstatus(1)=1 does not work.
Here's my workaround:
vars: intrabarpersist myCurrentBarNumber(0);
if currentBar<>myCurrentBarNumber then begin
// Do what ever you want
myCurrentBarNumber=currentBar;
end;[/quote]
Aljafp
I don't understand how your code above relates to Barstatus(N)=1 . Barstatus =1 only tells you that it is a tick within a bar. Barstatus=2 tells you it is a tick on the close of the bar, Barstatus=0 tells you it is a tick on the open of the bar. Your code seems to assure that "//do what ever you want" only executes once per bar. But as far as I understand that has nothing to do with what barstatus does. It does correct for LastbaronChart triggering multiple times on the same bar in MC but what does that have to do with Barstatus=1 ? Please enlighten me.
J~
Here's my workaround:
vars: intrabarpersist myCurrentBarNumber(0);
if currentBar<>myCurrentBarNumber then begin
// Do what ever you want
myCurrentBarNumber=currentBar;
end;[/quote]
Aljafp
I don't understand how your code above relates to Barstatus(N)=1 . Barstatus =1 only tells you that it is a tick within a bar. Barstatus=2 tells you it is a tick on the close of the bar, Barstatus=0 tells you it is a tick on the open of the bar. Your code seems to assure that "//do what ever you want" only executes once per bar. But as far as I understand that has nothing to do with what barstatus does. It does correct for LastbaronChart triggering multiple times on the same bar in MC but what does that have to do with Barstatus=1 ? Please enlighten me.
J~
sry, my workaround is for barstatus(1)=0, the open of the bar...AljafpAs far as i have tried, barstatus(1)=1 does not work.
Here's my workaround:
vars: intrabarpersist myCurrentBarNumber(0);
if currentBar<>myCurrentBarNumber then begin
// Do what ever you want
myCurrentBarNumber=currentBar;
end;
I don't understand how your code above relates to Barstatus(N)=1 . Barstatus =1 only tells you that it is a tick within a bar. Barstatus=2 tells you it is a tick on the close of the bar, Barstatus=0 tells you it is a tick on the open of the bar. Your code seems to assure that "//do what ever you want" only executes once per bar. But as far as I understand that has nothing to do with what barstatus does. It does correct for LastbaronChart triggering multiple times on the same bar in MC but what does that have to do with Barstatus=1 ? Please enlighten me.
J~
my apologies
Maybe you can still adapt it to do it this way:
vars: intrabarpersist myCurrentBarNumber(0);
if currentBar<>myCurrentBarNumber then begin
myCurrentBarNumber=currentBar;
end
else if currentBar=myCurrentBarNumber then begin
// do whatever you want
// depending on how you want to treat the opening tick, you may also
// seperate the if else into 2 if statements, one after another.
end
Re: BarStatus ?
Here's definition of BarStatus(n)I don't know why you would check for BarStatus(1)=1 ? As I understand it , All that tells you is that Data stream 1 had a tick come in. More frequently, barstatus is used to check for the close of a bar on a data stream i.e. Barstatus(1)=2 .It seems that function BarStatus(1)=1 does not work same as TS, it works more like LastBarOnChart. If applied to a strategy it does not show historical orders-only works in realtime.
Input: Length(10);
If BarStatus(1)=1 then Buy Next Bar at HighestFC(C,Length) + 1 Point Stop;
SetExitOnClose;
J~
BarStatus(1)=2 - closing tick of the a bar
BarStatus(1)=1 - a tick within a bar
BarStatus(1)=0 - opening tick of a bar
There are instances where I want to update my variables within a bar, the example I qoted is just for demonstration purpose only to show barstatus bug.
Try out the strategy I have posed in my first thread and one without barstatus(1)=1 and you will see the difference.Super
We agree on the definition. I don't understand how your example exposes a bug. Could you explain what it does. It looks to me that your statement should be executed on every tick inside the bar.
J~
i.e, Input: Length(10);
Buy Next Bar at HighestFC(C,Length) + 1 Point Stop;
SetExitOnClose;
- Marina Pashkova
- Posts: 2758
- Joined: 27 Jul 2007