3 different session times
Forums › ProRealTime English forum › ProOrder support › 3 different session times
- This topic has 12 replies, 5 voices, and was last updated 6 years ago by namrevlis24.
-
-
03/16/2017 at 10:39 PM #28815
Hello all,
Im trying to get different session end times for different sets of dates, but I just can’t get it to work properly.
I want to stop trading at specific times for certain specific dates, and for the other (non-specific) dates, stop trading at 14.15pm….I’ve tried it all different ways, but it just isn’t working 100% of the time – some of the session times are being applied as required, but others aren’t… below is my latest try…the “SessionEnd” is used later in the code when deciding whether or not its ok to enter a trade… Any ideas why this doesn’t work?!
many thanks
12345678910111213141516//for these dates, stop trading at 11.59amIF Date=20170316 OR Date=20170202 OR Date=20161215 THENSessionEnd =115900ENDIF//for these dates, stop trading at 13.29pmIF Date=20170310 OR date=20170203 THENSessionEnd =132900ENDIF//for all other dates, stop trading at 14.15pmIF Date<>20170316 AND Date<>20170202 AND Date<>20161215 AND Date<>20170310 AND Date<>20170203 THENSessionEnd =141500ENDIF03/16/2017 at 11:26 PM #2881703/17/2017 at 2:34 PM #28938If I had to play a guessing game, without knowing key information like the rest of the code to see how “sessionend” is used or the timeframe you run it with, one likely hypothesis would be that you might be running your code in a timeframe not compatible with your selected end session times, because in case you have a line later in the part of the code not displayed like “if time=sessionend then…”, then 11h59mn and 13h29mn would work only for 1mn timeframe, but not 5mn or 30mn or 1h etc… as the time of candle close would never be equal to such xxhx9 values for some timeframes…
03/17/2017 at 4:36 PM #28962Thanks for those suggestions…
Im using a 1 minute chart, and have given up on trying to get 3 different session end times to work. Now I just want 2 session times. A default one, and one for a subset of dates. Below is what I tried. It works for 2 dates – i.e. the new session end time of 11am is applied for these 2 dates, but if I try to add any more dates to this IF statement, it doesn’t work – it ignores the 11am session end for the 3rd, 4th, etc dates…
Do “IF… OR” statements only work with 2 items?
Many thanks
// reset the session end time each new day
If intradaybarindex=0 then
SessionEnd=141500
endifIF Date=20170316 OR Date=20170310 THEN
SessionEnd=110000
ENDIFIF Time>081000 AND Time<SessionEnd THEN
BUY 1 PERPOINT AT MARKET
ENDIF03/17/2017 at 5:51 PM #28965Yes, if statements should be able to run with more than 2 items when using “or”
Looks like a backtest that will accumulate orders and stop too soon, preventing from checking “session end” dates beyond backtest end point…
Does your backtest end between dates when it works and dates when it doesn’t? (like attached example ran from your code on french index and “session end” stopped being displayed as soon as 9h07 on day one). Or is there more to the code that allows to really run on all the dates?
03/17/2017 at 5:59 PM #28968Yes, there’s a whole bunch of conditions and other variables. So each day might have any number of trades, but I want trades to stop at 11am for a list of dates (& 14.15pm on all other dates). Everything works fine but the altered session end only seems to work for a maximum 1 or 2 dates in that IF statement. Any more dates than that, and it just uses the default session end.
Irritating as it seems quite a simple concept!
03/17/2017 at 6:21 PM #28972ok, well “if” statements do work with more than 2 items, so the bug is most likely in the lines we don’t see. I can understand sometimes people want to keep pieces of code secret, that’s not a problem for me, but sorry can’t help if the bug is in the hidden part rather than the showed part. Sometimes a bug is hard to find with the whole code, it’s even harder without it. Good luck and good trades.
03/17/2017 at 7:16 PM #28978ok I tried with one my codes in order to:
a) be able to backtest it over several days so that the if statement date conditions are met
b) rule out it could be from the hidden part of your code
and I face the same problem as you, so it’s something to do with a limitation of if and dates? Intriguing and as you say irritating
Even worse, I tried with 2 separate “if” statement:
123456IF Date=20170310 THENSessionEnd=110000ENDIFIF Date=20170316 THENSessionEnd=110000ENDIFand it works only with one… intriguing and irritating
03/17/2017 at 8:25 PM #28984I know! I tried all different combinations and ways of saying the same thing. Always the same result.
can you think of a different way to achieve what I’m after?
cheers
03/18/2017 at 9:23 AM #29012I think I finally managed it
Date1=20170316
Date2=20170310Time1=110000
IF (Date=Date1 AND Time>Time1) OR (Date=Date2 AND Time>Time1) THEN
Tradeallowed=0
ENDIFSo I can have as many Dates & Times (Session ends) as i Like.
Then I have a condition that Tradeallowed must be 1 in order to trade.
IT SEEMS TO WORK!!!
3 users thanked author for this post.
03/22/2017 at 7:52 AM #29392Well done if that works, I tried other combinations too with other keywords like opendate but ended up facing the same obstacle. And that was with using “graph” function to check it does everything it was supposed to do, and checking if possible lack of 1 mn candle at 1am for some days on cfd day change had anything to do with it, while intradaybarindex starts at midnight and so might have messed with logic used in if statements, but it wasn’t the issue either.
I can’t see why it didn’t work. If you have found a workaround that you’re happy with then at least this is not holding you back anymore, but I’ve got to say this one remains puzzling. Nicolas if you’re reading this topic, did this ever happen to you too?
04/17/2017 at 8:28 PM #32358I was using the same code in my systems:
if date=yyyymmdd or date=yyyymmdd then
set variable
endifThis seemed to work for me but today I found out by accident that my system was trading on easter Monday (I trade with IG), one of the dates I had ruled out. It seems the if date statement does not work well with multiple dates using “or”.
The workaround verygrubby posted using date1 and date2 variables works. Why however remains puzzling like Noobywan noted.
11/01/2017 at 2:53 PM #51209Thanks, verygrubby!
That’s the workaround I was looking for!
-
AuthorPosts
Find exclusive trading pro-tools on