3 different session times

Forums ProRealTime English forum ProOrder support 3 different session times

Viewing 13 posts - 1 through 13 (of 13 total)
  • #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

     

    #28817

    I suggest you create an indicator that returns, 1 for your first set of dates, 2 for the second etc…

    Then you can visuallize if and where the problem is.

    #28938

    If 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…

     

    #28962

    Thanks 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
    endif

    IF Date=20170316 OR Date=20170310 THEN
    SessionEnd=110000
    ENDIF

     

    IF Time>081000 AND Time<SessionEnd THEN
    BUY 1 PERPOINT AT MARKET
    ENDIF

    #28965

    Yes, 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?

    #28968

    Yes, 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!

    #28972

    ok, 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.

    #28978

    ok 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:

     

    and it works only with one… intriguing and irritating

    #28984

    I 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

    #29012

    I think I finally managed it

     

    Date1=20170316
    Date2=20170310

    Time1=110000
    IF (Date=Date1 AND Time>Time1) OR (Date=Date2 AND Time>Time1) THEN
    Tradeallowed=0
    ENDIF

    So 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.
    #29392

    Well 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?

    #32358

    I was using the same code in my systems:
    if date=yyyymmdd or date=yyyymmdd then
    set variable
    endif

    This 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.

    #51209

    Thanks, verygrubby!

    That’s the workaround I was looking for!

Viewing 13 posts - 1 through 13 (of 13 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login