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

Break even after price advancement

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

    #16
    Hello,

    Thanks for your reply.

    Can you clarify how you are testing this (market replay, strategy backtest) and what your strategy settings are for exit on close and time in force?
    Paul H.NinjaTrader Customer Service

    Comment


      #17
      Testing with market replay. Some days I have no position in the end of the day, so next session strategy entering long/short in the first few bars without problems. However when the position is closed on exit(standard 30 seconds before the close), the next day its limited by the rules: no entry for 10 bars after the last exit.

      P.S. I think I can use BarsSinceExit<Bars.BarsSinceSession ?

      Originally posted by NinjaTrader_Paul View Post
      Hello,

      Thanks for your reply.

      Can you clarify how you are testing this (market replay, strategy backtest) and what your strategy settings are for exit on close and time in force?
      Last edited by meowflying; 03-06-2015, 06:05 AM.

      Comment


        #18
        Hello,

        Thanks for your reply.

        Yes, you could use Bars.BarsSinceSession , continuing in your example:

        (BarsSinceExit("long") > 10 || BarsSinceExit("long") == -1) || Bars.BarsSinceSession < 10) && (BarsSinceExit("long1") > 10 || BarsSinceExit("long1") == -1 || Bars.BarsSinceSession < 10)
        Paul H.NinjaTrader Customer Service

        Comment


          #19
          Originally posted by NinjaTrader_Paul View Post
          Hello,

          Thanks for your reply.

          Yes, you could use Bars.BarsSinceSession , continuing in your example:

          (BarsSinceExit("long") > 10 || BarsSinceExit("long") == -1) || Bars.BarsSinceSession < 10) && (BarsSinceExit("long1") > 10 || BarsSinceExit("long1") == -1 || Bars.BarsSinceSession < 10)
          Bars.BarsSinceSession < 10 Will work only for the initial entry within first bars of the session, but will prevent all further entries.

          I need some like that:

          (BarsSinceExit < Bars.BarsSinceSession)

          But it gives me error in compilation:

          Operator "<" cannot be applied to operands of type 'method group' and 'int'

          Comment


            #20
            Hello,

            Thanks for your reply.

            The statement:

            (BarsSinceExit("long") > 10 || BarsSinceExit("long") == -1) || Bars.BarsSinceSession < 10) says that if any of the 3 conditions are true to execute the code after the statement.

            BarsSinceExit("long") > 10 will be true after 10 bars after the last exit
            BarsSinceExit("long") == -1) will be true before there are any entries
            Bars.BarsSinceSession < 10 will be true for the first 9 bars of the new session

            The issue previously advised was that entry conditions in the first 10 bars of a new session were being ignored because of BarsSinceExit("long") > 10 so to get past that issue the OR code of || Bars.BarsSinceSession < 10 was added.

            Taking the case of an exit at the last bar of the session, the code BarsSinceExit("long") > 10 would prevent placing a new order for 10 bars, however as it is a new session on the next bar, the code || Bars.BarsSinceSession < 10 would permit the entry.

            Later after the first 10 bars, you are correct that || Bars.BarsSinceSession < 10 by itself would inhibit further orders however 10 bars after the first exit BarsSinceExit("long") > 10 would be true allowing the next order to occur.
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Haiasi, Today, 06:53 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by ScottWalsh, Today, 06:52 PM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by ScottW, Today, 06:09 PM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by ftsc2022, 10-25-2022, 12:03 PM
            5 responses
            256 views
            0 likes
            Last Post KeyonMatthews  
            Started by Board game geek, 10-29-2023, 12:00 PM
            14 responses
            244 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Working...
            X