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.
    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.
          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
                          JoydeepNinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by funk10101, Today, 12:02 AM
                          1 response
                          11 views
                          0 likes
                          Last Post NinjaTrader_LuisH  
                          Started by GLFX005, Today, 03:23 AM
                          1 response
                          6 views
                          0 likes
                          Last Post NinjaTrader_Erick  
                          Started by nandhumca, Yesterday, 03:41 PM
                          1 response
                          13 views
                          0 likes
                          Last Post NinjaTrader_Gaby  
                          Started by The_Sec, Yesterday, 03:37 PM
                          1 response
                          11 views
                          0 likes
                          Last Post NinjaTrader_Gaby  
                          Started by vecnopus, Today, 06:15 AM
                          0 responses
                          1 view
                          0 likes
                          Last Post vecnopus  
                          Working...
                          X