Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cumulitive Profit not changing..

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

    #16
    In the output after all the instruments that are not exiting I get the following...

    **NT** Error on calling 'OnBarUpdate' method for strategy 'TestIOrderMulti/d023c1e4c3b641b69bff2f0bcee62fdf': Object reference not set to an instance of an object.

    Do I have the sequence correct below...

    //Unrealized profit condition here

    OBU()
    //Entry and Exit Condition here

    OnExec()
    //Stop & Target here

    StopStrategy()
    //CancelOrder and Exit Long here if Unrealized profit condition triggered

    Comment


      #17
      Your logic idea for each of the method looks fine to me. However this error message likely means one of your IOrders is being set to Null before it should. Or that you're trying to access the IOrder when you shouldn't be.

      Let me know if I can further assist.
      LanceNinjaTrader Customer Service

      Comment


        #18
        I've read there is no object to get a cumulative unrealized PnL for a multi-instrument script as you can do with realized PnL.

        Can I do something like the below to get a cumulative unrealized PnL for 3 different instruments?...

        unrlzdPnl = (((Position.GetProfitLoss(Closes[0][0], PerformanceUnit.Points)) + (Position.GetProfitLoss(Closes[1][0], PerformanceUnit.Points)) + (Position.GetProfitLoss(Closes[2][0], PerformanceUnit.Points)))

        Comment


          #19
          You're on the right track for getting the unrealized. Instead of Position you want to use Positions[index location]



          Let me know if I can further assist.
          LanceNinjaTrader Customer Service

          Comment


            #20
            I'm not sure what's happening, as shown below I'm trying to add up the unrealized PnL for Index 2 & 3. I'm getting some odd #'s as you can see from the attached Output image, also attached the PnL results from the Stategy Analyzer for that day.

            unrlzdPnl = ((Positions[2].GetProfitLoss(Close[0], PerformanceUnit.Points)) +
            (Positions[3].GetProfitLoss(Close[0], PerformanceUnit.Points)));

            Index 2 is UVXY -$146
            Index 3 is TRIP -$388

            The output is showing decimal figures toward end of the day? I even tried adding all the output #'s up for all minutes and it doesn't come out to the figures in the Analyzer window.
            Attached Files

            Comment


              #21
              Try starting simpler.

              Run a strategy in real time and print the unrealized for each instrument separately. As trades are placed ensure this value is updated properly.
              LanceNinjaTrader Customer Service

              Comment


                #22
                Where do I see the output or print info for the sim account? It's not under log is it?

                Also how will this help for getting correct unrealized PnL for backtesting? The realized PnL worked correctly in BT so I'm not sure why the Unrealized if off.

                Comment


                  #23
                  Prints will appear in the same location whether backtesting or running in real time (the output window).

                  My suggestion would allow you to determine if your script is properly reporting Unrealized PnL or if there might be other logic interfering with the storing or reporting.

                  By running it in real time you'll be able to view the unrealized PnL on the strategy tab. Make sure this value matches the variable you're storing.
                  LanceNinjaTrader Customer Service

                  Comment


                    #24
                    I apologize I've never run live sim before and can't seem to find specific instructions, I run from the control center under Order and view the Account performance(hit generate) instead of going under the strategy analyzer window correct? Going through the control center and after I hit generate I don't see the output icon like i do in the strat analyzer. And I don't see a strategy tab but do see a strategies tab if that's what you meant.

                    Comment


                      #25
                      For information on running Strategies in real time:

                      From the strategies tab: http://www.ninjatrader.com/support/h...t_strateg2.htm

                      From a Chart: http://www.ninjatrader.com/support/h...t_strategy.htm

                      You aren't required to do this for testing, but it's more of a suggestion to help you debug your script. This way you can ensure the Unrealized PnL values you are storing are being updated and stored at the correct points.

                      Let me know if I can further assist.
                      LanceNinjaTrader Customer Service

                      Comment


                        #26
                        I can't get a trade to trigger in the sim account. Have it down to a basic fast crossover slow sma on a 1min chart which happens constantly.

                        It's saying strategy not in sync with account position. I chose True for snyc in the strategy, but still coming up. Not sure if this is stopping it from taking trades.

                        Still can't find any output icon like you suggest, don't know if this only comes up after a trade triggers. Is there anyway I can get it to just manually trigger a trade so I can see what things look like after?
                        Last edited by zachj; 11-01-2013, 12:26 PM.

                        Comment


                          #27
                          The output window is found by going to tools -> output window
                          The strategies unrealized is found on the Strategies tab of the control center: http://www.ninjatrader.com/support/h...egies_tab2.htm

                          For getting trades to fire as a simple strategy in real time you could put a condition like this in your OnBarUpdate()

                          if(Close[0] > Open[0] && Position.MarketPosition == MarketPosition.Flat)
                          EnterLong();

                          Please note however, historical trades will be taken into account. You can avoid this by either igoring historical http://www.ninjatrader.com/support/h...historical.htm or by adding in exit condition.

                          Your strategies tab will also show the strategy (when enabled) as green or yellow. This will depend on historical trade states and your strategy settings discussed here: http://www.youtube.com/watch?v=US9cKUwLMOA

                          Let me know if I can further assist.
                          LanceNinjaTrader Customer Service

                          Comment


                            #28
                            You replied before I edited my last post. Im getting the snyc error even though I set the snyc to true, so its showing the yellow. Is this stopping trades, if so how can I fix it?

                            Comment


                              #29
                              You probably won't need to set sync = true but you can depending on your preferences. I suggest watching the youtube video or document here for more details on each setting: http://www.ninjatrader.com/support/h..._positions.htm

                              Yellow state means it's currently in a historical position and is waiting for the historical position to close out before going live. If you were to set it to Immediately submit live working historical orders instead, you would see it switch to green.
                              LanceNinjaTrader Customer Service

                              Comment


                                #30
                                Ok I see. But with my strategy it could go days without triggering a trade. Isn't there a way to make the price move with some sort of scroll device so I can get trades to trigger? I thought I remembered seeing some sort of simulator where you scroll it up and price moves up and vice versa. Or would that not show unrealized.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                599 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                344 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                103 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                558 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                557 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X