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 charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        59 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        143 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        161 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        97 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        276 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X