Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-Instrument Strategy

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

    Multi-Instrument Strategy

    Hi,

    My aim is to built a strategy which make few calculations on an instrument and based on few conditions enter Long to 2th instrument and enter Short to a 3th instrument( Actually I want to go Short in a basket of instruments).

    To be more understandable lets say

    Condition: EMA(5) > EMA(13) on EURUSD
    Order: Enter Long on EURGBP
    Condition EMA(5)< EMA(13) on EURUSD
    Order: Close Long position and Enter Short on USDJPY

    I have already made a code but when I going to back test it is not giving me any results. A part of my code is below

    #region Variables
    // Wizard generated variables
    private string shortInst = @"USDJPY"; // Default setting for ShortInst
    private string longInst = @"EURGBP"; // Default setting for LongInst
    private string signalInst = @"EURUSD"; // Default setting for SignalInst

    // User defined variables (add any user defined variables below)
    #endregion
    if (EMA(5)[0]>EMA(13)[0])

    {
    //Enter a long position on a basket of EM currencies
    EnterShort(1,shortInst);
    }

    //Check if the momentum Fast EMA is lower than Slow EMA, change in trend
    if ( EMA(5)[0]< EMA(13)[0])

    {
    ExitShort();
    EnterLong(1,longInst);
    }
    Do you have any thoughs why this is not working? Thanks

    #2
    Loukas, I'm seeing you adding any instruments to your strategies first in the Initialize() - to get a working sample for this process it would best to start off by reviewing the SampleMultiInstrument installed per default with NT.

    More documentation on MultiSeries work is also located here:

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply.
      I made few changes but is still doesnt submit any trades. My concerns are around the EnterLong() statment.
      Initialize()
      index value of 0
      // Add("USDGBP",PeriodTypr.Day,1);
      // index value of 1
      Add("USDMXN",PeriodType.Day,1);
      // index value of 2
      Add("EURUSD",PeriodType.Day,1);
      OnBarUpdate()

      if (CrossAbove(RSI(14, 0), 30, 1))
      {
      //Enter a long position on a basket of currencies. It is applied on Index Value 1
      EnterShort(1,shortInst);
      }

      In English it means : Enter a short position on USDMXN when RSI of USDGBP cross above 30?

      Comment


        #4
        Any errors in the log tab, this should be the first place to check if you run into any unexpected issues?

        Please try with a $ sign in front of your FX spot symbols, so :

        // Add("$USDGBP",PeriodTypr.Day,1);
        // index value of 1
        Add("$USDMXN",PeriodType.Day,1);
        // index value of 2
        Add("$EURUSD",PeriodType.Day,1);

        Please also use this EnterLong overload for MultiSeries use, so you can specify to which BIP to submit:

        EnterLong(int barsInProgressIndex, int quantity, string signalName)
        BertrandNinjaTrader Customer Service

        Comment


          #5
          At the Logs tab the message is that
          "The strategy has called the Add[] method with an invalid instrument. The USDMXN does not exist..."
          I made the adjustment this the symple "$". The is not any compile error but is still not making any trades.

          I am not sure about EnterLong() if has the correct structure

          if (CrossAbove(RSI(14, 0), 30, 1))
          {
          //Enter a long position on a basket of EM currencies. It is applied on Index Value 1
          EnterShort(1,1,shortInst);
          }
          It checks the Cross of RSI on USDGBP( index 0) and enter a Short on USDMXN(index 1). EnterShort( index number, quantity, signal name)

          Shall I send you the strategy to file to have a better view?
          Thanks

          Comment


            #6
            Did you reload the strategy fresh after making the needed code change to correctly call the added series? Yes, if you can attach the code that would help as I can then give it a run here for testing.

            Thanks,
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Please have a look at the attachement
              Attached Files

              Comment


                #8
                Loukas, your entry conditions are too restrictive. I ran your strategy on $EURCHF as the main instrument, $EURUSD as secondary, and $USDCAD as tertiary instrument (because we don't have USDMXN access) over a 2 year backtest and the conditions for entry were not triggered at all.

                I placed some print statements in the code to help you see what is actually going on. Did you look at the SampleMultiInstrument strategy Bertrand referenced? None of your code is in a BarsInProgress, so the main conditions are checked for every series on every bar, which would make debugging extremely difficult.

                Please take a look at the re-attached strategy, especially the comments I've revised.

                Let me know if you have questions.
                Attached Files
                AustinNinjaTrader Customer Service

                Comment


                  #9
                  I didnt manage to solve the problem. I have entered the BarInProgress statment but I didnt understand which is the correct way to send an order for other instruments. I have attached an update of the strategy. Thanks
                  Attached Files

                  Comment


                    #10
                    In my testing here on a daily chart I see trades for your added instrument - your conditions run off BIP0, so the primary series and send then trades to index 1 and 2 - what issues are you seeing? The added series are used internally only and are not visualized if your run for example from your primary chart or Strategy Analyzer backtest.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Sorry it was my mistake. I would like to make the following changes, instead of going long a single currency I want to going Long a basket of cuurencies. Do you have any ideas about it?

                      Comment


                        #12
                        No worries, if you would like to execute in several symbols you could issue multiple Enter() calls to different series.
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Is there a multiple Enter() statment or I have to enter one by one ?

                          e.g

                          Add("$USDCAD",PeriodType.Day,1);
                          Add("$USDJPY",PeriodType.Day,1);

                          .....
                          .....

                          EnterShort(1,1,shortInst);
                          EnterShort(2,1,shortInst);

                          Comment


                            #14
                            Originally posted by Loukas View Post
                            Is there a multiple Enter() statment or I have to enter one by one ?

                            e.g

                            Add("$USDCAD",PeriodType.Day,1);
                            Add("$USDJPY",PeriodType.Day,1);

                            .....
                            .....

                            EnterShort(1,1,shortInst);
                            EnterShort(2,1,shortInst);
                            This would be the way to go here Loukas.
                            BertrandNinjaTrader Customer Service

                            Comment


                              #15
                              I have tried the way below to enter a multiple Enter() statment but it send only an order for the first bar object only (USDCAD) . I tried to connect the EnterShort() statments with "&&" but it is not working neither. Do you have any ideas about it?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by andrewtrades, Today, 04:57 PM
                              1 response
                              5 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by chbruno, Today, 04:10 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post chbruno
                              by chbruno
                               
                              Started by josh18955, 03-25-2023, 11:16 AM
                              6 responses
                              436 views
                              0 likes
                              Last Post Delerium  
                              Started by FAQtrader, Today, 03:35 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post FAQtrader  
                              Started by rocketman7, Today, 09:41 AM
                              5 responses
                              19 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X