Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Position Left Over

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

    Position Left Over

    Hi,
    I have an odd situation and I'm not sure if it's due to something I'm doing wrong or if it's a quirk of how NT closes positions. I'd be grateful for any suggestions.

    I'm using NT to simulate trades whilst taking a live feed from eSignal. The strategy I've developed works fine on historical data but in real time I get the following scenario (the price values shown are examples but the stops etc. are genuine)

    Buy at market, 6 contracts, at 6,820 stop loss 20 points away at 6,800


    Order fills as follows:
    3 contracts @ 6,820.0 stop loss at 6,800.00
    3 contracts @ 6,820.5 stop loss at 6,800.50


    Price goes above 6,845 so strategy now moves the stop loss to lock in 5 points of profit and the result is as follows:
    3 contracts now have the stop loss at 6,825.00
    3 contracts now have the stop loss at 6,825.50
    Price goes above 6,870 so the strategy now does the following:


    Sell at market to exit long, 4 contracts at 6,870 and move stop loss to 20 points away, which is 6,850. The result is as follows:
    4 contracts sold at 6,870
    Stop loss for 3 contracts now at 6,850
    Stop loss for 3 contracts now at 6,850 (no, that's not a typo)
    So now I've got a position of 2 contracts but stop loss for 6!


    Price goes up to 6,880 so now use setstoploss to set it to 20 points away so I get this scenario:
    Stop loss for 3 contracts now at 6,860
    So now I've got 1 stop loss but it's for 3 contracts!
    Price goes below 6,860 and I now have this situation:
    Long position closed at 6,860
    Short position for 1 contract now open at 6,860
    I'm using setstoploss to adjust the stops and I've used traceorder to see what's happening. This only happens when I get multiple fills for an order. If I everything gets filled at one price in on execution than this works fine.

    Any suggestions/comments gratefully received.

    Thanks - Stefan

    #2
    For clarification -

    Is this through the DLL interface from eSignal to NinjaTrader?
    RayNinjaTrader Customer Service

    Comment


      #3
      I'm using the eSignal Real Time connection to get the data from the eSignal Data Manager. The strategy is written as a script within NT.

      Not sure if that answers the question.

      Comment


        #4
        So in the following, you are saying your strategy has stops in place for 6, you send market order to exit 4 which leaves you 2 but the stops are still for 6? Do you use signal names? If yes, are these specified in the SetStopLoss() and ExitLong() methods?

        Sell at market to exit long, 4 contracts at 6,870 and move stop loss to 20 points away, which is 6,850. The result is as follows:
        4 contracts sold at 6,870
        Stop loss for 3 contracts now at 6,850
        Stop loss for 3 contracts now at 6,850 (no, that's not a typo)
        So now I've got a position of 2 contracts but stop loss for 6!
        RayNinjaTrader Customer Service

        Comment


          #5
          Ah, I've had another look at the script and I do use the signal name for the stop loss however the exitlong() just uses the quantity.

          Also, I use multiple timeframes for entries so should probably use the full ExitLong(int barsInProgressIndex, int quantity,string signalName,string fromEntrySignal) overload method instead of the simple version.

          I assumed that because the system exited the correct number of contracts at the correct price I wouldn't need to specify the additional fields.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by 1001111, Today, 01:35 AM
          0 responses
          1 view
          0 likes
          Last Post 1001111
          by 1001111
           
          Started by ETFVoyageur, Yesterday, 07:05 PM
          1 response
          15 views
          0 likes
          Last Post ETFVoyageur  
          Started by MarianApalaghiei, Today, 12:35 AM
          1 response
          7 views
          0 likes
          Last Post MarianApalaghiei  
          Started by Rogers101, 05-05-2024, 11:30 AM
          17 responses
          56 views
          0 likes
          Last Post Rogers101  
          Started by haas88, 03-21-2024, 02:22 AM
          13 responses
          154 views
          0 likes
          Last Post haas88
          by haas88
           
          Working...
          X