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

Reset SetStopLoss

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

    Reset SetStopLoss

    How can SetStopLoss be reset back to default behavior of not doing anything?

    There are a number of threads about this, and none of them actually answer the question. They all talk about setting it to a large value that wont execute, but that is not reset. I want a true reset that will not submit any stop orders for a new entry. Is there a special value like double.MinValue that can be passed in to actually reset the function until a later call?

    #2
    Hello aslane,

    Thanks for your post.

    One approach you could take would be to only use signal names for your SetStopLoss. When an entry using a matching signal name as the stoploss, the stop loss would be used. If the entry does not match then no stop loss would be used.

    Here is a quick example you can test:

    if (CurrentBar == 500)
    {
    SetProfitTarget("myTest", CalculationMode.Ticks, 10);
    SetStopLoss("myTest", CalculationMode.Ticks, 10, false);
    EnterLong("myTest");
    }

    if (CurrentBar == 1500)
    {
    EnterLong();
    }

    What would happen is that the first entry would end with either the stop or target filled. In the case of the 2nd entry, it would end at the session (if exit on session set).

    I am unsure if the above approach would meet your needs so I will create a feature request to allow for the ability to "turn off" the Set methods. If this already exists, your vote will be added to it. In either case I will update this thread when I have further information on the feature request.



    Paul H.NinjaTrader Customer Service

    Comment


      #3
      So the answer is you can not do it, which is fine as I can work around it, but it would be nice to be able to disable it.

      Comment


        #4
        Hello aslane,

        Thanks for your reply.

        Correct, the set methods cannot be disabled.


        Paul H.NinjaTrader Customer Service

        Comment


          #5
          The only alternative is to use Enter and Exit methods directly such as:

          ExitLongStopMarket(...)
          ExitShortStopMarket(...)

          This is not as convenient as SetStopLoss, but you have more flexibility.

          In managed mode you would just call ExitLongStopMarket in each OnBarUpdate to keep it alive.

          If you are trying to emulate multiple stops or transitioning stops, like starting with a fixed stop and then transitioning to a trailing stop at X ticks above breakeven, you just need to track the stop price(s) yourself and update the stop order price on each bar.


          Steve L
          NinjaTrader Ecosystem Vendor - Ninja Mastery

          Comment


            #6
            Hello aslane,

            Thanks for your patience.

            The feature request has been created as SFT-4277, "Turn off SetStopLoss()".

            Thanks for your suggestion for improvement.
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            18 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            1 view
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            6 views
            0 likes
            Last Post Javierw.ok  
            Started by timmbbo, Today, 08:59 AM
            2 responses
            10 views
            0 likes
            Last Post bltdavid  
            Started by alifarahani, Today, 09:40 AM
            6 responses
            41 views
            0 likes
            Last Post alifarahani  
            Working...
            X