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

SetStopLoss & SetProfitTarget problem

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

    SetStopLoss & SetProfitTarget problem

    I'm encountering a problem with these two functions. I'm not sure if it's a problem with the strategy code or the strategy analyzer. I'll create a simple strategy that has SetStopLoss/SetProfitTarget in Initialize(). Create orders with EnterLong() or EnterShort(). Backtest it in the Strategy Analyzer.

    Everything will work fine for so many trades. Then it will ignore the StopLoss/ProfitTarget and keep a trade open for the rest of the backtest.

    I've checked over the order log, everything looks ok. The Stops and Limits are being issued. Then I see "Profit Target, Stop Loss, Buy, Exit on Close." The exit on close price is far above the stop/profit level, like they were not there.

    I wrote many simple strategies and all had this problem. I downloaded the sample code from http://www.ninjatrader-support.com/v...ead.php?t=3222

    and it also failed in the exact same way.

    Has anyone encountered this problem?
    Last edited by pauljff; 10-09-2007, 11:36 AM.

    #2
    Someone will follow up with you later today on this.
    RayNinjaTrader Customer Service

    Comment


      #3
      That is very interesting pauljff. Does there seem to be a set number of trades before it starts messing up or does it seem like its random?

      If you don't mind could you attach the log files and point me at the point of interest?
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        After fooling around with it for hours I think found the problem... in the Strategy analyzer "Time in Force" was set to "Day." I set it to GTC and my strategy worked fine. I'm guessing if the stop/profit orders weren't hit by the end of the trading day they expired, and then the position stayed open forever? (I am writing Strategies for Forex so end of day isn't a problem for me.)

        Maybe add a warning to the manual (if there isn't already one) so no one else goes crazy fighting with this.

        Comment


          #5
          Glad to here you resolved this. Thanks for the suggestion.
          Josh P.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by TraderBCL, Today, 04:38 AM
          2 responses
          14 views
          0 likes
          Last Post TraderBCL  
          Started by martin70, 03-24-2023, 04:58 AM
          14 responses
          105 views
          0 likes
          Last Post martin70  
          Started by Radano, 06-10-2021, 01:40 AM
          19 responses
          607 views
          0 likes
          Last Post Radano
          by Radano
           
          Started by KenneGaray, Today, 03:48 AM
          0 responses
          4 views
          0 likes
          Last Post KenneGaray  
          Started by thanajo, 05-04-2021, 02:11 AM
          4 responses
          471 views
          0 likes
          Last Post tradingnasdaqprueba  
          Working...
          X