![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
|
I have need test to see if my positions are Flat before entering a new "FullTrade". My scripted logic is to enter 3 uniquely named trades with 3 different targets and 3 stops. These are OCO, so the Full Stop cancels all. I call each of the 3 partial trades a "Leg" (e.g. Leg1, Leg2, Leg3).
My question is: In code, how can I avoid entering any additional "FullTrades" when I have a "FullTrade" position on? My trades are entered in OnBarUpdate(). My targets and stops are adjusted in OnPositionUpdate(). In Initialize() I have: EntriesPerDirection = 3; EntryHandling = EntryHandling.AllEntries; Most "FullTrades" work fine, but whenever one "Leg" has hit it's target, I can find myself entering a new trade if the conditions are right. IPosition doesn't seem to be available in OnBarUpdate() and OnPositionUpdate is too late. Will I need to track this on my own with additional variables? (Hopefully not, but possible.) What are your thoughts? Brian |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Mar 2008
Posts: 731
Thanks: 0
Thanked 1 time in 1 post
|
if (Position.MarketPosition == MarketPosition.Flat
&& ..... Not sure if that answers the question regarding your specific strategy but thats what I use in mine. |
|
|
|
|
|
#3 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Can you not just set some variables to signify a "state" and reset this to a "fresh" state once the position is flat which then signals you can take new "legs" ?
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#4 |
|
Member
|
Thanks for the quick response(s).
Elliot ... I do that too, but only in the OnPositionUpdate(). I wasn't able to get it to work when I first tried it in OnBarUpdate(). Compiled now, so it may be working now. Thanks very much. Ray ... ya, that's what I was going to do, if nothing else. I might need to go ahead a set my own class up for my 3-legs in a "FullTrade" anyway. Thanks. Much appreciated, Brian |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Entering positions when not flat | edward | ATM Strategies (Discretionary Trading) | 5 | 08-09-2007 02:21 PM |
| Flat a position on a market | Respond | SuperDOM and other Order Entry Windows | 2 | 06-27-2007 08:51 AM |
| Problem with MarketPosition.Flat | zoltran | Strategy Development | 3 | 04-10-2007 06:57 AM |
| P&L When Flat | pivot44 | Miscellaneous Support | 0 | 02-20-2007 05:01 AM |
| MarketPosition.Flat compile error | DarrylT | Strategy Development | 3 | 01-10-2007 05:49 AM |