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:	107
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 argusthome, 03-08-2026, 10:06 AM
            0 responses
            116 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            61 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            40 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            43 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            82 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X