Announcement

Collapse
No announcement yet.

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:	202
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.

    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:	146
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:	158
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 NullPointStrategies, Today, 05:17 AM
                      0 responses
                      20 views
                      0 likes
                      Last Post NullPointStrategies  
                      Started by argusthome, 03-08-2026, 10:06 AM
                      0 responses
                      119 views
                      0 likes
                      Last Post argusthome  
                      Started by NabilKhattabi, 03-06-2026, 11:18 AM
                      0 responses
                      63 views
                      0 likes
                      Last Post NabilKhattabi  
                      Started by Deep42, 03-06-2026, 12:28 AM
                      0 responses
                      41 views
                      0 likes
                      Last Post Deep42
                      by Deep42
                       
                      Started by TheRealMorford, 03-05-2026, 06:15 PM
                      0 responses
                      45 views
                      0 likes
                      Last Post TheRealMorford  
                      Working...
                      X