Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using signals generated from one ticker to trade another ticker

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

    Using signals generated from one ticker to trade another ticker

    Hi,

    I want to use signals generated from one ticker to enter positions in another ticker.
    The 2nd parameter of the function EnterLong seems to allow me to do that, but it isn't working. The positions are still entered off the original ticker in which the indicators are computed.

    Let's say I want to generate signals off VXAPL, and then trade off AAPL. How should I do it?

    EnterLong(DefaultQuantity,
    "AAPL"); ?

    #2
    Hello karfey,
    You have to create a multi-instrument strategy to do it.

    Please refer to our help guide to know more about multi-series concepts.
    http://www.ninjatrader.com/support/h...nstruments.htm
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Thanks for the links. I am still facing some issues getting the strategy to work. It can compile, but no trades are generated from the strategy. May I trouble you to take a look at the very short script below? The context is that the primary data is drawn from VXAPL (given index value of 0), and the trading is done off AAPL (given index value of 1).

      protectedoverridevoid Initialize()
      {
      CalculateOnBarClose =
      true;
      Add(
      "AAPL", PeriodType.Day, 1);
      //given index value of 1.
      //This is the line which causes trades to NOT be generated

      }
      ///<summary>
      /// Called on each bar update event (incoming tick)
      ///</summary>
      protectedoverridevoid OnBarUpdate()
      {
      // Condition set 1 on index signal 0 (attached to VXAPL)
      if (Close[0] > SMA(15)[0]
      && SMA(
      15)[0] > SMA(30)[0])
      {

      EnterLong(1,DefaultQuantity, "");
      //using the overloaded EnterLong(int BarsInProgressIndex,int //Quantity, string Signalname)

      }


      }

      #region Properties
      #endregion
      }
      }
      Last edited by karfey; 01-23-2013, 04:44 AM.

      Comment


        #4
        Ok, I've gotten it to work.

        by adding:
        // Condition set 1
        if (Close[0] > SMA(BarsArray[0],15)[0]
        && SMA(BarsArray[
        0],15)[0] > SMA(BarsArray[0],30)[0])

        Another question:
        what if I want to reference index1 for Close[0]?
        How should I go about doing it?

        Thanks.

        Comment


          #5
          Hello karfey,
          You can uses the Closes series to refer to the additional series. Please refer to our help guide to know more about it.
          http://www.ninjatrader.com/support/h...tml?closes.htm
          JoydeepNinjaTrader Customer Service

          Comment


            #6
            Hi, my objective is to simply plot the closing price of a ticker onto another as an indicator. However, the code snippet below does not pick up the secondary price. It simply doesn't plot. Can you please tell me where have I gone wrong?

            publicclass ClosePrice : Indicator
            {
            protectedoverridevoid Initialize()
            {
            Add(
            new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
            Add(
            "AAPL", PeriodType.Day, 1);
            Overlay =
            true;
            }
            protectedoverridevoid OnBarUpdate()
            {


            //Plot0.Set(Close[0]); //this line plots successfully

            Plot0.Set(Closes[1][0]); //this line fails to plot
            }

            Thanks!

            Comment


              #7
              Hello karfey,
              To assist you further may I know:
              • Are you trying to apply the indicator on a chart for AAPL or any other instrument.
              • What is the periodicity of the chart on which you are trying to apply the indicator.
              • Are you trying to apply the indicator on the price panel or on a different panel.


              I look forward to assisting you further.
              JoydeepNinjaTrader Customer Service

              Comment


                #8
                1) Are you trying to apply the indicator on a chart for AAPL or any other instrument.
                The closing price of AAPL is the indicator, and will be overlaid on another instrument.

                2) What is the periodicity of the chart on which you are trying to apply the indicator.
                Closing daily, as indicated by PeriodType.Day, 1

                3) Are you trying to apply the indicator on the price panel or on a different panel.
                On the same panel, as indicated by Overlay = true;

                Thanks!


                Comment


                  #9
                  Hello karfey,
                  To clarify further, say you are applying the indicator on a chart for Google. Then what is the periodicity for the chart of google. Is it a daily chart or something else.
                  JoydeepNinjaTrader Customer Service

                  Comment


                    #10
                    Sorry for the ambiguity.
                    Both charts are Daily Closing.

                    Comment


                      #11
                      Hello karfey,
                      Thanks for the clarification.

                      If you try the below code then are you able to get the plots.

                      Code:
                      protected override void Initialize()
                      {
                      	Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
                              Add("AAPL", PeriodType.Day, 1); 
                             Overlay = true;
                      }
                      Code:
                      protected override void OnBarUpdate()
                      {
                      	if (CurrentBars[1] < 1) return;
                      	
                      	if (BarsInProgress == 0)
                      		Plot0.Set(Closes[1][0]); 
                      }
                      JoydeepNinjaTrader Customer Service

                      Comment


                        #12
                        Yes the codes work. Fantastic support from Ninjatrader again!

                        I guess its an issue of resolving conflicts between OnBarsUpdate from 2 different dataseries?

                        Thanks so much for your prompt help.

                        Comment


                          #13
                          Hello karfey,
                          In your code you didnt checked if there are bars existed for the secodnary series.

                          Code:
                          if (CurrentBars[1] < 1) return;
                          Please refer to this post which further discusses it
                          http://ninjatrader.com/support/forum...ead.php?t=3170
                          JoydeepNinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Don22Trader1, Yesterday, 04:20 PM
                          1 response
                          21 views
                          0 likes
                          Last Post NinjaTrader_PaulH  
                          Started by ginx10k, Today, 05:49 AM
                          1 response
                          7 views
                          0 likes
                          Last Post NinjaTrader_Manfred  
                          Started by Goldy, Today, 04:00 AM
                          0 responses
                          20 views
                          0 likes
                          Last Post Goldy
                          by Goldy
                           
                          Started by Betican, Today, 12:32 AM
                          0 responses
                          22 views
                          0 likes
                          Last Post Betican
                          by Betican
                           
                          Started by Betican, Today, 12:25 AM
                          0 responses
                          20 views
                          0 likes
                          Last Post Betican
                          by Betican
                           
                          Working...
                          X