Profile Picture

A complete Futures trading system with Long/short/reversal/customized stop loss & profit target...

Posted By Deosaran 11 Years Ago

A complete Futures trading system with Long/short/reversal/customized...

Posted Monday July 09 2007
Hi All:

I have several Futures day trading written in C++ (gcc/linux), and some in VC++. I want to code and backtest with RE and C#. I am new to RE and C# but I hope my knowledge of C++ will help. I've also done a bit of VB.NEt but I prefer C#.

I want to a complete system with the following features:

- go LONG;  go SHORT.

-  reverse LONG to short, short to LONG

- stop loss and profit target exits using true range moving average (TRMA) rather than fixed % of entry price or absolute dollar value. e.g. stop loss a long position at entry price - 2*TRMA

- add other exits, e.g. traillow or close open positions at market on close or x bars before close

- initiate entry only after a certain % of day or number of bars

- pyramid entries

Can you direct me to any sample system that has some or even all of the above?

Also, if you can suggest built functions or indicators that can be used to do the above.

Related topic: what C# book or tutorials you would recommend?



Posted Thursday July 12 2007
I don't have a complete system for you to refer to, but I can give you a few pointers on how to accomplish what you want.

To go long or short, simply call OpenPosition().  There is an argument which specifies the position type (long or short).

To reverse your position, you need to close the currently open position and open another position in the opposite direction.  You can get a list of open positions by calling PositionManager.GetOpenPositions().  You can pass in a specific symbol to only get the open positions for that symbol.  You can call ClosePosition() to close the positions, and then OpenPosition() to open a position in the opposite direction.

You can call PositionManager.SetProfitTarget() and PositionManager.SetStopLoss() to set the profit targets and stop losses.  You can do this when a position is opened in an OrderFilled event handler, or at any other time.  You could also call it in the NewSymbolBar() method to modify the profit target or stop loss.

For additional exits, you can call ClosePosition() any time according to your own logic.  For example if you want to close your open positions before the close of the market, you could check the PriceDateTime of the bar in the NewBar() method, and if it 3:30 or later (for example), you could close all your current positions.  If you want to send a non-market order, you can use PositionManager.RemoveFromPosition().

I would handle initiating entry only after a certain percentage of the day the same way.  If the bar PriceDateTime is before a certain time, then don't make any trades.

Pyramiding can be handled with the PositionManager.AddToPosition() and PositionManager.RemoveFromPosition() methods.

As far as books go, you may want to look at "CLR Via C#" by Jeffrey Richter.  It is an excellent book, but it is targeted more towards people who already know the basics of C#, and covers a lot of the advanced stuff and what happens "under the covers."  So I'm not sure if that's really what you're looking for.


Similar Topics

Reading This Topic

2005-2018 © RightEdge Systems