NexusFi: Find Your Edge


Home Menu

 





Closing IOrder Object after trade done


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one zaico with 3 posts (0 thanks)
    2. looks_two sam028 with 2 posts (0 thanks)
    3. looks_3 rleplae with 2 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 1,303 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
Search this Thread

Closing IOrder Object after trade done

  #1 (permalink)
zaico
Barcelona Spain
 
Posts: 26 since Sep 2016
Thanks Given: 6
Thanks Received: 4

How can I check if a trade by a IOrder object is closed. I set a SL and a PT for a long entry, so i would like to know when the trade is done. I tried with (Order.OrderState != OrderState.Working) but it doesn't work.
Thanks

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Build trailing stop for micro index(s)
Psychology and Money Management
ZombieSqueeze
Platforms and Indicators
Exit Strategy
NinjaTrader
Are there any eval firms that allow you to sink to your …
Traders Hideout
Better Renko Gaps
The Elite Circle
 
  #3 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


You can check if you are flat or not with

 
Code
// Check if flat
    if (GetAtmStrategyMarketPosition("id") == MarketPosition.Flat)
         Print("ATM Strategy position is currently flat");

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629


zaico View Post
How can I check if a trade by a IOrder object is closed. I set a SL and a PT for a long entry, so i would like to know when the trade is done. I tried with (Order.OrderState != OrderState.Working) but it doesn't work.
Thanks

Do you want to know the status of the order or if the IOrder object has been disposed?

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
  #5 (permalink)
zaico
Barcelona Spain
 
Posts: 26 since Sep 2016
Thanks Given: 6
Thanks Received: 4


sam028 View Post
Do you want to know the status of the order or if the IOrder object has been disposed?

the status.

Reply With Quote
  #6 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


zaico View Post
the status.

like sam028 you may need to test for null
as the object may be disposed ... some testing will be needed

for sure, when still working it will return a status
the issue is when cancelled or filled (for example in chart trader outside the atm

i have implemented peeking directly in the SQLCe database to know the status
but that needs some careful considerations as well

in short, several options
depending on what you want to do

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #7 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629

Check the OrderState possible values here then.
If your (Order.OrderState != OrderState.Working) was not working you may print the order status to debug your stuff.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
  #8 (permalink)
zaico
Barcelona Spain
 
Posts: 26 since Sep 2016
Thanks Given: 6
Thanks Received: 4

The thing is something like this:
 
Code
				if (condition )
				{    
					// Submit an entry order at the low of a bar
					if (Order == null)
					{	
						SetStopLoss("", CalculationMode.Ticks, 5, false);
						SetProfitTarget("", CalculationMode.Ticks, 60);
						Order=EnterLongLimit(0, true, 1, MIN(Low, 4)[0], "Long Entry");
						barNumberOfOrder = CurrentBar;
					}
						
				}
							
				
				if (Order != null)
				{			
					if ( CurrentBar > barNumberOfOrder+70)
					{
						CancelOrder(Order);
			                        Order = null;
			                        barNumberOfOrder=0;
					}	
				}
		}
The thing is: I want to finish the Order wherever it's state is once it passes 70 bars but restart the counting if the LongLimit is reached. But this way it's starts counting from the moment I set the LongLimit. Wich could be very far from the entry point. Leaving the trade live for only few minutes.

Reply With Quote




Last Updated on December 28, 2016


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts