Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Placing trade at open

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

    Placing trade at open

    I've written some code that places a trade at the start of the day trade for the CME S&P eminis.

    So if i for some reason decided that I wanted to enter a long trade at the start of each wednesday I would write something like this.

    if(Bars.FirstBarOfSession){
    if (Time[0].DayOfWeek == DayOfWeek.Wednesday){
    EnterLong(NuContracts, "Wednesday_LE");
    }
    }

    However I tested this out this morning on a 5 minute bar chart that had a starting time of 8:30am and closing time of 3:15pm. It placed the trade as soon it ticked but it entered at market, thus getting in a tick worse than open. Is there a way to assure that the trade will get in at the days opening price?

    If there is no way around this then is there away to have it adjust the profit point should it not enter at open? I want it to set a profit target of 1.25 from the days open.

    #2
    Your code is not made to trade at open. Your code only works after it receives the first tick and sees all the information before it can process. If you want to submit an order at open you needed to place it on the bar before this even happened.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      So how would I do this? Would i set the first if condition to fire at a specific time? Or would i have to adjust the start time of the chart? If it is the start time then I must note that I must use 5 minute bars for another portion of my code to work properly.

      Comment


        #4
        You just need to get the order to the market before the market opens. Right now you are submitting your order after the market opens. If you do CalculateOnBarClose = true instead of false, just submit the order on the last bar of the prior session. That will get you in around the open of the next bar.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by funk10101, Today, 12:02 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by GLFX005, Today, 03:23 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by nandhumca, Yesterday, 03:41 PM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by The_Sec, Yesterday, 03:37 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by vecnopus, Today, 06:15 AM
        0 responses
        1 view
        0 likes
        Last Post vecnopus  
        Working...
        X