|
QuantShare
2010-11-01 06:36:39
0
|
|
Best Answer
- Yes, they contain a list of symbols that pass the buy and sell rules. A change in our code has not been committed and that is why you are getting the same list. It is fixed now. Thank you for reporting this.
- To optimize the execution of trading systems, the number of symbols in the list (for a particular date) will not contain more than 2 * (Max number of symbols) + 1.
- "OnNewPosition" gets the signal. You can then use this event to modify it. After that the signal is converted into an order.
After all orders are procceeded, the OnEndPeriod is executed.
However, if you execute orders on today's bar, then the "OnNewPosition" will be called after "OnEndPeriod".
- I am not sure I understand exactly what you want to do with GetOpenPositions, but here is an example on how to be fully invested in either long or short positions: (You need to set the trading system type to Long/Short)
string index = "^GSPC";
double result = Data.ParseFormula("a = rsi(14) > 50;").GetTimeSeries(index, "a")[0];
bool isfullylong = (result == 1) ? true : false; // Long positions if RSI of index is higher than 50
MMPosition[] positions = Portfolio.GetOpenPositions();
if(positions.Length > 0)
{
if(positions[0].IsLong == isfullylong)
{
// Portfolio is already in the correct long or short mode
return;
}
}
Divers.Output("IsLong: " + isfullylong);
// Close positions
for(int i=0;i<positions.Length;i++)
{
positions[i].ClosePosition();
}
if(isfullylong)
{
Portfolio.UpdateCategorySettings("short", 0, 0, Orders.OpenMarketOrder());
Portfolio.UpdateCategorySettings("long", 100, 5, Orders.OpenMarketOrder());
}
else
{
Portfolio.UpdateCategorySettings("long", 0, 0, Orders.OpenMarketOrder());
Portfolio.UpdateCategorySettings("short", 100, 5, Orders.OpenMarketOrder());
}
|
|