Profile Picture

Close and open position on same (next day) bar

Posted By k2trade Last Year
Message
Posted Wednesday May 11 2016
So, I have my first strategy in RE coded and I am in the middle of backtesting.  The strategy  trades a relative strength custom indicator with SPY as the underlying index....all EOD.  The issue I run into is after several months/weeks of trading, I have multiple positions open with cash near zero.  That is fine, until I receive a sell signal and buy signal on the same bar.  I close the "sell" position at the next day's open, but RE does not recognize that I now have a cash balance, albeit available via temporary margin.  As a result, the "buy" signal does not open until the next bar (day).  I would very much like to close a position and open on the same bar the day after both the buy and sell signals are received. 

Unfortunately, I do  not  yet understand Position Manager enough to know if  I can essentially sell one position at the  open, update available capital to  reflect this sale, and then open a  new position with  the proceeds on the  same bar.  

Any help is much appreciated.



Edited: Wednesday May 11 2016 by k2trade
Posted Thursday May 19 2016
Hmmm...  Can someone at least tell me if I can post this elsewhere to get some assistance? 

I'm starting to think I may need to write my own paper broker to fix this.  Is the RE paper broker code available anywhere such that I do not have to start from scratch?
Posted Friday May 20 2016
Try this http://www.rightedgesystems.com/forums/3790/Position-Reversal-Problem?Keywords=positionreversed


Posted Saturday May 21 2016
Try setting your account margin factor to > 1. Otherwise you can't open positions until the next bar which is after you've exited the closing positions.
Posted Wednesday November 22 2017
Hi everyone,
the topic is a bit old already - but was it really solved satisfactory? Is there some workaround?
@k2trade: I think I have exactly the same problem that you described. I tried
   - setting the margin factor in the paper broker to "2"
   - enabling position reversal in the paper trader settings
   - setting the margin factor in the paper broker to "2" AND enabling position reversal in the paper trader settings
None of this worked.
What "did work" was to increase the "Max Open/Symbol" parameter in the global Parameter Management to "2". The Closing of the first position and the Opening of the second position on the Open of same bar was simulated as intended. This is of course only helpful for tracking the error in this particular case since in other situations I do not want to have 2 positions in one symbol...
That points towards the Position Manager like k2trade mentioned already, doesn't it...!?
My MySymbolScript.NewBar() treats the exits first and after that the entries... so from a chronological point of view there should be some solution...

Thanks for any reply! Best regards!



Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems