Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Real-time BarsSinceEntry() and daily bars

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

    Real-time BarsSinceEntry() and daily bars

    Hi,

    I have a small account and need to avoid being flagged as a PDT by IB. I have set my exits to BarsSinceEntry() >= 1, however I also have COBC = false. I should only exit after the session has closed and a new session has begun (at the earliest).

    If I set BarsSinceEntry() >= 1 and have daily bars with intraday granularity will that be enough to ensure that I don't make trades intraday? Or, should the value be set to at least BarsSinceEntry() >= 2?

    Regards,
    Henrik

    #2
    Hello don_janeiro,

    Thanks for opening the thread.

    You should be able to use BarsSinceEntry() to determine if a certain data series has iterated a bar if you use the proper overload for Multi-series NinjaScripts. If you do not use the proper overload, BarsSinceEntry() will only give you the bars iterated from the primary data series.

    The following method signature should be used when working with multi-time frame and instrument strategies:

    BarsSinceEntry(int barsInProgressIndex, string signalName, int entriesAgo)

    Note: When working with a multi-series strategy the BarsSinceEntry() will return you the elapsed bars as determined by the first Bars object for the instrument specified by the barsInProgressIndex.


    However, if you are using COBC = false, OnBarUpdate() will be called for each tick and you may be making additional entries.

    You may also wish to use IsFirstTickOfBar with a BarsInProgress condition to check if the daily series has iterated a bar. Such an additional condition can prevent trades from being placed intraday with COBC = false.

    Please see the documentation below for implementation:

    FirstTickOfBar - https://ninjatrader.com/support/help...ttickofbar.htm

    BarsInProgress - https://ninjatrader.com/support/help...inprogress.htm

    Please let me know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you for the answer!

      To elaborate, I want the fine grained intraday capability of posting limit orders during the busiest trading times of the day and then exiting at the earliest on the next session, ie. I do not want to take intraday trades. However, when I do exit I want to be able to finely tune the time of day this exit takes place (mostly during the evening session). Therefore, if I add FirstTickOfBar I assume for each daily bar that it will:

      1) Fire once
      2) It will fire on the first tick of the new bar (which for daily bars will/should be at the open and might not work for the strategy)

      Would I be better off just using DateTime- logic to compare the latest entry to the current timestamp (given that I want the exit to be placed at certain times of the day)?

      Comment


        #4
        Hello don_janeiro,

        Thanks for the reply.

        Time based logic may work as a good alternative. Since you are using COBC = false, you can use the finer per tick granularity to submit orders at more accurate times.

        You may wish to record the timestamp of the order fill within OnExecution(). We have a sample strategy that demonstrates how to use OnExecution() and OnOrderUpdate() to place protective orders. I will provide a link below:

        The OnOrderUpdate() and OnExecution() methods are reserved for experienced programmers. Instead of using Set() methods to submit stop-loss and profit target orders, you can submit and update them manually through the use of IOrder and IExecution objects in the OnOrderUpdate() and OnExecution() methods. The OnOrderUpdate()


        Please let me know if you have any additional questions.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Barry Milan, Yesterday, 10:35 PM
        5 responses
        16 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by DanielSanMartin, Yesterday, 02:37 PM
        2 responses
        13 views
        0 likes
        Last Post DanielSanMartin  
        Started by DJ888, 04-16-2024, 06:09 PM
        4 responses
        13 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by terofs, Today, 04:18 PM
        0 responses
        12 views
        0 likes
        Last Post terofs
        by terofs
         
        Started by nandhumca, Today, 03:41 PM
        0 responses
        8 views
        0 likes
        Last Post nandhumca  
        Working...
        X