hi,
i need to find last bar in the trading day :
if i use date<>date[1] is not correct because i receive information after 1 bar...i want to know it the last day bar
Example:
i setting dax futures open 8.00 close 22.00 all days
last bar day is 2200!
I need to know the information at the 2200 clock
last bar day
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
Re: last bar day
Go to the Wiki,
See : 8 PowerLanguage Keyword Reference
Look under : Sessions (18 P)
See : 8 PowerLanguage Keyword Reference
Look under : Sessions (18 P)
Re: last bar day
if i code this with instrument "Es futures"
if time=SessionEndTime(1,1) then print(date,time," End Day");
i get this output :
1191210.00 1600.00 End Day
but time 16.00 is end session and not end day
if time=SessionEndTime(1,1) then print(date,time," End Day");
i get this output :
1191210.00 1600.00 End Day
but time 16.00 is end session and not end day
- rrams
- Posts: 128
- Joined: 10 Feb 2011
- Location: USA
- Has thanked: 7 times
- Been thanked: 70 times
- Contact:
Re: last bar day
turbofib, what you are asking for is somewhat complicated. You can accomplish it with code something like this:
(I have not tested the code, so I don't know if it works.)
Unless you really know what you are doing, you should stick with just hard coding the last bar times for each symbol.
Because, for instance, the session functions can return wrong information if you use local time for your strategy and the exchange uses a different Daylight Saving Time.
I try to help as a thank you for the times that I needed help and not to prove anything.
Code: Select all
variables: dayfraction(0), nextsession(0);
switch(BarType_ex)
begin
case 2: dayfraction=BarInterval/1440; // minutes
case 3: dayfraction=BarInterval/24; // hours
case 9: dayfraction=BarInterval/86400; // seconds
default: RaiseRuntimeError("Invalid interval. Requires intraday data.");
end;
nextsession=IFF(CurrentSession(0)<SessionCount(0), CurrentSession(0)+1, 1);
if DayFromDateTime(DateTime+dayfraction)<>DayFromDateTime(DateTime) or
(SessionEndDay(0, CurrentSession(0))=DayOfWeek(Date) and SessionStartDay(0, nextsession)<>DayOfWeek(Date) and
DateTime2ELTime(DateTime+dayfraction)>=SessionEndTime(0, CurrentSession(0)))
then print("Last bar of day");
Unless you really know what you are doing, you should stick with just hard coding the last bar times for each symbol.
Because, for instance, the session functions can return wrong information if you use local time for your strategy and the exchange uses a different Daylight Saving Time.
I try to help as a thank you for the times that I needed help and not to prove anything.