Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
NT8 - New Method GetLastPrice
Collapse
X
-
NT8 - New Method GetLastPrice
NT8 - New Method GetLastPrice() should be possible to get and would be the last tick...Tags: None
-
Originally posted by MicroTrends View PostNT8 - New Method GetLastPrice() should be possible to get and would be the last tick...
I have just discovered in NT8 there is:
Code:position.GetMarketPrice();
-
Originally posted by gregid View PostIn 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();
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, 06:25 AM.
Comment
-
Originally posted by MicroTrends View PostThat sounds great - not sure why we would use a position to get it...
Code:position.GetUnrealizedProfitLoss(PerformanceUnit.Currency, Close[0]);
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());
Code:double lastPrice = Bars.Instrument.MarketData.Last.Price;
Comment
-
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.
Let me know if that doesn't do the trick.Last edited by NinjaTrader_Brett; 05-08-2015, 08:17 AM.
Comment
-
Originally posted by gregid View PostI 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]);
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());
Code:double lastPrice = Bars.Instrument.MarketData.Last.Price;
Code:position.GetUnrealizedProfitLoss(PerformanceUnit.Currency, position.GetMarketPrice());
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Rapine Heihei, Today, 08:19 PM
|
1 response
8 views
0 likes
|
Last Post Today, 08:30 PM | ||
Started by Rapine Heihei, Today, 08:25 PM
|
0 responses
6 views
0 likes
|
Last Post Today, 08:25 PM | ||
Started by f.saeidi, Today, 08:01 PM
|
1 response
9 views
0 likes
|
Last Post Today, 08:17 PM | ||
Change colour of Stop market and limit orders to red and green via indicator script
by Rapine Heihei
Started by Rapine Heihei, Today, 07:51 PM
|
0 responses
8 views
0 likes
|
Last Post Today, 07:51 PM | ||
Started by frslvr, 04-11-2024, 07:26 AM
|
5 responses
98 views
1 like
|
Last Post
by caryc123
Today, 07:47 PM
|
Comment