Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

stoploss modification

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

    stoploss modification

    Hi,
    I got issues developping a strategy which have to modify the stop loss the error I get is in french but the traduction will give something like the variable is used before it is instanciated. I understand why I can get such error, but not how to deal with it since it is caused but a SetStopLoss method. I explain my code: I have a method for setting an initial stoploss and call the enterLongLimit method, one other method is waiting for some condition to raise and then call the setstoploss again to modify the stop. Still the condition can raise at any time it is possible that I call two times the setstopLoss method before the trade is filled. Is it problematic? I should also notice that because I have a lot of trades at the same moment I use tags to identify my trade.
    I did some tests and it seems to be my order who disappear so I can't use the Tag, I can save the tag, but there is any explanation of why my order disappear (== null) after it is filled.

    Thank you in advance,
    R.E.

    #2
    Hello snoppss,

    Thank you for your post.

    It should be fine to call the SetStopLoss twice before the fill, however I would recommend not calling it in the Initialize() at all if adjusting in OnBarUpdate(), and make sure it is not adjusting based on a fill or position before the fill or position exists.

    Comment


      #3
      Hi,
      Thank you for your answer, I am making some tests and it shows up that I am trying to modify the stop loss after the order is filled like what is specified here: http://ninjatrader.com/support/forum/showthread.php?t=3222. The major difference is that I use the order after it is filled (I need his name to modify the specified stopLoss), and that I added now a boolean to make sure the order is filled (I used the onOrderUpdate method) before trying to modify the stop loss.

      I noticed something weird: I have noticed that the error message in the log is showed 5 seconds before the order is declared filled (in the log). Is it due to the fact that the error messages have a special buffer flushed each time there is a message to be showed, or the strategy use multiple threads and I have to pay attention to this, or I am missing something about "event programming".

      Thank you in advance,
      R.E.

      Comment


        #4
        Hello snoppss,

        It is more likely the states the orders go through, but I cannot say for certain on the delay without looking at the Log and Trace files.

        Please send me your log and trace files for today so that I may look into what occurred.
        You can do this by going to the Control Center-> Help-> Mail to Platform Support.
        Please refer this thread in the e-mail: "http://ninjatrader.com/support/forum/showthread.php?t=77308"

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        576 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        553 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X