Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple Bracket Orders?

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

    Multiple Bracket Orders?

    I am new to the platform but VERY excited and have made a lot of progress since the 3 days I've started.

    I have now created my custom indicator and interested in turning it into a strategy.

    Consider this:

    When developing a LONG strategy, is it possible to to create 4 bracket orders at once, where I can specifically define the stop price, the type (trailing vs market) and the profit targets "manually"? If it is not too much to ask and you perhaps have a code sample, I'd buy you a beer!

    By manually I mean my script will calculate the share size based at the time of entry and stop and likewise the profit targets.

    Secondly, I am interested in a strategy that will calculate per tick, however, is there a built in a way to say "only enter of the condition has been met N times"?

    As you know calculations on tick can generate a "false positive" or sorts and the idea is to "confirm the long" if the condition is met over N ticks. Makes sense?

    Thank you kindly for this great platform, support and community. I am very impressed with everything I am seeing so far and signing up for all webinars.


    #2
    Hello focus333, thanks for writing in.

    When you call any entry order in the NinjaScript library, there is an overload that takes a SignalName property that can be used to give your orders a unique ID e.g. EnterLong(int quantity, string signalName)

    With that same signal name, you can specify stops and targets for that entry with SetStopLoss and SetProfitTarget.




    So the idea here is:

    SetStopLoss("Entry1", CalculationMode.Ticks, 10, false); //Set protective orders before the entry is made.
    SetStopLoss("Entry2", CalculationMode.Ticks, 20, false);

    EnterLong(1, "Entry1");
    EnterLong(2, "Entry2");

    In C# you can create any user variable you want, so if this idea could be as simple as a counter property that counts up.

    private int counter = 0;

    OnBarUpdate()
    {
    if(EntryCondition)
    {
    counter++;
    if(counter > 4)
    {
    EnterLong();
    }
    }

    if(ExitCondition)
    {

    ExitLong();
    counter = 0;

    }
    }

    Since C# can do a lot of things, I would recommend you test your code as much as possible to get the desired output. Use the Print() method to print out data to the output window and strategically place your Prints through the OnBarUpdate method to see when certain code is being hit and what conditions are being skipped. e.g.

    OnBarUpdate()
    {
    Print("Checking Condition");
    Print(EntryCondition);
    if(EntryCondition)
    {
    Print("Condition True");
    EnterLong();
    }
    }

    Please let me know if I can assist any further.

    Comment


      #3
      Thank you for your reply NinjaTrader_ChrisL !

      How do I go about setting the different types of stops? For example, trailing stop?

      Comment


        #4
        Hello focus333,

        Thanks for your reply.

        Chris has already provided a link to the Set stop loss method.

        The help guide provides all the information needed and a good place to start is here: https://ninjatrader.com/support/help...d_approach.htm this will provide an overview that will be helpful to understand some of the order relationships and requirements.

        Through that link you can access all of the order types available and on each page you will find tips and warnings for these orders.

        Comment


          #5
          My bad, I missed that. Thank you.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          38 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          64 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          41 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X