- ago
I tried to transfer an information of a signal to the position table in "Positions".

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?
0
855
Solved
4 Replies

Reply

Bookmark

Sort
- ago
#1
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?
0
- ago
#2
The entire code is as follows:
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".
0
- ago
#3
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":

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.
0
- ago
#4
Adding

CODE:
   _transaction.PositionTag = 0;


after the PlaceTrade line solved the problem,
1
Best Answer

Reply

Bookmark

Sort