I looked through the OrderState properties but do not see one that corresponds to having "filled and exited at the limit price."
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!
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
NinjaTrader
How to check IOrder object to see if a trade exited or not?
Collapse
X
-
How to check IOrder object to see if a trade exited or not?
I have an IOrder object and would like to make sure that the trade exited at the limit price (my strategy has multiple entries & exits).
I looked through the OrderState properties but do not see one that corresponds to having "filled and exited at the limit price." -
Hi texasnomad,
You could do something like...
if (order.OrderState == OrderState.Filled && entryOrder.AvgFillPrice == tryOrder.LimitPrice)
But since this is a limit order, the price is guaranteed.Last edited by NinjaTrader_Tim; 07-22-2010, 12:42 PM.TimNinjaTrader Customer Service
-
Originally posted by NinjaTrader_Tim View PostHi texasnomad,
You could do something like...
if (order.OrderState == OrderState.Filled && entryOrder.AvgFillPrice == tryOrder.AvgFillPrice.LimitPrice)
But since this is a limit order, the price is guaranteed.
I don't understand why you used 3 different object names; order, entryOrder and tryOrder
At the time I place the trade, my code is:
g1 = EnterLongStopLimit(Lots1, currentLimitPrice, "LongG1");
Do I need to track the status of g1 with other IOrder objects? If so, how and when?Last edited by texasnomad; 07-22-2010, 11:30 AM.
Comment
-
Hi texasnomad,
My apologies for the typos, should be "entryOrder"
If you want to create an IOrder and access information, you can set up the order as in at this page:
Code:private IOrder entryOrder = null; protected override void OnBarUpdate() { if (entryOrder == null && Close[0] > Open[0]) entryOrder = EnterLong(); }
TimNinjaTrader Customer Service
Comment
-
Code:protected override void OnPositionUpdate(IPosition position) { if( position.Quantity == Lots2 + Lots3 && g3.OrderState == OrderState.Filled ) { /*if( position.MarketPosition == MarketPosition.Long ) { SetStopLoss("LongG2", CalculationMode.Price, g2.AvgFillPrice + 0.5 * atr, false); SetStopLoss("LongG3", CalculationMode.Price, g3.AvgFillPrice + 0.5 * atr, false); }*/ if( position.MarketPosition == MarketPosition.Short ) { SetStopLoss("ShortG2", CalculationMode.Price, g2.AvgFillPrice - 0.5 * atr, false); SetStopLoss("ShortG3", CalculationMode.Price, g3.AvgFillPrice - 0.5 * atr, false); } } //Print("Position changed at " + Time[0].ToString() + ". Total lots: " + Position.Quantity); }
That said, I'm still curious how I can know if g1 is an open or closed trade...
Comment
-
Originally posted by NinjaTrader_Tim View PostHi texasnomad,
My apologies for the typos, should be "entryOrder"
If you want to create an IOrder and access information, you can set up the order as in at this page:
Code:private IOrder entryOrder = null; protected override void OnBarUpdate() { if (entryOrder == null && Close[0] > Open[0]) entryOrder = EnterLong(); }
I just saw your latest post. I tried replacing
if( position.Quantity == Lots2 + Lots3 && g3.OrderState == OrderState.Filled ) {
with
if( g1.OrderState == OrderState.Filled && g1.AvgFillPrice == g1.AvgFillPrice.LimitPrice ) {
but g1.AvgFillPrice.LimitPrice is not recognized as a valid property of AvgFillPrice. Did you intend to say:
g1.AvgFillPrice == g1.LimitPrice ?
Also, do g1's properties update even after I create the object with EnterShortStopLimit()?Last edited by texasnomad; 07-22-2010, 12:45 PM.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by bortz, 11-06-2023, 08:04 AM
|
47 responses
1,609 views
0 likes
|
Last Post
by aligator
Today, 07:22 PM
|
||
Started by jaybedreamin, Today, 05:56 PM
|
0 responses
9 views
0 likes
|
Last Post
by jaybedreamin
Today, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
19 views
0 likes
|
Last Post
by DJ888
Today, 05:12 PM
|
||
Started by Jon17, Today, 04:33 PM
|
0 responses
6 views
0 likes
|
Last Post
by Jon17
Today, 04:33 PM
|
||
Started by Javierw.ok, Today, 04:12 PM
|
0 responses
16 views
0 likes
|
Last Post
by Javierw.ok
Today, 04:12 PM
|
Comment