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 Order not submitting

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

    SetStopLoss Order not submitting

    Hello,

    I have small catch in this code, i am not getting it work. Basically i want to submit stop loss order to low of previous bar of entry condition bar. But i am getting error after multiple tries. Can you suggest what is going wrong. I am also using Exit On Close.
    Attached Files
    Devdas
    NinjaTrader Ecosystem Vendor - Devdas

    #2
    Hello..... Some one here ?
    Devdas
    NinjaTrader Ecosystem Vendor - Devdas

    Comment


      #3
      hello devdas,

      Thanks for your post and patience.

      Have you tried printing the signalBar_low value just before you set the stoploss just to make sure of the value?
      Paul H.NinjaTrader Customer Service

      Comment


        #4
        Hi Paul,

        thanx for looking it here.

        As you suggest i printed that value and it seems ok, i checked maually on all 8 trades.
        But 2 of them as its clear that stop order didnt executed. Notie also the error on log is still generating. May be that error is due to setting signalBar_low = 0 when it gets Flat. But i am not sure that is causing any problem.

        One more thing , i am setting a huge value of initial Stop Loss in Initialize() to ensure that Calculated Stop is used for trigger.I have used ST = 200,000 in that. I set this huge values because on smaller value strategy was not using Calculated Stop Price rather than hitting Stop order with smaller values.
        Attached Files
        Devdas
        NinjaTrader Ecosystem Vendor - Devdas

        Comment


          #5
          Hello,

          Thanks for your reply.

          Does it make sense to add a condition, where you set your stop loss, to first test if the current bar low is less than or equal to the low 1 bar ago? Or perhaps check the difference between the current Low and the Low[1] and if less than some value set your stoploss at some other value?
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            Well thats very annoying and confusing me more.
            I cant understand why i need to compare CurrentBar Low to Low[1] ?
            As i am using CalculationMode.Price then any price lower than entry price i can set for Stop Loss in case of Long and it should be submitted as soon as long triggers.

            Well i set lower Value of ST = 300 ticks and now error is not appearing but also number of prints of signalBar_low in output is also reduce. Trades that hit stop with ST = 300 ticks are absent from that. Look at prior post figures, first print value of 7798.4 is absent now from here and corresponding trade had hit the stop with ST = 300 ticks.

            Looks also next trade with signalBar_low = 8451.05 which never retraced and hence its signalBar_low value is appearing in output.

            I have attached snap of current code also with slight modification like commenting the line
            signalBar_low =0;
            Attached Files
            Devdas
            NinjaTrader Ecosystem Vendor - Devdas

            Comment


              #7
              Hello devdas,

              Thanks for your reply.

              Sorry if this is confusing but I only know what snippets of your code you share and evidence of results so I am guessing at what the issues are. I suggested a comparison from the Low 1 bar ago to the current bar low to ensure that price had not retraced, is that not possible or do you have other code that checks for this?
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                Hello Paul.

                I got it working. Actually catch was "DoneForSession" variable and i guess to some extent fix Stop Value ST. Ultimately its comparing the User Calculated Stop to Fix Stop for submission, this is what i am taking this from it.
                I need to set ST = 10000 ticks which is relatively large value compared to session range we get. But again too high value again threw error as before.
                Attached Files
                Devdas
                NinjaTrader Ecosystem Vendor - Devdas

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by geddyisodin, Today, 05:20 AM
                2 responses
                16 views
                0 likes
                Last Post geddyisodin  
                Started by hazylizard, Today, 08:38 AM
                0 responses
                6 views
                0 likes
                Last Post hazylizard  
                Started by Max238, Today, 01:28 AM
                5 responses
                42 views
                0 likes
                Last Post Max238
                by Max238
                 
                Started by giulyko00, Yesterday, 12:03 PM
                3 responses
                13 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by habeebft, Today, 07:27 AM
                1 response
                16 views
                0 likes
                Last Post NinjaTrader_ChristopherS  
                Working...
                X