Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

tagging orders with wildcards

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

    tagging orders with wildcards

    I have a strategy that gives multiple signals and orders.
    Till now I named all the orders the same, because I use only 1 way to handle all the Profit Targets, Stoploss and Trails.

    I now want to give the entry orders different names (tags) but allways with, lets say, the first 10 characters the same. Then follows a more specific tag.

    I use NT7 and a Managed Approach.

    My questions:
    1 Is it possible to work with different order tags but handle them (SL, TP, Trail) in 1 way, using wildcards to adress all the different order tags?
    2 Is it wise to work this way or is there a better way?

    Thanks in advance,
    Anne

    #2
    Hello Anne,

    Thank you for writing in.

    There is no built-in way to reference an order by the use of a wild card. The entire signal name of the order must be referenced.

    What you could do, however, is store each signal name string into a list and then just iterate through the list in order to grab each individual signal name string.

    As a quick example:
    Code:
    private IOrder order1 = null, order2 = null, order3 = null;
    List<string> signalNames;
    
    protected override void Initialize()
    {
        signalNames = new List<string>();
    }
    
    protected override void OnBarUpdate()
    {
        if (order1 == null)
        {
            order1 = EnterLong("long1");
            signalNames.Add(order1.Name);
        }
    
        if (order2 == null)
        {
            order2 = EnterLong("long2");
            signalNames.Add(order2.Name);
        }
    
        if (order3 == null)
        {
            order3 = EnterLong("long3");
            signalNames.Add(order3.Name);
        }
    }
    You can then iterate through the list to do something.

    The example below will just exit by utilizing the signal name for each entry:
    Code:
    foreach (string signalName in signalNames)
    {
         ExitLong(signalName);
    }
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Ok, thanks.

      Without having tried, is it possible to adress the order tag by a variable?
      For instance:
      EnterShort(QuantShort1, Shortnr1);
      instead of
      EnterShort(QuantShort1, "Shortnr1");

      And what are the possibilities in NT8 about more dynamic adress orders (and tags)?

      Comment


        #4
        Hello trail,

        You will be able to pass a variable containing a string.

        NinjaTrader 8 will still need the entire signalName when referring to orders.
        Zachary G.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        26 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 02-22-2024, 01:11 AM
        5 responses
        32 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, Yesterday, 09:53 PM
        2 responses
        49 views
        0 likes
        Last Post wzgy0920  
        Started by Kensonprib, 04-28-2021, 10:11 AM
        5 responses
        192 views
        0 likes
        Last Post Hasadafa  
        Started by GussJ, 03-04-2020, 03:11 PM
        11 responses
        3,234 views
        0 likes
        Last Post xiinteractive  
        Working...
        X