I tried to transfer an information of a signal to the position table in "Positions".
runs properly without an entry signal in "Positions". When I try to transfer a signalName to the "Positions" by
the text "Entry" is displayed, but the positions are never closed.
Does anyone know a solution for that?
CODE:
_transaction = PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, 0);
runs properly without an entry signal in "Positions". When I try to transfer a signalName to the "Positions" by
CODE:
_transaction = PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, "Entry");
the text "Entry" is displayed, but the positions are never closed.
Does anyone know a solution for that?
Rename
Maintaining groups of positions (first line) and using the entry signal (second line) makes the code somewhat different, isn't it. A solution can emerge if you're willing to show a more complete code which shows how you close the positions?
The entire code is as follows:
It is the C#-Code for "But at market if price close decreases 3 consecutive bars" ans "Sell at market afer 5 bars".
CODE:
public override void Execute(BarHistory bars, int idx) { int index = idx; Position foundPosition0 = FindOpenPosition(0); bool condition0; if (foundPosition0 == null) { condition0 = false; { if (indicator[index] >= 3.00) { { condition0 = true; } } } if (condition0) { _transaction = PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, "Entry"); _transaction.Weight = weight[index] * -1; } } else { condition0 = false; { condition0 = true; } if (condition0) { if (idx - foundPosition0.EntryBar + 1 >= 5) { ClosePosition(foundPosition0, OrderType.Market); } } } }
It is the C#-Code for "But at market if price close decreases 3 consecutive bars" ans "Sell at market afer 5 bars".
OK, this is expected. This code line tries to find a position to close using positionTag i.e. that last "0" in "... OrderType.Market, 0, 0":
Because the overloaded call with entry name does not support passing a positionTag, you're breaking the link between PlaceTrade and ClosePosition.
CODE:
Position foundPosition0 = FindOpenPosition(0);
Because the overloaded call with entry name does not support passing a positionTag, you're breaking the link between PlaceTrade and ClosePosition.
Adding
after the PlaceTrade line solved the problem,
CODE:
_transaction.PositionTag = 0;
after the PlaceTrade line solved the problem,
Your Response
Post
Edit Post
Login is required