GetPositions() returns the positions for the current symbol.
GetPositionsAllSymbols() returns all the positions for all symbols in the backtest.
How can I get positions for the external symbols for the current symbol?
GetPositionsAllSymbols() returns the positions not only for the external symbols but also other symbols in the backtest.
Examples:
Symbols: SPY, QQQ
External Symbols, UPRO, TQQQ from GetHistory()
Strategy running SPY trades either SPY or UPRO.
Strategy running QQQ trades either QQQ or TQQQ.
Strategy running SPY wants to see neither QQQ nor TQQQ.
Strategy running QQQ wants to see neither SPY nor UPRO.
GetPositionsAllSymbols() returns all the positions for all symbols in the backtest.
How can I get positions for the external symbols for the current symbol?
GetPositionsAllSymbols() returns the positions not only for the external symbols but also other symbols in the backtest.
Examples:
Symbols: SPY, QQQ
External Symbols, UPRO, TQQQ from GetHistory()
Strategy running SPY trades either SPY or UPRO.
Strategy running QQQ trades either QQQ or TQQQ.
Strategy running SPY wants to see neither QQQ nor TQQQ.
Strategy running QQQ wants to see neither SPY nor UPRO.
Rename
Use a LINQ query with the custom condition to limit the symbols e.g. GetPositionsAllSymbols().Where(p => p.Symbol != bars.Symbol) and along those lines?
I wish there was a WL6-like Position where it contains symbols only from the currently running symbol so that it would have made life easier to migrate from WL6 to WL8.
Thank you for your suggestion.
I came up with a solution like this and it works great.
I came up with a solution like this and it works great.
CODE:
List<Position> GetPositionsLocalSymbols() { return GetPositionsAllSymbols().Where(p => p.Symbol == Symbol || p.Symbol == Symbol3x).ToList(); }
Your Response
Post
Edit Post
Login is required