Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterLong() for multiple instruments?

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

    EnterLong() for multiple instruments?

    hello community,

    i am trying to achieve the following:
    I have a basket of stocks that get compared on relative strength and then sortet by lowest to highest value. Taking the last 5 values of the sorted list will give me a key/value pair of the instruments i want to buy. So i actually have for example (List<KeyValuePair<double, string>>):
    1.9, IEV
    1.67, QQQ
    1.51, EFA

    This works so far. What i now want is to actually EnterLong() on the three calculated positions, but i am unsure how to actually do that, since EnterLong() does not have a valid method for entering a specific instrument. Is it possible to compare my SYM string to anything? I am looking for something like:
    EnterLong("IEV");
    EnterLong("QQQ");
    EnterLong("EFA");

    Thanks for reading.

    #2
    Hello Puravida,

    Thank you for your post.

    You would need to use the overload method for EnterLong() of -
    EnterLong(int barsInProgressIndex, int quantity, string signalName)

    You would pass through the BarsInProgress that you want to submit the order to, then the quantity of the order, and then a signal name for tracking later.

    Example, to submit an order to the QQQ with IEV as my primary instrument, meaning the one that I am loading the strategy on.

    EnterLong(1, 100, "LongEntry");

    Here is a link on how BarsInProgress works and the EnterLong()
    http://www.ninjatrader.com/support/h...?enterlong.htm
    http://www.ninjatrader.com/support/h...inprogress.htm
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hi Cal and thanks for your response so far.

      That sounds like a plan, i am just unsure how i would determine the actual index for my top-5 instruments, since the sorting of the key/value list will make it impossible to match the index of the list to the initial BarsInProgress sorting by Add().

      Therefore, is there a shortcut possible to determine the BarsInProgress index if i have only the instrument name as string? Or do i have to tweak the list to save the initial index for later use (the long way)?

      Thanks for reading.

      Comment


        #4
        You can run the BarsInProgress Check for your script and have the name check as well.

        Example -
        if(BarsInProgress == 1 && Instrument.MasterInstrument.Name == "QQQ")

        http://www.ninjatrader.com/support/h...nstruments.htm
        Cal H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, Yesterday, 10:06 AM
        0 responses
        22 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        19 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        14 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        10 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        41 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X