Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cancel EnterLongStopMarket order if no trigger in next bar

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

    #16
    Hello UltraNIX,

    Can you save the output (Save As) to a text file to provide the full output?

    I would like to see the orders placed before the error.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #17
      I found interesting thing.

      Take a look at screenshot 201015-Short - all trades are there, while 201015-Long - only 1 trade, and exit name is Strat_XLM_Session Close. When I remove the code, it works fine, and it makes 51 trades.

      That "Session close" code is here:
      Code:
       if (ToTime(Time[0]) >= 225500) // When Adjusting, be sure it matched 15:00 (or 3:00 P.M.) Chicago Time
      {
      ExitLong(Qty, "Strat_XLM_Session Close", "Strat_ELS_Long");
      ExitLong(Qty, "Strat_XLM_Session Close", "Strat_ELM_Long");
      ExitShort(Qty, "Strat_XSM_Session Close", "Strat_ESS_Short");
      ExitShort(Qty, "Strat_XSM_Session Close", "Strat_ESM_Short");
      }
      I have this for intraday trading purposes, in order to exit trades 65 minutes before session closes (my local time), in order to avoid increased margin requirements.

      Questions here are 2:
      1) What if statement should I use in order to determine, whether data series are intraday (like tick, and minute)? And if there are intraday data series - then use this 'session close' exit, if data series is daily or higher, then not.
      2) Sometimes there's no bar after 22:55:00 for some 20 minutes (local time) no bars are produced. So is there a way to exit those trades without waiting for another bar in order for OnBarUpdate method to run the code?
      Attached Files

      Comment


        #18
        Hello UltraNIX,

        Thank you for your reply.

        For your first question, you can determine if the data series is intraday by using Bars.BarsType.IsIntraday. An example of this can be found in the built in Bar Timer indicator which you can view in the NinjaScript Editor.

        As to the second question, no. If there are no incoming ticks coming in and no bars are forming, there would not be a way to exit the trades until new ticks come in.

        Please let us know if we may be of further assistance to you.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        50 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        126 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        69 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X