Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Q on Strategy Analyzer and multiple instruments within a single strategy

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

    Q on Strategy Analyzer and multiple instruments within a single strategy

    I want to optimize a strategy that trades multiple instruments; how do I do this in the strategy analyzer? I see I can select multiple instruments in a list to run on the same strategy, but that isn't the same as running one strategy that trades different instruments. If I select, say, NQ 06-22 as the instrument and my strategy trades the YM 06-22 as well, will it do that? Is it capable of doing so in an indirect way? Thank you

    #2
    HI Austiner, thanks for posting. The Analyzer needs you to pick a primary instrument, and you will add more instruments to the script using AddDataSeries. To submit an order to the second series use the special order entry overload that takes a BarsInProgressIndex parameter e.g.

    EnterLongLimit(int barsInProgressIndex, bool isLiv eUntilCancelled, int quantity, double limitPrice, string signalName) //pass in 0 for primary series, pass in 1 for secondary series.
    ExitLongStopMarket(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double stopPrice, string signalName, string fromEntrySignal) //pass in 0 for primary series, pass in 1 for secondary series.

    Kind regards.

    Comment


      #3
      Hi Chris,

      Huge help, thank you! I am about to build the code to start testing this, but I need to know before I do.

      My strategy uses the GetAccount.CashValue type variables to determine exits for certain trades, I have an example below of what the strategy will be doing and please let me know if the strategy analyzer is capable of this:

      Enter long NQ from conditions on a 1 min candlestick chart
      Enter short on YM from conditions on a 1 min candlestick chart
      Constantly check to see total account liquidation
      Once the total liquidation is at +$100 profit, immediately exit both trades for their respective instrument

      My Q is: can the analyzer
      1. Log entries against multiple instruments within a single strategy (the NQ long entry and the YM short entry as above).
      2. See the net liquidation of the total account value taking these two trades into account to see when their combined liquidation shows +$100 profit and then exit?
      3. from your response, it sounds like if I had NQ as the single instrument, and the strategy had the AddDataSeries and intbarsInProgressIndex code for YM as well and it's respective trades, the analyzer would execute the above in 1. and 2. can you confirm?

      I assumed the "lists" can't do this, but I might be wrong as it would make my life a lot easier so I am now asking for you to clarify if the "lists" function in the instrument drop down can do this: If I select a strategy and then select as the instrument a list that includes NQ and YM, and the strategy uses the GetAccountItem.NetLiquidation but the strategy doesn't have the code to trade NQ and YM within it - just one instrument. Does the strategy analyzer now run that strategy against my account independent of the other instruments? or could it calculate exits in the same way as the above in 1. and 2.? As in: would it wait for NQ trade to get to +$100 profit and exit the NQ trade alone and separately wait for the YM trade to get to +$100 profit and exit the YM trade alone (this would be executing the strategies independently), or would it understand the account net liquidation against each of those trades together, and exit both when the total account net liquidation showed +$100 (this would be executing in 1 and 2).

      In the end, I am looking to optimize the +$100 as a variable - at what profit would yield the least drawdown. I can do the code, but need these Q answered to understand the easiest way for the strategy analyzer to optimize this.

      Thank you!


      Comment


        #4
        Hi Austiner, thanks for the follow up.

        The strategy analyzer will log each trade it takes. Set the view at the top left to Trades to see each trade taken by the strategy. The account balance or any account value will not be changed when the optimization is happening, so you should make a private variable within the script itself that represents the cash value of the account and manage this value within your script for backtests. Running a backtest or optimization against an instrument list will vary the primary instrument used for the backtest, so any instruments added with AddDataSeries will stay the same.

        Kind regards,
        -ChrisL

        Comment


          #5
          Hi Chris,

          Thank you for all the help: need help with this line of code:

          EnterLongLimit(int barsInProgressIndex,bool isLiveUntilCancelled,Convert.ToInt32(DefaultQuanti ty),GetCurrentBid(0),@"MYM 1");

          primary instrument is NQ, secondary is MYM - ref the signal name. I added the MYM as a secondary data series. Just need help on how to pass in a 1 for the int barsInProgressIndex

          or anything else that may be incorrect. Thank you!

          Further, I noticed that I can only add in data series as MYM 03-22 on the builder, do I add MYM ##-## to get the current contract no matter the date?

          Comment


            #6
            Hi Austiner, Im happy to help. Simply pass in a 1 to target the second series:

            Code:
            EnterLongLimit([B]1[/B],true,Convert.ToInt32(DefaultQuantity),[B]GetCurrentBid(1)[/B],@"MYM 1");
            This is not possible to do through the builder, the script needs to be unlocked to use this overload.

            The continuous contract is not supported on the Continuum connection, to trade an instrument it needs to be a hard coded expiry.

            Best regards,
            -ChrisL

            Comment


              #7
              Hi Chris/NT8 team, need a bit of help coding the Exits too; getting this error on the screenshot. your help is very much appreciated!

              Attached Files

              Comment


                #8
                Hi Austiner, thanks for the follow up.

                The overloads are documented here for reference. The help guide will have the correct syntax and all overloads for all possible activities that can be used in the scripting library:



                We do recommend those writing their own scripts to be at least an intermediate level in object-oriented C# programming. One should be comfortable with creating objects and calling methods in C# to get the most out of automated strategies and make the development process easier. The compile error you are getting means the parameter list is not correct. Make sure to fill in each parameter as its documented:

                ExitShortLimit(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double limitPrice, string signalName, string fromEntrySignal)

                fromEntrySignal is a string and will be the exact same string you gave to the entry order you want to exit.

                Kind regards,
                -ChrisL

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Yesterday, 05:17 AM
                0 responses
                72 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                143 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                76 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                47 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                51 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X