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

Stop Loss in Real Time with COBC = True

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

    Stop Loss in Real Time with COBC = True

    Hi,

    I have a NT 7 strategy with a Stop Loss that I want to trigger in real time. According to this post, the Stop Loss should trigger in real time even if COBC = true.



    But my strategy does not have the Stop Loss trigger until the bar is closed with COBC = true.
    If I change the COBC = false, I do get the Stop Loss to trigger in real time, but then my strategy is updating in real time which I do not want.

    So am I missing something or is there another way to get this to work? My strategy works well with COBC = true, I just want the Stop Loss to trigger in real time.

    Thanks,

    Lee

    #2
    If you set a stoploss, its a real working order (sent to the broker) unless u are using a simulated one, which i doubt. so yeah, they are triggered in realtime and are from the point they are placed not affected by COBC conditions in your script - just like every other working order.

    however, that requires the order to actually already been placed while the "in decision bar" is being printed.

    are you sure this is the case?
    bc you cant exit the position based on a specific condition to be met while running COBC=true without having to wait till the bar is actually closed for ninjatrader to check if the condition is true.

    so im guessing that this is the problem.

    my approach to fix this problem:
    since i think u cant change the cobc within the onbar update method, to ensure your signal is running onbarclose(which i understand is what you want?) .

    you would have to outsource your signal to an indicator (that runs on barclose)
    you then would have to read out a boolseries from that indicator which should send ur strategy the entrysignal only on bar closed. and since you still would be able to run the strategy onbarclose=false, u could check for ur exit condition tick by tick from there on.

    look at this for more information on how to do this



    however. there might be a more convenient way. or maybe this isnt even the problem.
    im just guessing here based on the little information you provided

    Comment


      #3
      Hello lee612801,

      Thanks for your post.

      What method are you using to set your stop loss? (SetStopLoss())?

      Can you share that portion of your code where you are setting the stop loss?
      Paul H.NinjaTrader Customer Service

      Comment


        #4
        Hi Paul & BigRo,

        I am using SetStopLoss as in the following:

        protected override void Initialize ()
        {
        SetStopLoss(CalculationMode.Percent, .06);
        }

        I am using a sim account and testing the strategy in Market Replay. I was not able to get it to trigger using my strategy with COBC = true, but it could have been an issue with the session and the Replay getting hosed up (as it often seems to do). I will try it again later today and see if I continue to have the same problem.

        Thanks,

        Regards,

        Lee
        Last edited by lee612801; 11-10-2015, 01:30 AM.

        Comment


          #5
          Hello lee612801,

          Thanks for your reply.

          The SetStopLoss() method should work for you in Market replay regardless of the CalculateOnBarClose setting.

          While you are testing, you may want to change the setstoploss to use ticks as this will make it very clear where the stop actually is. SetStopLoss(CalculationMode.Tick, 10); // 10 tick stoploss
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            Hi Paul,

            Its very strange. I changed it to ticks, and it worked immediately. But when I use percent, it will not trigger in real time unless I refresh after it should have triggered. I guess my back up plan is to have a separate strategy running that only looks at stoploss, but its not preferred.

            If you can think of anything else,let me know.

            Regards,

            Lee
            Last edited by lee612801; 11-13-2015, 09:52 PM.

            Comment


              #7
              Hi Paul,

              I think I figured out the problem. I can see the position entered on the chart, but NOT in the order list. So the stop loss wont execute if there is no current order... makes sense. But it will work for the COBC = false becuase it immediately places the order and therefore the stop loss will execute.

              So now I know the problem, but don't know how to fix it. So I will close this thread and start a new one to see if there are any ideas out there on how to solve this.

              Thanks,

              Lee

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by rocketman7, Today, 09:41 AM
              3 responses
              7 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by traderqz, Today, 09:44 AM
              2 responses
              4 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by stafe, 04-15-2024, 08:34 PM
              8 responses
              40 views
              0 likes
              Last Post stafe
              by stafe
               
              Started by rocketman7, Today, 02:12 AM
              7 responses
              31 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by guillembm, Yesterday, 11:25 AM
              3 responses
              16 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X