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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    661 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    375 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    110 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    574 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    580 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X