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

How to buy at close

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

    How to buy at close

    Good afternoon,
    I would want to know how can I do to buy at close.
    In reality I will buy at 1 minute before close or during after hours, but I don't have intraday data and I would want to test my strategy when it buy at close and not at open of next bar.
    I can use EnterLongLimit but it's not good, I test it and it's not good.
    I can stock the close in a variable and print or write in a file, but I would prefer an other way, of course if this other way exists.

    Thank's a lot.

    #2
    Hi,

    If you're using the Kinetic Free EOD data and don't have access to intraday data, then each bar only has the Open, High, Low, Close and Volume data points to work with, and the OnBarUpdate event will only get called each time the bar is fully closed. Because of this, you won't have a way to check what the bar's price is right before closing and make an order that fills on that bar - the only possibility is to have it submit an order at the full close and get filled at the open of the following bar.

    One way to work around this would be to get an intraday data feed, and then use 1 min bars, and check for something like

    if(Time[0].Hour == 15 && Time[0].Minute == 59)
    submit a market order

    Besides that, if you can figure out a way to use variables and the output window to virtually hold trade fills, that might be the only way without having the intraday data feed as far as I can tell

    **Edit: If you want to still make your strategy based on Daily bars overall, you'd have to add the 1 minute bars as another Bars object which makes things more complex.. from then on, your OnBarUpdate() would have to have if statements to check if(BarsInProgress == 0) that's the daily bars, do the regular calculations, and if(BarsInProgress == 1) that's the 1min bars, do those calculations
    Last edited by RunnrX; 04-06-2013, 10:20 AM. Reason: adding more info

    Comment


      #3
      Hello neo-13,

      Thank you for your post.

      Using End Of Day data (as mentioned by RunnrX) will only be the Open, High, Low and Close of the Daily bar.

      To be able to buy one minute before the close you would need a smaller (intra-day) interval such as 1 minute to be able to achieve this.

      Please let me know if I may be of further assistance.

      Comment


        #4
        Thank's,
        it's same in the real time, if I use daily bar (and I choose false in CalculateOnBarClose) I can't buy one minute before the candle close?
        In others words, in real time if I want to buy just before the end of daily bar, I must use small time frame or I can use daily bar and choose false for CalculateOnBarClose?

        RunnrX,
        Thank's , I know this, I can do that I want with intraday bar, but I would want to know If it was possible with daily bar.


        Tnak's for your answers.

        Comment


          #5
          Hello neo-13,

          Thank you for your response.

          Who do you connect to for the Daily Data? If this is a End Of Day data feed you will not be able to see the incoming ticks with CalculateOnBarClose = False as the feed is EOD.

          However, if your have a real-time data feed you can use CalculateOnBarClose = False and check the time of the bar to see if it is one minute before the close of the bar.

          For example, if the session for the Daily bar closed at 4PM you could use the following:
          Code:
          if(ToTime(Time[0]) >= 35900)
          {
          //Your exit
          }
          For information on ToTime() please visit the following link: http://www.ninjatrader.com/support/h...nt7/totime.htm

          Please let me know if I may be of further assistance.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by ZeroKuhl, Today, 04:31 PM
          0 responses
          7 views
          0 likes
          Last Post ZeroKuhl  
          Started by Vulgoth_t_Destroyer, 05-09-2022, 04:45 PM
          54 responses
          5,336 views
          0 likes
          Last Post Gaterz
          by Gaterz
           
          Started by ETFVoyageur, 05-07-2024, 07:05 PM
          11 responses
          74 views
          0 likes
          Last Post -=Edge=-  
          Started by _Zero_, 04-10-2020, 03:21 PM
          145 responses
          7,900 views
          6 likes
          Last Post johng2
          by johng2
           
          Started by TheTradingMantis, 01-19-2023, 02:05 AM
          43 responses
          921 views
          0 likes
          Last Post jmagaia
          by jmagaia
           
          Working...
          X