Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy reverse position fills profit target

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

    Strategy reverse position fills profit target

    I have a strategy that uses the following code every time it is triggered in one direction or the other.
    Code:
    SetStopLoss(order1Name, CalculationMode.Ticks, 50, false);
    SetProfitTarget(order1Name, CalculationMode.Ticks, 50);
    EnterLong(Convert.ToInt32(TargetSize), order1Name);
    ... or it uses EnterShort() to go short. The documentation says that NT8 will effectively reverse the position if the opposite Enter* order is called. This works sometimes, and sometimes it will fill the profit target order immediately.

    See the attached CSV document with the data from the Orders window. See that transition from 1:00 and the orders at 1:09 where the problem happened. Also, it is not shown in the CSV format, but the orders at the same minute mark (like 1:09) all happen at the same second (it happens fast). There's one Sell Short at 1:09 and then immediately the Profit Target is filled, however, the price is nowhere near the profit target.

    Note, the immediate close of the position (profit target) happens intermittently, not always. How can I fix this or is there a cleaner way to reverse a position with stop loss and profit target orders?

    If the above code was used to enter a position, then when the strategy is triggered again, for example, the following code would reverse that position:
    Code:
    SetStopLoss(order1Name, CalculationMode.Ticks, 50, false);
    SetProfitTarget(order1Name, CalculationMode.Ticks, 50);
    EnterShort(Convert.ToInt32(TargetSize), order1Name);
    Also note, it uses the same order name.

    #2
    Hi bfalls, thanks for posting.

    Make sure you are giving a unique signal name to each entry signal so they can be targeted by their own SetStopLoss/SetProfitTarget methods. Make sure the long order has a signal name different from order1Name.

    For a more consistent reversal behavior, it would be best to set up a bool variable "WaitingForCancel" set to true when the position needs to reverse. Then check in OnOrderUpdate if the stop and target are in State.Canceled and WaitingForCancel == true, then reverse using EnterLong/EnterShort.

    Kind regards,
    -ChrisL

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    71 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    143 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    76 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    47 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    51 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X