Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with SetProfitTarget with shorts

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Problem with SetProfitTarget with shorts

    Greetings all,

    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

    #2
    Hi there, the only way you could make this work is by canceling the stop order when these spikes occur and then immediately re-issue the stop after the prices are normal again.
    AustinNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    68 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    37 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    61 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    62 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X