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

Placing an order before the end of a bar

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

    Placing an order before the end of a bar

    I tried finding this information on the Support Forum but haven't been able to find it. If these questions have already been answered, please point me in the right direction.

    I am writing a strategy that trades Equities and uses 2 time frames, LTF (Lower Time Frame) and HTF( Higher Time Frame). The LTF will always be in minutes (5 min, 15 min, etc). The HTF may be in minutes (30, 60, 120 etc). It can also be daily, weekly or monthly.

    The entry/exit decisions are done at the end of the HTF bar. Market Orders are placed for the open of the next bar. For backtesting this is not an issue. However for Real Time Trading, at the end of the day (even if the HTF is in minutes), I want to place the trade before the end of the day. I don't want to place a market order for the open of the next day. I have a few questions

    1) Is there a way for the strategy to determine, in real time, that the current time is x minutes or y seconds from the end of the current trading day?

    2) Will this method "know" if "today" is a short trading day

    3) If using weekly or monthly bars on the HTF, is there a way to determine if "today" the current day, is the end of the week or end of the month?

    #2
    Hello krofs,


    Thank you for the post.


    1) Is there a way for the strategy to determine, in real time, that the current time is x minutes or y seconds from the end of the current trading day?
    Generally, the SessionIterator object is used for any session related information, you can find the session times using this object which could then be compared against the processing series time:




    2) Will this method "know" if "today" is a short trading day
    Only if you add this type of logic, the concept of a short trading day only relates to your strategies logic and it detecting it to be a short trading day.

    3) If using weekly or monthly bars on the HTF, is there a way to determine if "today" the current day, is the end of the week or end of the month?
    You can do various comparisons with the DateTime objects, this will depend on what you mean by "Today". Do you mean the time from one of the secondary series or would this be the higher timeframe?

    If you mean the lower timeframe series, you can use its Time object to determine where in time that BarsInProgress currently is. If you mean at the time of the bar close for the higher time frame, the Times reported on that call would only be intervals of the series, so 1 week, month interval timestamps. The lower time frames would have more granular timestamps or you could also use the OnMarketData override to get the last ticks time. Again this depends on which series you are referring to here, I could suggest using Prints in your script and Print the timestamps as it processes to get an idea of the processing it takes.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you, I'll give it a try

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Waxavi, Today, 02:10 AM
      0 responses
      6 views
      0 likes
      Last Post Waxavi
      by Waxavi
       
      Started by TradeForge, Today, 02:09 AM
      0 responses
      11 views
      0 likes
      Last Post TradeForge  
      Started by Waxavi, Today, 02:00 AM
      0 responses
      2 views
      0 likes
      Last Post Waxavi
      by Waxavi
       
      Started by elirion, Today, 01:36 AM
      0 responses
      4 views
      0 likes
      Last Post elirion
      by elirion
       
      Started by gentlebenthebear, Today, 01:30 AM
      0 responses
      5 views
      0 likes
      Last Post gentlebenthebear  
      Working...
      X