Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Multi-Instrument help

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

    Multi-Instrument help

    I want to create a ratio spread chart. ie (ZN*3)-(ZB*2).

    As a strategy,
    I can access both instruments with Add() but can't seem to plot.

    As an Indicator,
    I can plot but can't access both instuments to set ratio value.

    Any ideas or direction I should look?
    Last edited by Json; 12-21-2007, 02:10 PM.

    #2
    Some people have gotten around the plotting in strategies by using Draw methods. I've seen users use DrawLine() and just draw line segments for every bar. This is not the best for efficiency and is not officially supported as a workaround either, but thought I would just throw you that idea.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Plotting on strategy chart

      Josh

      I also want to plot on a strategy chart and have used the DrawLine workaround in the past.

      This time I want to calculate the difference between $UVOL and $DVOL and draw that value as a line on the $UVOL chart somehow....or...plot both and fill the region between them (which I assume is impossible in a strategy).

      So far I have not been able to pick up the value of $DVOL...which I assume I will need to subtract from the $UVOL value (close I suppose) and then store the difference in an array.

      Such a simple task seems impossible. I am a little frustrated with this in NT as in eSignal I could add 2 instruments to a chart, plot one on the left vertical axis and one on the right and plot the difference also....not so here.

      Any direction here would be most appreciated. Thanks

      Comment


        #4
        Add the instruments into the strategy and then use Closes to do the subtraction and then plot that difference.

        Code:
        Closes[0][0] - Closes[1][0]
        http://www.ninjatrader-support.com/H...V6/Closes.html

        I don't think you even need to create an array. Just do the calculation and draw a line on every bar. Place the strategy on the $UVOL chart and it will do the lines there.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          thanks Josh

          that worked fine

          Comment


            #6
            Josh

            Is there a way in a Strategy to show the price of those plots?

            i.e. something like PaintPriceMarkers = true;

            I did use DrawTextFixed, however would prefer the price at the plot

            thanks
            Last edited by ATI user; 01-08-2008, 06:52 PM.

            Comment


              #7
              Unfortunately this is not supported since you cannot add new plots from within the scope of a NinjaScript strategy.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                ATI user,
                would you mind posting your uvol/dvol strategy for others to use as an example?

                Comment


                  #9
                  no worries...here it is...

                  protected override void Initialize()
                  {
                  // Add 1 minute Bars object to the strategy
                  Add("^DVOL", PeriodType.Minute, 1);

                  }

                  protected override void OnBarUpdate()
                  {
                  if ( Bars.FirstBarOfSession )
                  DrawHorizontalLine("center", true, 0, Color.Yellow, DashStyle.Solid, 1) ;

                  if ( FirstTickOfBar ) {
                  LastUpDnVolDiff = UpDnVolDiff;
                  UpDnVolDiff = Closes[0][0] - Closes[1][0];
                  DrawLine("diff"+CurrentBar,1,LastUpDnVolDiff,0,UpD nVolDiff,Color.Blue,DashStyle.Solid,3);
                  DrawLine("dvol"+CurrentBar,1,-Closes[1][1],0,-Closes[1][0],Color.Red,DashStyle.Solid,1);
                  }
                  // if ( PlotVolValues == "yes" )
                  DrawTextFixed("volvalues", "UVOL: " + Closes[0][0] + "\nDVOL1: " + Closes[1][0] + "\nSPRD: " + UpDnVolDiff ,
                  TextPosition.BottomRight, Color.DimGray, new Font("Arial",8), Color.Transparent, Color.Black, 1);

                  }

                  Comment


                    #10
                    In looking at the code for the "strategyplot" sample provided i am not seeing the difference between it being an indicator or a strategy. i understand it is a indicator from a strategy, but is the only thing that accesses the strategy be the
                    private
                    int id = 1


                    I am still looking at it, so maybe it will dawn on me.

                    Comment


                      #11
                      Hi timmyb,

                      The StrategyPlot is an indicator. The strategy accesses the indicator and sets values to the indicator. The indicator takes those values and plots them. The ID is just to differentiate the indicator from its own instances. This allows you to use multiple plots as opposed to only one.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Got ya thanks again Josh, i am sure i have been a pain to most here with my constant questions, but i have come a long way

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by bortz, 11-06-2023, 08:04 AM
                        47 responses
                        1,607 views
                        0 likes
                        Last Post aligator  
                        Started by jaybedreamin, Today, 05:56 PM
                        0 responses
                        9 views
                        0 likes
                        Last Post jaybedreamin  
                        Started by DJ888, 04-16-2024, 06:09 PM
                        6 responses
                        19 views
                        0 likes
                        Last Post DJ888
                        by DJ888
                         
                        Started by Jon17, Today, 04:33 PM
                        0 responses
                        6 views
                        0 likes
                        Last Post Jon17
                        by Jon17
                         
                        Started by Javierw.ok, Today, 04:12 PM
                        0 responses
                        16 views
                        0 likes
                        Last Post Javierw.ok  
                        Working...
                        X