Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnPositionUpdate - MarketPosition parameter - what's it good for?

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

  • NinjaTrader_PatrickH
    replied
    If the variable cp is to be compared for the position of the strategy, yes. Keep in mind this would be as each update to position calls OnPositionUpdate(). So in sequence of the events.

    Leave a comment:


  • pstrusi
    replied
    Originally posted by NinjaTrader_PatrickH View Post
    Hello pstrusi,

    Thank you for your response.

    Why not just use OnPositionUpdate() when position returns Flat? I may not be understanding your reason for avoiding this?

    The "actual" position or more accurately the position reported by the brokerage technology is marketPosition. The order of events as they are processed would be called through position.MarketPosition instead.
    Hi Patrick

    So, having in mind what you say, then This following snippet would do the job?

    Code:
    protected override void OnPositionUpdate(IPosition position)
    		{
    			if ( position.MarketPosition == MarketPosition.Long )
    			{
    				cp=1.0;
    				
    			}
    			if ( position.MarketPosition == MarketPosition.Short )
    			{
    				cp=-1.0;
    				
    			}
    		}
    
    // Then before submitting any new order, would it good enough to check the value of CP, right?

    Leave a comment:


  • NinjaTrader_PatrickH
    replied
    Hello pstrusi,

    Thank you for your response.

    Why not just use OnPositionUpdate() when position returns Flat? I may not be understanding your reason for avoiding this?

    The "actual" position or more accurately the position reported by the brokerage technology is marketPosition. The order of events as they are processed would be called through position.MarketPosition instead.

    Leave a comment:


  • pstrusi
    replied
    I just want to do what you say: check my position before send a new order. I know how to do that, it could be done in OnBarUpdate, OnPositionUpdate...etc The reason for my request is because there's a doubt coming from OnPositionUpdate indicated by Sledge and still confirmed by NT support team here, that 's a difference depending in how you call it. So that's what I want to address. Let's wait for NT support team answer to contrast. Thanks

    Leave a comment:


  • koganam
    replied
    Originally posted by pstrusi View Post
    Koganam, I'm not trying to trade as HFT with my algo, still some signals might trigger within a timeframe where actually an old order was just submit, still working...etc So before the new order is submit, in order to avoid overfillings or unwilling positions, I HAVE to check what is my instance position, I don't think that this simple request is something complicated to NT, or at least it shouldn't be.

    Thanks for your willing to help always
    How does that negate anything that I have said? I specifically said that you are just asking the computer to do exactly what you would do manually, and exactly what you have described anyway. What has HFT got to do with the matter?

    Well, if you will not take the simple solution, I guess I will leave to to find the complicated solution that you are seeking. Yes, it is a simple request, and no, it is not complicated. You are the one who wants to make it complicated. You have been given a simple, reliable solution that I use myself personally, and you persist in looking for some other answer.

    All the best to you. I am out.

    Leave a comment:


  • pstrusi
    replied
    Koganam, I'm not trying to trade as HFT with my algo, still some signals might trigger within a timeframe where actually an old order was just submit, still working...etc So before the new order is submit, in order to avoid overfillings or unwilling positions, I HAVE to check what is my instance position, I don't think that this simple request is something complicated to NT, or at least it shouldn't be.

    Thanks for your willing to help always

    Leave a comment:


  • koganam
    replied
    Originally posted by pstrusi View Post
    Thanks Koganam, the problem is that you presume that I'm exiting when actually I'm reversing positions. I'm sorry NOT to clear that before
    It does not matter. You make your query of the position immediately before you make your order. Reversing is still just "making an entry in the opposite direction". If using Unmanaged orders, it is placing a quantity higher than the current position: if using Managed orders and properly arranged, NT will take care of the exit and reversal orders.

    Regardless, just as you would do if you were manually clicking the mouse, you decide that you are going to make a kind of entry order, so you check your position, then make the necessary order. You check your position immediately before you make the order, no matter how many times you have checked the position, or not, in the past.

    It is very simple. Before you put your money it risk, the last thing that you do is check your position, so as to be sure that you are not making a mistake by entering the order that you are about to make. There is nothing to argue about. Whether the computer makes the entry or you click the mouse, the entry decision process is exactly the same

    Leave a comment:


  • koganam
    replied
    Originally posted by sledge View Post
    But if it never fills, then order gets rejected....
    What never fills? I do not see your point, sorry. Maybe I am just dense?

    We are simply checking a position before we make an entry. I was replying to @pstrusi, (the immediate querier) so maybe we are talking at cross purposes?

    Leave a comment:


  • pstrusi
    replied
    Thanks Koganam, the problem is that you presume that I'm exiting when actually I'm reversing positions. I'm sorry NOT to clear that before

    Leave a comment:


  • koganam
    replied
    Originally posted by pstrusi View Post
    Thanks for your attention Koganam.

    What I look for is checking in reliable way that old managed orders are already filled, and position updated before new ones. In a platform like NT, this should be done easily. So if you have more ideas to achieve this with another simple test, please share.

    Thanks
    You said: "Before I submit an order ...", which leads to the presumption that you are talking about an entry order, because there is no need to make this check before you exit. You are either in a position to exit or you are not.

    In which case, as I already said, you check right before you issue the order. What other idea are you looking for? After all, you are about to do something immediately, so check your position immediately before you take action, not check some unknown time back before your entry.

    Even for an exit order, placed at some time after the order instead of in OnExecutionUpdate(), you would still check the position immediately before you make the order.

    I do not see your objection to doing so, and there is nothing else that I can suggest other that what I do reliably.
    Last edited by koganam; 10-17-2016, 08:10 AM. Reason: Corrected spelling.

    Leave a comment:


  • pstrusi
    replied
    Thanks for your attention Koganam.

    What I look for is checking in reliable way that old managed orders are already filled, and position updated before new ones. In a platform like NT, this should be done easily. So if you have more ideas to achieve this with another simple test, please share.

    Thanks
    Last edited by pstrusi; 10-17-2016, 04:08 AM.

    Leave a comment:


  • sledge
    replied
    Originally posted by koganam View Post
    Do it right before you submit the order, in OnBarUpdate() or wherever else you are submitting said order.
    But if it never fills, then order gets rejected....

    Leave a comment:


  • koganam
    replied
    Originally posted by pstrusi View Post
    I'm a little confused about this subject, so I'd like to clear my doubt.

    Before I submit any order I have to check in reliable way, what's my actual market position, and I use to do this:

    Code:
    protected override void OnPositionUpdate(IPosition position)
    		{
    			if ( position.MarketPosition == MarketPosition.Long )
    			{
    				cp=1.0;
    				
    			}
    			if ( position.MarketPosition == MarketPosition.Short )
    			{
    				cp=-1.0;
    				
    			}
    		}
    BUT after reading this post I have a doubt because it seems that position.MarketPosition could be the old position in case of triggering Stops orders. So I'd like to know what's is the ultimate and reliable best way to do it.

    Thanks in advance
    Do it right before you submit the order, in OnBarUpdate() or wherever else you are submitting said order.

    Leave a comment:


  • pstrusi
    replied
    I'm a little confused about this subject, so I'd like to clear my doubt.

    Before I submit any order I have to check in reliable way, what's my actual market position, and I use to do this:

    Code:
    protected override void OnPositionUpdate(IPosition position)
    		{
    			if ( position.MarketPosition == MarketPosition.Long )
    			{
    				cp=1.0;
    				
    			}
    			if ( position.MarketPosition == MarketPosition.Short )
    			{
    				cp=-1.0;
    				
    			}
    		}
    BUT after reading this post I have a doubt because it seems that position.MarketPosition could be the old position in case of triggering Stops orders. So I'd like to know what's is the ultimate and reliable best way to do it.

    Thanks in advance

    Leave a comment:


  • NinjaTrader_DaveI
    replied
    I agree that could be documented more clearly. I've added a note to the help guide to clarify this point. There have been a wide range of updates to the help guide which should be published along with the next beta build.

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by egordleo, Today, 05:50 AM
0 responses
1 view
0 likes
Last Post egordleo  
Started by kevinenergy, 02-17-2023, 12:42 PM
118 responses
2,778 views
1 like
Last Post kevinenergy  
Started by briansaul, Today, 05:31 AM
0 responses
8 views
0 likes
Last Post briansaul  
Started by fwendolynlpxz, Today, 05:19 AM
0 responses
4 views
0 likes
Last Post fwendolynlpxz  
Started by traderqz, Yesterday, 12:06 AM
11 responses
28 views
0 likes
Last Post NinjaTrader_Gaby  
Working...
X