Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy not executing Stops / Take Profits / Brackets.

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

    Strategy not executing Stops / Take Profits / Brackets.


    I have a very simple strategy which enters three orders : a entry, a stop, and a take profit at once. The strategy will enter but the stop and take profit are always ignored. Why?



    HTML Code:
                Print("StartShort");
                Draw.VerticalLine(this, "StartShort", Time[0], Brushes.Red);
                Draw.HorizontalLine(this, "EnterShortStopMarket", Close[0] + 8, Brushes.Red);
                Draw.HorizontalLine(this, "StartShort2", Close[0], Brushes.Yellow);
                Draw.HorizontalLine(this, "EnterShortLimit", Close[0] - 8, Brushes.Green);
                EnterShort();
                EnterLongMIT(Close[0] + 8);
                EnterLongMIT(Close[0] - 8);​
    I have also tried different variations such as EnterShortStopLimit and ExitShortLimit without success.


    Click image for larger version

Name:	image.png
Views:	117
Size:	19.4 KB
ID:	1327840

    #2

    protected override void OnBarUpdate()
    {
    if (CurrentBar < 20)
    return;

    // Only enter if at least 10 bars has passed since our last entry
    if ((BarsSinceEntryExecution() > 10 || BarsSinceEntryExecution() == -1) && CrossAbove(SMA(10), SMA(20), 1))
    EnterLongMIT(GetCurrentBid() + TickSize, "SMA Cross Entry");
    }​

    Comment


      #3
      Have you tried declaring your stops and TP. Separate modules for EnterLong() and EnterShort().

      Comment


        #4
        More Information is explained in ' NinjaTrader 8 SubmitOrderUnmanaged from an Indicator' above question.

        Comment


          #5
          EnterLongMIT(GetCurrentBid() + TickSize, "SMA Cross Entry");
          I am not sure I follow. I have no problem with the initial order entry, however the stop / target is not being respected.

          Have you tried declaring your stops and TP. Separate modules for EnterLong() and EnterShort().


          - I do not understand a 'module' in the C# context. I understand modules as a java concept. We usually use the term assembly in C#.
          - I have used a few APIs including EnterShort and EnterShortLimit and EnterShortStopLimit which includes an argument for a stop.

          More Information is explained in ' NinjaTrader 8 SubmitOrderUnmanaged from an Indicator' above question.
          I read through the post and it is not clear what the solution is. The post looks related in topic, and there are two pages of back and forth which is not a great sign.


          It is very strange that this very minimal code would not work and it looks like it is a common problem. Is there a configuration somewhere I could look at which manages this aspect of ordering and may be preventing this code from running.
          Last edited by nicthe; 12-14-2024, 03:18 PM.

          Comment


            #6
            Hello nicthe,

            The code you have in your first post is not valid, the managed approach does not support bracketing the market. You are also trying to combine a regular market order which will always fill with market if touched orders which will only fill based on the criteria set, the order types you have now would always enter short and then sometimes become flat if you were using the unmanaged approach. You can find a sample of how to make bracket orders here:

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            81 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            42 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            64 views
            2 likes
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            66 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            54 views
            0 likes
            Last Post CarlTrading  
            Working...
            X