I'm having a problem with setting profit targets on equity shorts in Sim accounts using IQFeed. The key here is Sim accounts. These are positions that can be held overnight.
At some point after the markets close - and this can happen any time between close and open - IQFeed is sending a price of 0 for some stocks. 100% gain on a short?! Swish.
However, we know that's not real, so it's not helpful. By closing out my position, I am unable to test my strategy in a sim environment as this won't happen in live. Here's what I've done so far:
1. I already use time parameters for my strategies so that they're "on" at certain times of the day. This has worked perfectly fine for entries and exits that are not held overnight.
2. The above, of course, is done in the OnBarUpdate section of the code. I have moved the SetProfitTarget code into this time from from Initialize. In Backtest and Optimization, it's running as expected (I should add: I tried to add time constraints in the Initialize section, but it failed to operate in this section).
Is there any way I can avoid having the SetProfitTarget code execute because of a bad signal from IQFeed? I do realize one obvious suggestion is to turn off IQFeed overnight, but I've had this problem occur at 4:01pm and 9:29am (EDT).
Thanks for any help!
bfd

Comment