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

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.

        Kate W.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Patlpp, 08-16-2021, 03:10 PM
        10 responses
        498 views
        0 likes
        Last Post Joerg
        by Joerg
         
        Started by AdamDJ8, 05-07-2024, 09:18 PM
        2 responses
        17 views
        0 likes
        Last Post -=Edge=-  
        Started by StockTrader88, 03-06-2021, 08:58 AM
        46 responses
        4,101 views
        3 likes
        Last Post tradgrad  
        Started by usasugardefender, Today, 01:42 AM
        0 responses
        1 view
        0 likes
        Last Post usasugardefender  
        Started by haas88, 03-21-2024, 02:22 AM
        15 responses
        182 views
        0 likes
        Last Post haas88
        by haas88
         
        Working...
        X