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 AaronKoRn, Today, 09:49 PM
        0 responses
        2 views
        0 likes
        Last Post AaronKoRn  
        Started by carnitron, Today, 08:42 PM
        0 responses
        8 views
        0 likes
        Last Post carnitron  
        Started by strategist007, Today, 07:51 PM
        0 responses
        9 views
        0 likes
        Last Post strategist007  
        Started by StockTrader88, 03-06-2021, 08:58 AM
        44 responses
        3,975 views
        3 likes
        Last Post jhudas88  
        Started by rbeckmann05, Today, 06:48 PM
        0 responses
        9 views
        0 likes
        Last Post rbeckmann05  
        Working...
        X