Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Trading on open of session based on last candle of prior session

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

    Trading on open of session based on last candle of prior session

    Hi,

    I currently use two parameters, StartHour and EndHour to specify when I want trades to occur using hourly candles. Say I am looking at trades in FX which close for an hour at 22:00 until 23:00 GMT. However I seem to run into a problem when I want trades to occur at 23:00 (that is the opening price of the 00:00 candle, the candle that starts at 23:00 and end at 00:00). No matter what I set my parameters to I can't get trades to occur at this time. OnBarUpdate prints hourly updates at 21:00 then 22:00 and then 00:00 as expected, however my trade signal generated at the close of the 22:00 candle is not actioned on the open of the next candle that being at 23:00, the opening time of my 00:00 candle. What am I doing wrong here?

    Thanks,
    darmbk.

    #2
    Hi darmbk,

    Are the prints you are getting inside of the same branching action block that the order submission is in? (inside the same condition statement)

    What is the if statement you are using to determine when to trade?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      The entry occurs within an if statement at the start of OnBarUpdate that checks for a trigger variable (which for now I have set to always want to trade) and a test to see if we are already trading in the direction of the triggered trade. However, regardless of the direction the new trade should be, it does not show up.

      Here is an example of the the output:

      At the close of the 21:00 candle a trigger is calculated, regardless of the trigger the last position is closed, then if the trigger is good a new trade is entered. The close and new open are shown at the starting price of the 22:00 candle, i.e. at 21:00 as you would expect. Then the close of the session comes along at the end of the 22:00 candle. Again a trigger is calculated, then the existing order is deleted BUT this time it is shows up as an exit at the close of the session on the 22:00 candle (rather than at the start of the next candle based on the strategies explicit exit criteria) because there is no next candle AND finally there is no entry carried out at the start of the 00:00 candle which is at 23:00 even though the trigger was good.

      09/01/2009 21:00:00
      09/01/2009 21:00:00 Trigger 7.464
      09/01/2009 21:00:00 OnExecution: Close position
      09/01/2009 21:00:00 Exit: Close position
      09/01/2009 21:00:00 Close: Close position @ 1.3397
      09/01/2009 21:00:00 Result: 2 ticks
      09/01/2009 21:00:00 OnExecution: MyEntry
      09/01/2009 21:00:00 Open: MyEntry Short @ 1.3397
      09/01/2009 22:00:00
      09/01/2009 22:00:00 Trigger 0.002
      09/01/2009 22:00:00 OnExecution: Exit on close
      09/01/2009 22:00:00 Exit: Exit on close
      09/01/2009 22:00:00 Close: Exit on close @ 1.3431
      09/01/2009 22:00:00 Result: -34 ticks
      12/01/2009 00:00:00

      Comment


        #4
        Hi darmbk,

        Are the print and the entry submission in the same if statement?

        What code are you using?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Can I PM you the code?

          I've added a few more print statements. What I see is that on the last candle of the session, the code still thinks there is a short position even though NT is closing the position at the end of the session for me (note the missing Short Signalled and no current short trade so Enter Short at 22:00)

          09/01/2009 21:00:00
          09/01/2009 21:00:00 Trigger 7.464

          09/01/2009 21:00:00 Short Signalled
          09/01/2009 21:00:00 Short Signalled and no current short trade so Enter Short

          09/01/2009 21:00:00 OnExecution: Close position
          09/01/2009 21:00:00 Exit: Close position
          09/01/2009 21:00:00 Close: Close position @ 1.3397
          09/01/2009 21:00:00 Result: 2 ticks
          09/01/2009 21:00:00 OnExecution: MyEntry
          09/01/2009 21:00:00 Open: MyEntry Short @ 1.3397
          09/01/2009 22:00:00
          09/01/2009 22:00:00 Trigger 0.002

          09/01/2009 22:00:00 Short Signalled

          09/01/2009 22:00:00 OnExecution: Exit on close
          09/01/2009 22:00:00 Exit: Exit on close
          09/01/2009 22:00:00 Close: Exit on close @ 1.3431
          09/01/2009 22:00:00 Result: -34 ticks

          Comment


            #6
            Hi darmbk,

            Please send an email to support [at] ninjatrader [dot] com. In the body of the email please add a link to this thread.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Brevo, Today, 01:45 AM
            0 responses
            2 views
            0 likes
            Last Post Brevo
            by Brevo
             
            Started by aussugardefender, Today, 01:07 AM
            0 responses
            3 views
            0 likes
            Last Post aussugardefender  
            Started by pvincent, 06-23-2022, 12:53 PM
            14 responses
            238 views
            0 likes
            Last Post Nyman
            by Nyman
             
            Started by TraderG23, 12-08-2023, 07:56 AM
            9 responses
            384 views
            1 like
            Last Post Gavini
            by Gavini
             
            Started by oviejo, Today, 12:28 AM
            0 responses
            4 views
            0 likes
            Last Post oviejo
            by oviejo
             
            Working...
            X