Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Compare bar time to session end time

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Compare bar time to session end time

    I am trying to not submit an order at the end of a trading session time (which is set in the strategy Time Frame parameter list). I tried the following if statement but received an error that said I could not compare the two. How would I do this?

    if (ToTime(Time[0]) == Bars.SessionEnd.TimeOfDay)

    #2
    Code:
    if (ToTime(Time[0]) == ToTime(Bars.SessionEnd))
    You may also find this reference sample useful for what you are trying to do: http://www.ninjatrader-support.com/v...ead.php?t=3226
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hi,
      I tried implementing the code you mentioned above but am getting the following error:

      'NinjaTrader.Data.Bars' does not contain a definition for 'SessionEnd' and no extension method 'SessionEnd' accepting a first argument of type 'NinjaTrader.Data.Bars' could be found (are you missing a using directive or an assembly reference?)

      Can you please advise? I would like to be able to have my system stop trading before end of day. (Dont want to use 4pm comparison as some sessions end earlier)
      Thx

      Comment


        #4
        nightriderx, are you attempting to work with this snippet in 6.5 or 7?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          with NT7
          thx!

          Comment


            #6
            Ok, for NT7 please use this revised method of accessing the session begin / end times of the applied session template you're using -

            http://www.ninjatrader.com/support/h...xtbeginend.htm
            BertrandNinjaTrader Customer Service

            Comment


              #7
              With respect, Bertrand, y'all need to correct that link. I've been told that NT7 should not use Bars.SessionBreak but should use Bars.FirstBarOfSession instead.

              Comment


                #8
                Lost Trader,

                It has already been corrected for the next Help Guide version.
                Josh P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by DayneSwift, Yesterday, 11:06 PM
                0 responses
                2 views
                0 likes
                Last Post DayneSwift  
                Started by AidanLawrence, Yesterday, 10:03 PM
                0 responses
                2 views
                0 likes
                Last Post AidanLawrence  
                Started by butt_toast, Yesterday, 09:47 PM
                0 responses
                2 views
                0 likes
                Last Post butt_toast  
                Started by GaryOz, Yesterday, 06:54 PM
                0 responses
                4 views
                0 likes
                Last Post GaryOz
                by GaryOz
                 
                Started by 2inthebush, Yesterday, 06:27 PM
                0 responses
                22 views
                0 likes
                Last Post 2inthebush  
                Working...
                X