• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT8 - New Method GetLastPrice

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

    NT8 - New Method GetLastPrice

    NT8 - New Method GetLastPrice() should be possible to get and would be the last tick...

    #2
    Originally posted by MicroTrends View Post
    NT8 - New Method GetLastPrice() should be possible to get and would be the last tick...
    In NT7 I was missing possibility to get the last price from position or instrument without the need to add secondary bars - this could be used for calculation of unrealized profit from all open positions on the account (ie different charts, strategies, doms).
    I have just discovered in NT8 there is:
    Code:
    position.GetMarketPrice();
    Will this method work the way I described? It would be fantastic if it did!

    Comment


      #3
      Originally posted by gregid View Post
      In NT7 I was missing possibility to get the last price from position or instrument without the need to add secondary bars - this could be used for calculation of unrealized profit from all open positions on the account (ie different charts, strategies, doms).
      I have just discovered in NT8 there is:
      Code:
      position.GetMarketPrice();
      Will this method work the way I described? It would be fantastic if it did!
      That sounds great - not sure why we would use a position to get it...
      but very nice feedback thank you

      a lot of other commercial models have onTick as an event

      in NT7 - apart from Close[0] in calculateonbar close
      what about Close[-1] ?

      also you can trap the last tick on onMarketData - but its a waste due to bids and asks
      you could also subscribe to the internal events in ninjaTrader

      onstartup {
      Bars.Bar += new BarUpdateEventHandler(OnBarUpdateRealtime);}

      private void OnBarUpdateRealtime(object sender, NinjaTrader.Data.BarUpdateEventArgs e)
      {
      if (e.Operation == Operation.Remove) return;
      currentRealTimeBar = e.Bars.Get(e.Last);

      isRealtime=true;
      }

      protected override void OnTermination()
      {
      Bars.Bar -= OnBarUpdateRealtime; }
      }

      On another note isRealtime

      i find the Historical property a mixture of metaphors
      i like to set a isRealtime local in the onBarUopdateRealtime so we know the data is in fact in realtime even if the strategy thinks its in historical stats...
      Last edited by MicroTrends; 05-08-2015, 05:25 AM.

      Comment


        #4
        Originally posted by MicroTrends View Post
        That sounds great - not sure why we would use a position to get it...
        I gave one example of such need - to get unrealized profit from positions outside of current strategy. The default use of the method is:
        Code:
        position.GetUnrealizedProfitLoss(PerformanceUnit.Currency, Close[0]);
        But outside of the strategy you don't have the Close[0] unless you add new Bar series.
        if the the method works as expected (I am about to test it once I sort out some conversion issues) you could do something like:
        Code:
        position.GetUnrealizedProfitLoss(PerformanceUnit.Currency, position.GetMarketPrice());
        Also it seems you can get the market data directly from Instrument:
        Code:
        double lastPrice = Bars.Instrument.MarketData.Last.Price;

        Comment


          #5
          Would recommend you guys start to push out into the AddOn support.

          In which you just could attach your own MarketData handler. The documentation is still not complete but the example should show the use case.

          http://www.ninjatrader.com/support/h...marketdata.htm

          Let me know if that doesn't do the trick.
          Last edited by NinjaTrader_Brett; 05-08-2015, 07:17 AM.
          BrettNinjaTrader Product Management

          Comment


            #6
            Originally posted by gregid View Post
            I gave one example of such need - to get unrealized profit from positions outside of current strategy. The default use of the method is:
            Code:
            position.GetUnrealizedProfitLoss(PerformanceUnit.Currency, Close[0]);
            But outside of the strategy you don't have the Close[0] unless you add new Bar series.
            if the the method works as expected (I am about to test it once I sort out some conversion issues) you could do something like:
            Code:
            position.GetUnrealizedProfitLoss(PerformanceUnit.Currency, position.GetMarketPrice());
            Also it seems you can get the market data directly from Instrument:
            Code:
            double lastPrice = Bars.Instrument.MarketData.Last.Price;
            ah so you are iterating through a collection of connections instruments and positions and getting P&L info - and so having the method there in the position object for last price gives you the context during enumeration... very nice

            Code:
            position.GetUnrealizedProfitLoss(PerformanceUnit.Currency, position.GetMarketPrice());

            Comment


              #7
              Exactly, that's the idea!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by brunoviveiros, Today, 04:31 AM
              2 responses
              13 views
              0 likes
              Last Post brunoviveiros  
              Started by foxy_rav, Today, 06:31 AM
              1 response
              4 views
              0 likes
              Last Post NinjaTrader_Jim  
              Started by neilzep, Today, 06:42 AM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by teafortwo, Today, 04:26 AM
              3 responses
              8 views
              0 likes
              Last Post NinjaTrader_PaulH  
              Started by autogenix, Today, 12:54 AM
              3 responses
              11 views
              0 likes
              Last Post NinjaTrader_Marco  
              Working...
              X