Profile Picture

Position Reversal Problem

Posted By Chris_M 10 Years Ago
Message
Posted Monday October 15 2007
Hello,

I'm getting a NullReferenceExeption when I try to handle a position reversal and access the newly opened reversal position. My handler looks like this:

public void PositionManager_PositionReversed(object sender, PositionOverfilledEventArgs e)

{

  PositionManager.SetProfitTarget(e.OpenedPosition.PosID, 0.05, true);

}

It's called like this:

PositionManager.PositionOverfilled += new EventHandler<RightEdge.Common.PositionOverfilledEventArgs>(PositionManager_PositionReversed);

It's more or less a translation of the VB-sample from Daniel. What could be the reason for the error?

Regards,

Chris

Posted Monday October 15 2007
I think I've figured it out myself:
I'm using a multi position system and in case of a reverse order PositionManager seems to close existing positions first before opening new reversed positions. And I've got an earlier position with exactly the same size as the reverse order position size. So in my case this earlier position is closed an there is no newly opened position. And with that no reference to any opened position. So any access to that causes an error.
Works as designed! Wink

Regards,
Chris

Posted Monday October 15 2007
I can't get it working! Crying
Even if i restrict open positions/symbol to one the reverse order is not created!

My oh my - is this complicated!!!! Sad


Edited: Monday October 15 2007 by Chris_M
Posted Monday October 15 2007
I'm not sure why it wouldn't be showing up.  If the order that was filled ends up getting spread over multiple positions, you should see one trade for each position it was applied to.  These trades will look like normal trades, but the description will indicate that they were part of an overfill.

Can you post or send us your system?  It's hard to know what might be wrong without looking at it?

Thanks,
Daniel

Posted Monday October 15 2007
Hmmm...the debugging shows that many stop orders with a position size of 3 times the current size get rejected when the stop is triggered. What could be the reason for that? I thought that the position manager would open orders in reversed direction instead of rejecting them. 
Posted Monday October 15 2007
Ah, you probably need to enable position reversal in the paper trader settings.  It is disabled by default.

Daniel

Posted Monday October 15 2007
WHERE?? w00t

I've seen it - under configure services!


Edited: Monday October 15 2007 by Chris_M
Posted Monday October 15 2007
That was the key! NOW IT WORKS!!!! Hehe FINE, THANKS!!!!

Edited: Monday October 15 2007 by Chris_M


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems