- ago
I'm running into a situation where I'm getting conflicting signals from a strategy run in the strategy manager vs the signals on a chart.

What it seems like is that the NSF is recognized and honored on the SM - i.e. if a position is already open, the next signal is ignored. On the charts, it shows that both long and short positions can be open at the same time.

How do I ensure NSF positions on the charts are not entered?
0
162
3 Replies

Reply

Bookmark

Sort
Cone8
 ( 24.10% )
- ago
#1
The Strategy Monitor (and Streaming Strategies) works with "Use Live Positions".
The Strategy Window does not.

1. Is Preferences > Trading > Use Live Positions enabled?
2. Is Strategy Settings > Retain NSF Positions enabled?

QUOTE:
How do I ensure NSF positions on the charts are not entered?

Add this statement to the Initialize() section of the Strategy. The it will ignore the "Retain NSF Positions" configuration so that NSF Positions are never retained by the backtest.
CODE:
BacktestSettings.RetainNSFPositions = false;

QUOTE:
On the charts, it shows that both long and short positions can be open at the same time.
That's because your strategy allow it, and it's a bad idea.
That will happen, for example, if you have Buy/Sell and Short/Cover blocks in the same block Strategy.
0
- ago
#2
Thanks as always, Cone. I should be more clear - I'm using a Dummy account and only having them auto-stage, not placed. I didn't see any overlapping positions in my backtest of the original code, even with the "Retain NSF Postions" selected.

A couple comments/questions:

Live Positions was not selected. Are you saying it should be selected?
Retain NSF positions was selected; I've turned that off now. I also added the code you suggested, but I'm still seeing the entry/exit signals.

CODE:
public override void Initialize(BarHistory bars) {          BacktestSettings.RetainNSFPositions = false;



Finally, you say having buy/sell and short/covers should not be in the same strategy (I'm using code, not block strategies this time). Is there something inherent in a Long/Short strategy that's an issue, or are you saying that this implementation is where the problem is?
0
Cone8
 ( 24.10% )
- ago
#3
QUOTE:
I didn't see any overlapping positions in my backtest of the original code, even with the "Retain NSF Postions" selected.
Live trading (includes dummy broker) uses the same code, so I don't know what to tell you. The data can be different when trading live if you're not using Streaming Bars.

QUOTE:
Live Positions was not selected. Are you saying it should be selected?
I was pointing out one of the differences the way a strategy backtest works in a Strategy Window vs. the Strategy Monitor. But if your strategy trades the primary symbol and only holds one position per symbol, I'd recommend "Use Live Positions". But please read the Help about the details for that option.

QUOTE:
but I'm still seeing the entry/exit signals.
You lost me here. I don't have the details. Why wouldn't you expect entry and exit signals? You might have to show us the code to explain it.

QUOTE:
Is there something inherent in a Long/Short strategy that's an issue
A strategy has to manage all the positions separately.

QUOTE:
, or are you saying that this implementation is where the problem is?
Both. If your code does not ensure that only 1 position is open, then any combination is possible in the backtest. Brokers like IB wouldn't allow it because Buy/Cover and Short/Sell mean the same thing - in other words, the strategy might have long and short positions for the same symbol, but IB would only have 1 position or none - the combination of the backtest long and short positions.
0

Reply

Bookmark

Sort