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:	129
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 Mindset, 04-21-2026, 06:46 AM
            0 responses
            90 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            137 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            68 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            120 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            71 views
            0 likes
            Last Post PaulMohn  
            Working...
            X