this may be a very easy question, but I've spent the last 3 hours trying to figure out how to get a count of the total bars since open.
i'm during 1 min chart, so for example:
start of trading session = 9:30
at 9:45 the total bars should be 15
at 10:00 the total bars should be 30..etc..etc..
any help would be greatly appreciated.
PowerLanguage question. Total bars since open
- ABC
- Posts: 723
- Joined: 16 Dec 2006
- Location: www.abctradinggroup.com
- Has thanked: 125 times
- Been thanked: 410 times
- Contact:
stockmacd,
you can realize this with a counter you have to reset once before your new session begins.
In case "MyBarNumber" and "MyBarCounter" are variables, you can do the following:
A second idea would be to store the CurrentBar value on the session start into a variable and substract it from the current CurrentBar value, to get the number of bars from session start to the most recent bar.
Best regards,
ABC
you can realize this with a counter you have to reset once before your new session begins.
In case "MyBarNumber" and "MyBarCounter" are variables, you can do the following:
Code: Select all
If CurrentBar <> MyBarNumber then begin
MyBarNumber = CurrentBar;
MyBarCounter = MyBarCounter + 1;
end;
Best regards,
ABC
- RobotMan
- Posts: 375
- Joined: 12 Jul 2006
- Location: Los Altos, California, USA
- Has thanked: 31 times
- Been thanked: 13 times
- Contact:
Code: Select all
// Function: bpBSS (Bars Since Start)
If time>=Sess2StartTime and time<=Sess2EndTime then BEGIN
bpBSS = bpBSS[1] + 1;
end Else bpBSS = 0;
I've tried both solutions, but it's not working. I must be doing something wrong.
vars:barcounter(0) ;
If time>=Sess1StartTime and time<=Sess1EndTime then BEGIN
barcounter= barcounter[1] + 1;
end Else barcounter= 0;
print(TimeToString(time) + " count=" + NumToStr(barcounter,0));
output:
12:00:00 AM count=1
12:00:00 AM count=2
12:00:00 AM count=3
12:00:00 AM count=4
12:00:00 AM count=5
12:00:00 AM count=6
12:00:00 AM count=7
12:00:00 AM count=8
12:00:00 AM count=9
12:00:00 AM count=10
12:00:00 AM count=11
12:00:00 AM count=12
.......... keeps on going and going. It looks like "time" is always outputed as 12:00 am. Do I need to change a setting in quotemanager?
vars:barcounter(0) ;
If time>=Sess1StartTime and time<=Sess1EndTime then BEGIN
barcounter= barcounter[1] + 1;
end Else barcounter= 0;
print(TimeToString(time) + " count=" + NumToStr(barcounter,0));
output:
12:00:00 AM count=1
12:00:00 AM count=2
12:00:00 AM count=3
12:00:00 AM count=4
12:00:00 AM count=5
12:00:00 AM count=6
12:00:00 AM count=7
12:00:00 AM count=8
12:00:00 AM count=9
12:00:00 AM count=10
12:00:00 AM count=11
12:00:00 AM count=12
.......... keeps on going and going. It looks like "time" is always outputed as 12:00 am. Do I need to change a setting in quotemanager?
- RobotMan
- Posts: 375
- Joined: 12 Jul 2006
- Location: Los Altos, California, USA
- Has thanked: 31 times
- Been thanked: 13 times
- Contact:
Sorry, I trade emini and wrote for globex 24 hour.
For US stock, try this:
----------------------------------------------------------------
// Function: bpBSSstk
bpBSSstk = IFF(time=sess1firstbartime,1,bpBSSstk + 1);
----------------------------------------------------------------
To check; go to chart and "insert study..." / ""Custom 1 Line""
Formula: bpBSSstk
See Attached.
Bob Perry
Los Altos,CA
For US stock, try this:
----------------------------------------------------------------
// Function: bpBSSstk
bpBSSstk = IFF(time=sess1firstbartime,1,bpBSSstk + 1);
----------------------------------------------------------------
To check; go to chart and "insert study..." / ""Custom 1 Line""
Formula: bpBSSstk
See Attached.
Bob Perry
Los Altos,CA
- Attachments
-
- Goog1min.jpg
- (76.82 KiB) Downloaded 1052 times