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

Real time behavior different from Sim

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

    Real time behavior different from Sim

    Hi all,

    hi I finally had the confidence to run my strategy in real time, in the Sim account it does not produce any error but the Real one when the operation ends either by stop or Target re-enters without an entry signal.
    Attached Files

    #2
    Hello pacoperico,

    To confirm, you are getting an error message (like a rejected order message)?

    If yes, what is the full error message? (You can Ctrl + c to copy an error from the Log tab of the Control Center and Ctrl + v to paste this in your reply)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi ChelseaB, thanks for the answer no it does not present or generate any error that we can see,
      This is the code structure that we use very simple:


      if (coditionsss,,,
      && (Position.MarketPosition == MarketPosition.Flat)
      && (BarsSinceExitExecution() > 1 || BarsSinceExitExecution() == -1))


      {
      EnterShortLimit(1, Close[1] + 1, @"NQ_Short");

      }
      if ((Position.MarketPosition != MarketPosition.Flat)
      && (Position.MarketPosition == MarketPosition.Short))
      {

      ExitShortStopMarket(Convert.ToInt32(DefaultQuantit y), High[1], @"PRO---NQ_Short", @"NQ_Short");
      ExitShortLimit(Convert.ToInt32(DefaultQuantity), (Position.AveragePrice - siceM) , @"Target-NQ_Short", @"NQ_Short");
      }

      //this code is for if our stop is very far we manage the risk like this
      if (Position.GetUnrealizedProfitLoss(PerformanceUnit. Currency, Close[0]) < VirtualSTOP)
      {
      ExitLong();
      ExitShort();
      }

      Comment


        #4
        Hello pacoperico,

        Print (or write the values to file) and enable TraceOrders to get an understanding of what exactly different.

        Is possible the orders are having slightly different fill prices or the data is different.

        Below is a link to a forum post that demonstrates using Print() and TraceOrders.


        And a link to a forum post that demonstrates writing the information to file.
        Citizens of the NinjaTrader Community, A common question we hear from clients is 'why are results from backtest different from real-time or from market replay?'. Live orders are filled on an exchange with a trading partner on an agreed upon price based on market dynamics. Backtest orders are not using these market dynamics.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi ChelseaB Thanks for the answer, I already activated the traces, which is easy, as soon as I have an example, I'll give you the results.

          Comment


            #6
            hi this all the log when error happen ends 1 operation and immediately starts another
            Attached Files

            Comment


              #7
              Hello pacoperico,

              These text files appear to have hexidecimal values.. Did you change the file extension?

              Is this output from the output window from Print()?
              Did you right-click the Output window and select Save As to save the output to a text file?

              Or is this written to file with StreamWriter?

              Are you getting an error? If so, please copy and paste the full error message.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                hi sorry

                the logic of the strategy ends and out of nowhere starts another operation

                this are the log
                Time Category Message
                2022-03-14 15:56 Execution Execution='1250660|1302250091|1302250091' Instrument='MES 06-22' Account='2137' Exchange=Globex Price=4165.25 Quantity=1 Market position=Short Operation=Operation_Add Order='1302250091' Time='3-14-2022 3:56 PM'
                2022-03-14 15:56 Order Order='1302250091/2137' Name='Sell' New state='Filled' Instrument='MES 06-22' Action='Sell' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=GTC Oco='' Filled=1 Fill price=4165.25 Error='No error' Native error=''
                2022-03-14 15:56 Position Instrument='MES 06-22' Account='2137' Average price=4162.75 Quantity=1 Market position=Flat Operation=Remove
                2022-03-14 15:56 Order Order='1302250091/2137' Name='Sell' New state='Working' Instrument='MES 06-22' Action='Sell' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                2022-03-14 15:56 Order Order='1302250091/2137' Name='Sell' New state='Accepted' Instrument='MES 06-22' Action='Sell' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                2022-03-14 15:56 Order Order='c84af710d24e41c284e5042b0180c5b7/2137' Name='Sell' New state='Submitted' Instrument='MES 06-22' Action='Sell' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                2022-03-14 15:56 NinjaScript NinjaScript strategy 'Soluciones123/246651055' submitting order
                2022-03-14 15:55 Order Order='1302249596/2137' Name='PRO---NQ_Short2' New state='Cancelled' Instrument='MES 06-22' Action='Buy to cover' Limit price=0 Stop price=4164.75 Quantity=1 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                2022-03-14 15:55 Order Order='1302249598/2137' Name='Target-NQ_Short2' New state='Cancelled' Instrument='MES 06-22' Action='Buy to cover' Limit price=4155.75 Stop price=0 Quantity=1 Type='Limit' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                2022-03-14 15:55 Execution Execution='1250532|1302249752|1302249752' Instrument='MES 06-22' Account='2137' Exchange=Globex Price=4162.75 Quantity=1 Market position=Long Operation=Operation_Add Order='1302249752' Time='3-14-2022 3:55 PM'
                MES 06-22 Sell 1 4165.25 2022-03-14 3:56:04 PM 1250660|1302250091|1302250091 Exit - 1302250091 Sell
                MES 06-22 Buy 1 4162.75 2022-03-14 3:55:45 PM 1250532|1302249752|1302249752 Entry 1 L 1302249752 Buy to cover
                MES 06-22 Buy 1 4162.75 2022-03-14 3:55:44 PM 1250526|1302249748|1302249748 Exit - 1302249748 Buy to cover
                MES 06-22 Sell 1 4160.25 2022-03-14 3:55:35 PM 1250458|1302249594|1302249594 Entry 1 S 1302249594 NQ_Short2

                Comment


                  #9
                  Hello pacoperico,

                  The output from the prints and trace orders should tell us why.

                  Have you started debugging the script by adding prints (or writing to file)? Is TraceOrders enabled?
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    hi ChelseaB

                    this are the log from do that

                    Comment


                      #11
                      hi
                      here is how problem start
                      Received unknown order type '', Order Id '1302803390'

                      Comment


                        #12
                        Hello pacoperico,

                        The Log on the Log tab of the Control Center will show real-time orders, but will not give you information about why the script is behaving as it is.

                        You are wanting to know why a stop loss is not being submitted from the script logic, is this correct?

                        Prints and TraceOrders will appear in the New -> NinjaTrader Output window as directed in the forum post linked in post #4.
                        Right-click the output window and select Save As.
                        Last edited by NinjaTrader_ChelseaB; 03-15-2022, 10:11 AM.
                        Chelsea B.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by terofs, Today, 04:18 PM
                        0 responses
                        3 views
                        0 likes
                        Last Post terofs
                        by terofs
                         
                        Started by nandhumca, Today, 03:41 PM
                        0 responses
                        4 views
                        0 likes
                        Last Post nandhumca  
                        Started by The_Sec, Today, 03:37 PM
                        0 responses
                        3 views
                        0 likes
                        Last Post The_Sec
                        by The_Sec
                         
                        Started by GwFutures1988, Today, 02:48 PM
                        1 response
                        5 views
                        0 likes
                        Last Post NinjaTrader_Clayton  
                        Started by ScottWalsh, 04-16-2024, 04:29 PM
                        6 responses
                        33 views
                        0 likes
                        Last Post ScottWalsh  
                        Working...
                        X