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

Sometimes Order Not Closign in Strategy Analyzer

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

    Sometimes Order Not Closign in Strategy Analyzer

    Hi When i run strategy in market replay everything closes alright. However when in strategy analyzer sometimes orders dont get close and wait until session close. How can this be prevented?


    Click image for larger version

Name:	image.png
Views:	122
Size:	900.6 KB
ID:	1258150

    #2
    Hello, thanks for writing in. The order may be missed due to lack of intrabar grainularity. We have a guide and an example on implementing this here:




    Also, add a print() method to make sure the order is actually submitted in the historical backtests.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      So you mean add 1 tick data for better results as a secondary series? That way i can expect more accurate results in backtesting historical data?

      Comment


        #4
        You don't mention what kind of order this is (limit? market? stop market? stop limit?) and in the screenshot these are renko bars which don't necessarily represent the prices that traded during that time period - there might also be an issue there that Strategy Analyzer is making more apparent.
        Bruce DeVault
        QuantKey Trading Vendor Services
        NinjaTrader Ecosystem Vendor - QuantKey

        Comment


          #5
          Yes. Renko bars are the worst type for back testing.

          Comment


            #6
            I am intering like this and i am seeing similar with tick based too.
            EnterLong(PositionSize, "34B Long");
            ExitLongStopMarket(0, true, Position.Quantity, stopLong, "SLL", "34B Long");

            Comment


              #7
              Perhaps the order is being rejected because the price is already beyond the stopLong price. You could check if low <= stopLong and if so ExitLong() instead of placing an exit long stop market order. There are other possibilities, but given only these two lines of code that is what comes to mind.
              Bruce DeVault
              QuantKey Trading Vendor Services
              NinjaTrader Ecosystem Vendor - QuantKey

              Comment


                #8
                ok.
                Can you also advice on how i can make sure i wait 2 bars after recent take profit, stop loss or parabolic stop loss.. Am I doing it right?
                For some reason. if i enter short with parabolic stop, parabolic stop hits, then another valid signal and on next bar i open order. I want to wait at least two bars.


                && (BarsSinceExitExecution("34B Short") > 1 || BarsSinceExitExecution("34B Short") == -1)
                && (BarsSinceExitExecution("34B Long") > 1 || BarsSinceExitExecution("34B Long") == -1)

                EnterShort(PositionSize, "34B Short");
                SetParabolicStop("34B Short", CalculationMode.Ticks, ParabolilcSarSL, false, 0.02, 0.2, 0.02);​

                Last edited by tkaboris; 06-29-2023, 08:29 AM.

                Comment


                  #9
                  HI i am adding AddDataSeries(Data.BarsPeriodType.Tick, 1);
                  ​for more accurate backtesting and following above example that was posted in #2Forum
                  So i added that tick data and my entry is
                  EnterLong(PositionSize, "StochFL");


                  if(stopLong <= bid){
                  ExitLongStopMarket(0, true, Position.Quantity, stopLong, "SLL", "StochFL");
                  ExitLongLimit(0, true, Position.Quantity, Position.AveragePrice + (TickSize * tpByATR), "PTL", "StochFL");
                  }

                  However I am still getting many orders that dont get TP or SL set in strategy analyzer... What else can i check?

                  ​​​Click image for larger version

Name:	image.png
Views:	99
Size:	49.2 KB
ID:	1259097

                  Comment


                    #10
                    ok i changed some of the entries

                    else if (State == State.Configure)
                    {
                    Calculate = Calculate.OnPriceChange;
                    AddDataSeries(Data.BarsPeriodType.Tick, 1);
                    }​
                    TickReplay is enabled

                    if (UseParabolicStop){
                    SetParabolicStop("StochFS", CalculationMode.Ticks, ParabolilcSarSL, false, Acc, AccStep, AccMax);
                    }
                    EnterShort(PositionSize, "StochFS");​


                    I still get this unfulifled stops in strategy analyzer


                    Also i understand that If i choose rather regular stoploss i need to change from 0 to 1.
                    if(stopShort >= ask){
                    ExitShortStopMarket(1, true, Position.Quantity, stopShort, "SLS", "StochFS");
                    ExitShortLimit(1, true, Position.Quantity, Position.AveragePrice - (TickSize * tpByATR), "PTS", "StochFS");
                    }​
                    Click image for larger version

Name:	image.png
Views:	112
Size:	61.5 KB
ID:	1259110

                    Comment


                      #11
                      NinjaTrader_ChrisL I entered short with
                      if(ParabolilcSarSL >= ask){
                      SetParabolicStop("StochFS", CalculationMode.Ticks, ParabolilcSarSL, false, Acc, AccStep, AccMax);
                      EnterShort(PositionSize, "StochFS");
                      }​

                      its strategy analyzer with tick data. Parabolic stop loss didnt trigger. My longs seem to work ok but short parabolic is not
                      Click image for larger version  Name:	image.png Views:	0 Size:	655.7 KB ID:	1259145Click image for larger version  Name:	image.png Views:	0 Size:	735.9 KB ID:	1259144
                      Last edited by tkaboris; 07-06-2023, 08:21 AM.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by futtrader, 04-21-2024, 01:50 AM
                      4 responses
                      41 views
                      0 likes
                      Last Post futtrader  
                      Started by Option Whisperer, Today, 09:55 AM
                      1 response
                      11 views
                      0 likes
                      Last Post bltdavid  
                      Started by port119, Today, 02:43 PM
                      0 responses
                      3 views
                      0 likes
                      Last Post port119
                      by port119
                       
                      Started by Philippe56140, Today, 02:35 PM
                      0 responses
                      4 views
                      0 likes
                      Last Post Philippe56140  
                      Started by 00nevest, Today, 02:27 PM
                      0 responses
                      2 views
                      0 likes
                      Last Post 00nevest  
                      Working...
                      X