Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ExitLong does not cancel trailstop order, leaving net short position instead of flat

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

    ExitLong does not cancel trailstop order, leaving net short position instead of flat

    Problem:

    Using ExitLong() as second stop loss, but trailing stop also executes, turning what should be a long exit into a net short position.


    Here is what I'm doing:

    Strategy is calculated on bar close not each tick.

    I'm using 2 data series.

    [0] the primary chart series is my signal series
    [1] the secondary series is the one I'm placing trades on

    Thus: in the State>Configure section I am adding only 1 data series.

    Note: the primary chart data series is not the same instrument as the data series I add and place trades on.

    The issue occurs in market replay (have not tested to see if this occurs in live market)

    1. I enter the position (inside of OnBarUpdate) by doing the following:

    a. set trailstop

    SetTrailStop(TradeType, CalculationMode.Ticks, TrailerSize, true);
    where TradeType is a striing I set and TrailerSize is a user entered integer

    b. establish a long position using a market order

    EnterLong(1,Convert.ToInt32(DefaultOrderQuantity), TradeType);


    2. On the primary data series (the chart)
    I test to see if price as exceeded a threshhold.
    If so, I submit an exitlong order on the secondary data series like this

    ExitLong(1,0, "","");

    The order and trailstop are established correctly, but the trailstop does not cancel after the position is exited.


    Is there something else I need to do to make sure the trailstop is removed?

    Thanks.







    #2
    Hello halgo_boulder,

    Please try using a signal name from the entry in the ext method instead of using a blank string to see if that helps. You used TradeType as the entries signal name, you can pass that to the exit as well to ensure it targets that specific entry and its position.

    JesseNinjaTrader Customer Service

    Comment


      #3
      OK I will give that a try thank you.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Clevchin, Today, 12:57 PM
      8 responses
      15 views
      0 likes
      Last Post Clevchin  
      Started by samish18, Today, 03:48 AM
      11 responses
      19 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by serman, Yesterday, 09:47 AM
      5 responses
      21 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by Salahinho99, 06-18-2024, 08:49 AM
      5 responses
      56 views
      0 likes
      Last Post JosephDavidsona  
      Started by kidpoker007, 05-30-2024, 01:43 PM
      13 responses
      144 views
      0 likes
      Last Post marcus2300  
      Working...
      X