Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi Instrument trade entry coexistence

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

    Multi Instrument trade entry coexistence

    Hi,
    Seemingly simple problem.
    Multiinstrument strategy theoretically allows 2 instrument to be traded "simultaneously" so an assumption is if i have 1 position of FDAX there is no issue to have at the same tome 1 position of ES.
    Yet, not happening for me, probably some setting?
    Log:
    BarsInProgress account position is 2 has value Flat < have flat position
    Enter Long bar in progress 2 instrument FDAX time 2/17/2022 8:45:00 AM <- enter FDAX
    BarsInProgress account position is 4 has value Flat < different series flat
    Enter Long bar in progress 4 instrument ES time 2/17/2022 9:33:00 AM < try 1
    BarsInProgress account position is 4 has value Flat
    Enter Long bar in progress 4 instrument ES time 2/17/2022 9:34:00 AM < try 2 and so on

    While i have FDAX i cannot get ES. Using this: https://ninjatrader.com/support/help...l?position.htm This is for reference point.
    Code:... if ( Positions[BarsInProgress].MarketPosition == MarketPosition.Flat) // no position for given BarSeries

    Hm... ?

    -PNF




    #2
    Hello, thanks for writing in. There are two ways to enter the market with a multi instrument script.

    1. Call an entry order during the correct BarsInProgress. e.g. FDAX as the primary series, ES as the secondary series:

    if(BarsInProgress == 0)
    {
    if(<FDAX entry condition>)
    {
    EnterLong();
    }
    }

    if(BarsInProgress == 1)
    {
    if(<ES entry condition>)
    {
    EnterLong();
    }
    }

    2. Use the special overload that takes a BarsInProgress index:

    //this can be done anywhere in the code:
    //​EnterLong(int barsInProgressIndex, int quantity, string signalName)
    EnterLong(0, 1, "FDAXEntry");
    EnterLong(1, 1, "ESEntry");

    Also, make sure your EntriesPerDirection is set to at least 2.

    Comment


      #3
      Interesting, i actually using 1 approach to iota, which is not working and that is the reason i ask question, i will try Forum
      Also, make sure your EntriesPerDirection is set to at least 2. < i have 10.
      I will try. TY

      -PNF

      Comment


        #4
        Weeeeeeeeeeeeeeeeeelllllllllll.
        To put this simply --> not working

        Enter Long bar in progress 2 instrument FDAX time 2/18/2022 8:23:00 AM
        BarsInProgress account position is 4 has value Flat
        Enter Long bar in progress 4 instrument ES time 2/18/2022 10:41:00 AM
        BarsInProgress account position is 4 has value Flat
        Enter Long bar in progress 4 instrument ES time 2/18/2022 10:42:00 AM
        BarsInProgress account position is 4 has value Flat
        Enter Long bar in progress 4 instrument ES time 2/18/2022 10:49:00 AM​
        same issue!

        EntriesPerDirection = 10;



        if(isInMinList) //so current bar is minute bar
        {

        if ( Positions[BarsInProgress].MarketPosition == MarketPosition.Flat) // no position
        {

        if(Closes[BarsInProgress][0] <=<Condition>)
        {
        EnterLong(BarsInProgress,xxxr.instrName + " Long Entry");
        Print("BarsInProgress account position is " + BarsInProgress + " has value " + Positions[BarsInProgress].MarketPosition);
        Print("Enter Long bar in progress " + BarsInProgress + " instrument " + xxxr.instrName + " time " + Time[0].ToString());
        }
        // short side
        if(Closes[BarsInProgress][0] >=<condition> )
        {
        EnterShort(BarsInProgress,pos,xxxr.instrName + " Short Entry");
        Print("Enter Short bar in progress " + BarsInProgress + " instrument " + xxxr.instrName+ " time " + Time[0].ToString());
        }
        }

        }

        Any other suggestion?

        -PNF​

        Comment


          #5
          Hi, I would suggest starting with a simple test strategy just to prove that my concepts described in post Forum work. Your EnterShort/EnterLong overloads are not correct, you are using the overload:

          ExitLong(int quantity, string signalName, string fromEntrySignal)

          You need to use this one to target a specific series:

          ExitLong(int barsInProgressIndex, int quantity, string signalName, string fromEntrySignal)

          This is all documented in our help guide here for future reference:

          Comment


            #6
            Cris L.,
            You suggest using ExitLong, where i' asking EnterLong and provide snippet of the code that is nothing to do with Exit.
            Question was: 2 instruments i want to take position on both.
            What am i missing?

            -PNF

            Comment


              #7
              Hi, Sorry that was a mistake, I meant to provide the EnterLong() overload:

              EnterLong(int barsInProgressIndex, int quantity, string signalName)

              I see in your example you are using
              ​EnterLong(BarsInProgress,xxxr.instrName + " Long Entry");
              That would be this overload, so its using BarsInProgress as the quantity:
              EnterLong(int quantity, string signalName)

              Comment


                #8
                Yes, your reference is correct, my copy paste is not.
                It need to read:
                EnterShort(BarsInProgress,pos,xxxr.instrName + " Short Entry");

                Which i was actually using, sorry for confusion.
                Now the upmost interesting part:
                After i repear Installation as commission stop working i get 2 entries, as i expect, and this functionality working.
                Why commissions stop working i do not know.
                Using platform before with version 8.0, had no issue with commissions, now switch to 8.1.1.6 64bit, click run backtest, include commissions, get 0, check configuration per instrument it is not 0, for es, for ex. 2.23, why backtest is 0?


                So 2 functions interlace with each other I have multiple entries and no commissions or i have commissions and no multiple entries?
                How to make it working BOTH?


                -PNF

                Comment


                  #9
                  Hi, you will need to try two simple strategies just to prove that the issue you are seeing is coming from your code specifically and this is something that you are going to need to debug on your own. Set up each test that I suggested in Post number 2 with ES as the primary series (the series on the chart) and FDAX as the second series.

                  Kind regards,
                  -ChrisL

                  Comment


                    #10
                    Thank you.
                    I did overcome challenges on my side, now facing another one.
                    Have 4 instruments:
                    "ZB,
                    "FGBL",
                    "ZT",
                    "TN"
                    For backtest using year 2010 to 2022
                    Firsts 3 first trade execution 2010 on each
                    add 4th
                    ​First execution 2016 on each
                    Running only TN - first execution is 2016.
                    Not like this matter for real time, but for optimization timeframe does matter.
                    Was looking in the help on Ninjatrader did not find any reference.

                    Question: Is that expected behavior?

                    -PNF

                    Comment


                      #11
                      Hello, thanks for the follow up. If you print out the time stamps from the 4th data series when do these time stamps start?

                      if(BarsInProgress == 3)
                      Print("TIME " + Time[0]);

                      Comment


                        #12
                        Time 7/10/2016 6:01:00 pm

                        --pnf

                        Comment


                          #13
                          Ok, and.... ? Should not system trade what is available and not the common denominator time?! I still would be able to understand dynamics as ES did not start in 2018?
                          -PNF

                          Comment


                            #14
                            Hi, if you are only seeing the 4 data series start at 7/10/2016 then this is all the data you have available for this instrument.

                            Comment


                              #15
                              This is how to say "inaccurate", I trade only ZB - data is available from 2010, if i combine with TN in one strategy, data only magically available from 2016, including ZB, so both dataseries using lower data denominator. How this makes any sense? Data not available for ZB because of TN.
                              To me this make no sense.
                              -PNF

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by NullPointStrategies, Yesterday, 05:17 AM
                              0 responses
                              62 views
                              0 likes
                              Last Post NullPointStrategies  
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              134 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              75 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              45 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              50 views
                              0 likes
                              Last Post TheRealMorford  
                              Working...
                              X