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

Entering Trade on Signal Bar

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

    Entering Trade on Signal Bar

    Hi, I'm trying to backtest a strategy that enters longs when the low of the current bar crosses a moving average calculated from the lows of the series. However whenever the long gets triggered the strategy enters on the open of the next bar. Is there any way to have the strategy enter the longs at the price where it is crossing the moving average durring backtesting? Also, if running the strategy live in its current form would it behave the same way, only entering on the next bar?

    #2
    Hello,

    This is because the criteria has to be met before the execution can be made. There is no way around this in backtesting.

    If you are trading live or forward testing the execution will happen when the criteria is met (interbar if you have CalculateOnBarClose = false).
    DenNinjaTrader Customer Service

    Comment


      #3
      Ok, I'm testing out the strategy in live sim mode with updateonclose = false and the strat enters the trade when the price pierces the moving average. However I'm encounter a different problem now with the stops. In backtesting I have a breakeven stop that goes in effect when the Low[0] goes higher then breakeven on a long. But now in live sim mode what appears to be happening is that if the new bar opens above the breakeven then the stop goes into effect immediately, triggering if the low of that bar hits the stop.

      I'm guessing that since i'm not using updateonclose I need to set the stop when Low[1] goes above breakeven?

      Comment


        #4
        Correct darckeen, with CalculateOnBarClose set to false you also process your stop logic intrabar or on every incoming tick.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Ok, that appears to be working now I'm having a new problem. When I enter the trade the system is looking back at the previous bar but if the low from that bar is above my breakeven then the stop triggers immediately on the signal bar resulting in multiple entries and stop outs. Is there someway I can determine how many bars the trade has been in to filter out this effect?

          Comment


            #6
            Please use BarsSinceEntry() to do this filtering.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by mmenigma, Today, 02:22 PM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by frankthearm, Today, 09:08 AM
            9 responses
            35 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by NRITV, Today, 01:15 PM
            2 responses
            9 views
            0 likes
            Last Post NRITV
            by NRITV
             
            Started by maybeimnotrader, Yesterday, 05:46 PM
            5 responses
            26 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by quantismo, Yesterday, 05:13 PM
            2 responses
            21 views
            0 likes
            Last Post quantismo  
            Working...
            X