• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Difference between to futures ES AND NQ in a dynamic variable

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

    Difference between to futures ES AND NQ in a dynamic variable

    Hi All,

    i am am looking for help on key aspect to develop my strategy

    1. How to capture value difference between NQ-ES in a variable and use in a strategy

    2. Need help to create a strategy using strategy builder and go long ES AND with ES data series only enter BQ LONG

    can an I do this ?

    any help is appreciated . I have sent multiple emails to support but received general help info .

    if some can help with code or unlock script with strategy builder

    Thx

    #2
    Please read NQ

    Comment


      #3
      Hello 2sureshk,

      Thank you for your note.

      Attached is a sample indicator which plots QQQ divided by TSLA. You could modify the attached script by passing "ES 12-18" and "NQ 12-18" for QQQ and TSLA.

      Then you could modify,

      Values[0][0] = Closes[1][0]/Closes[0][0];

      To,

      Values[0][0] = (Closes[1][0] -Closes[0][0]);

      Which would give you the net difference.

      You would have to open the script with the NinjaScript editor and when you finish making the changes, you would right click in the script>compile.

      See the following video on the NT8 NinjaScript Editor:
      https://www.youtube.com/watch?v=Q06x...ZmVnauWXkWe0Nf

      Once you get the plot showing correctly you would want to transfer this into a strategy by right clicking in the editor on the strategy folder>new strategy.

      Please let us know if you need further assistance.

      Attached Files
      Alan P.NinjaTrader Customer Service

      Comment


        #4
        Thank for the indicator .. I will take a look and share the feedback

        if i want multiply one if the instrument with 2 .

        can I use 2* closes[o][0] it instead if two a dynamic variable

        thx
        suresh

        Comment


          #5
          Hello 2sureshk,

          You could modify the script to give them a weighting, I would encourage you to use prints to confirm the values.

          I’ve provided a link to a youtube video which covers an example of using prints to understand behavior:
          https://www.youtube.com/watch?v=K8v_...tu.be&t=48m45s

          You could also see an indicator uploaded located in the sharing section which plots the FANGS as a candlestick chart with weightings for an example of this.
          https://ninjatraderecosystem.com/user-app-share/

          Please let us know if you need further assistance.
          Alan P.NinjaTrader Customer Service

          Comment


            #6
            Hi
            In order to understand how it works I have tried to adapt to ES and NQ the script attached. It compiles, but it does not work as an input of default NT8 indicators (such as ADXVMA), whereas it works with 3rd party indicator amaADXVMA .
            I have embedded some other questions within the script. Could you please have a look and perhaps reply with some hints/explanations on how to have it working also for the difference for any two different and compatible plots on a given chart?
            Thank you.
            Attached Files
            Last edited by guidoisot; 11-08-2018, 07:40 AM.

            Comment


              #7
              Hello guidoisot,

              Technically the primary series is the series the script is applied to, so the chart you apply the indicator to for example. So in the script you attached ES would be the secondary series and the NQ would be the third.

              I’m not sure I understand question 3, perhaps you can provide more detail, but the helpguide for plots would be a good resource,
              https://ninjatrader.com/support/help...s/?addplot.htm

              If you wanted the VWAP you would add a tick series in State.Configure then pass this series to the VWAP indicator in OnBarUpdate, you would want to see the following example,
              https://ninjatrader.com/support/help...flow_vwap2.htm

              Your correction of the script looks correct, initially I think it was used to show the primary series divided by ES and NQ.

              Writing statements in the strategy builder then “Viewing” and “unlocking code” is really valuable in learning how things work. In the builder I was able to select the ADXVMA and pass the PlotPrimary.. indicator to it. If you use the builder are you able to accomplish this?

              I look forward to you reply.
              Attached Files
              Alan P.NinjaTrader Customer Service

              Comment


                #8
                I am unable to use this indicator . Please share some instructions to plot on chart. It is blank when I use the indicator on chart

                Comment


                  #9
                  Hello 2sureshk,

                  Which version of the indicator? Are you seeing errors in the log tab? Are you enabled for equities data?

                  I look forward to your reply.
                  Alan P.NinjaTrader Customer Service

                  Comment


                    #10
                    Ninja trader8 . I have enabled the data for all the markets
                    no error . It just shows the blank screen I will try to post the screenshot once I get access to the system

                    Comment


                      #11
                      Hi Alan,
                      thank you for your reply, that I just noticed.
                      I thought I did subscribe this thread, but I was wrong because I did not receive any email notice telling me about your reply.
                      Incidentally, let me say, as a general feed back to your colleagues following these aspects, that I find this new version of the forum much much less .... "interactive", than previous one. It is basically impossible to find things here and printing is not available! why?
                      This change does not help much in understanding something (NT scripting) which is already enough difficult by itself.
                      Coming back to the subject, I will check/study the scripting comments of your reply and most likely I will need to ask some other questions.
                      Thank you.

                      Comment


                        #12
                        Hi 2sureshk
                        I attach my chart and its indicator panel, maybe this can help.
                        the indicator plot is onthe bottom panel.
                        Best.
                        Attached Files

                        Comment


                          #13
                          Originally posted by NinjaTrader_AlanP View Post

                          If you wanted the VWAP you would add a tick series in State.Configure then pass this series to the VWAP indicator in OnBarUpdate, you would want to see the following example,
                          https://ninjatrader.com/support/help...flow_vwap2.htm
                          Hi Alan,
                          I have tried to implement the vwap as follows:
                          Code:
                          public class Difference : Indicator
                              {
                                  protected override void OnStateChange()
                                  {
                                      if (State == State.SetDefaults)
                                      {
                                          Description                                    = @"Plot equals  Difference between any two plots on chart";
                                          Name                                        = "Difference";
                                          Calculate                                    = Calculate.OnPriceChange;
                                          IsOverlay                                    = false;
                                          DisplayInDataBox                            = true;
                                          DrawOnPricePanel                            = true;
                                          DrawHorizontalGridLines                        = true;
                                          DrawVerticalGridLines                        = true;
                                          PaintPriceMarkers                            = true;
                                          ScaleJustification                            = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                                          //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                                          //See Help Guide for additional information.
                                          IsSuspendedWhileInactive                    = true;
                                      }
                                      else if (State == State.Configure)
                                      {
                                          AddDataSeries(Data.BarsPeriodType.Tick, 1);
                                          AddPlot(Brushes.Gray, "");
                                          }
                                  }
                          
                                  protected override void OnBarUpdate()
                                  {
                                      if(CurrentBars[0]<2 || CurrentBars[1]<1 || CurrentBars[2]<1) return; //why this instruction is necessary?
                          
                                      double VWAPValue = OrderFlowVWAP(VWAPResolution.Standard, TradingHours.String2TradingHours("CME US Index Futures RTH"), VWAPStandardDeviations.Three, 1, 2, 3).VWAP[0];
                          
                                            Values[0][0] =     Close[0]-VWAPValue[0];  
                          
                          
                                  }
                              }
                          }
                          but it does not compiles.

                          I copied and pasted the instructions form the example on line, but there is something that does not work. Also, in order to simplfy, is it possible to consider just the vwap, (skipping trading hours and Standard Deviation lines)?

                          The compiling error is shown in the attached image. Thank you.




                          Attached Files

                          Comment


                            #14
                            Hello guidoisot,

                            You are setting the value of the indicator to a double but then trying to subtract close minus a double array, which is not the same. If you drop the zero at the end as my attached picture shows, it should compile.

                            I will pass on your feedback regarding the forum.

                            Please let us know if you are still unable to compile.
                            Attached Files
                            Alan P.NinjaTrader Customer Service

                            Comment


                              #15
                              Hi, thank you for your reply.
                              The code compiles, but it activates only an empty sub-panel, where the indicator should be plotted
                              Tried to use command like "plot" or "draw" applied to "value" but with no success.
                              Can this indicator be obtained with the Strategy Builder?
                              Is the (for now not visible) plot of this indicator going to be compatible for use in the Strategy Builder? Market Analyzer?
                              If I want to compare the difference between the weekly VWAP (given by amaCurrentWeekVWAP) can I just follow the same process replacing this ama weekly indicator with the orderFlowVWAP?
                              Thank you.
                              Click image for larger version  Name:	Difference compiles but plot is not visible.JPG Views:	2 Size:	226.5 KB ID:	1039479

                              #region Using declarations
                              using System;
                              using System.Collections.Generic;
                              using System.ComponentModel;
                              using System.ComponentModel.DataAnnotations;
                              using System.Linq;
                              using System.Text;
                              using System.Threading.Tasks;
                              using System.Windows;
                              using System.Windows.Input;
                              using System.Windows.Media;
                              using System.Xml.Serialization;
                              using NinjaTrader.Cbi;
                              using NinjaTrader.Gui;
                              using NinjaTrader.Gui.Chart;
                              using NinjaTrader.Gui.SuperDom;
                              using NinjaTrader.Gui.Tools;
                              using NinjaTrader.Data;
                              using NinjaTrader.NinjaScript;
                              using NinjaTrader.Core.FloatingPoint;
                              using NinjaTrader.NinjaScript.DrawingTools;
                              #endregion

                              //This namespace holds Indicators in this folder and is required. Do not change it.
                              namespace NinjaTrader.NinjaScript.Indicators.AlanIndicators
                              {
                              public class Difference : Indicator
                              {
                              protected override void OnStateChange()
                              {
                              if (State == State.SetDefaults)
                              {
                              Description = @"Plot equals Difference between any two plots on chart";
                              Name = "Difference";
                              Calculate = Calculate.OnPriceChange;
                              IsOverlay = false;
                              DisplayInDataBox = true;
                              DrawOnPricePanel = true;
                              DrawHorizontalGridLines = true;
                              DrawVerticalGridLines = true;
                              PaintPriceMarkers = true;
                              ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                              //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                              //See Help Guide for additional information.
                              IsSuspendedWhileInactive = true;
                              }
                              else if (State == State.Configure)
                              {
                              AddDataSeries(Data.BarsPeriodType.Tick, 1);
                              AddPlot(Brushes.Blue, "");
                              }
                              }

                              protected override void OnBarUpdate()
                              {
                              if(CurrentBars[0]<2 || CurrentBars[1]<1 || CurrentBars[2]<1) return; //why this instruction is necessary?

                              double VWAPValue = OrderFlowVWAP(VWAPResolution.Standard, TradingHours.String2TradingHours("CME US Index Futures RTH"), VWAPStandardDeviations.Three, 1, 2, 3).VWAP[0];

                              Values[0][0] = Close[0] - VWAPValue;
                              //when this indicator is applied to a chart it appears to be calculating, but it does not
                              //plot anything: its panel remains empty.
                              //I can just notice that the scale of panel 2 (where the indicator should be plotted) is much
                              //smaller than the actual range of values for the difference;
                              //how can I tell the script to plot this "value"
                              }


                              }
                              }


                              Click image for larger version

Name:	ES 12-18 (15 Minute) 2018_11_12 (13_00_00).png
Views:	1
Size:	105.4 KB
ID:	1039480

                              Attached Files
                              Last edited by guidoisot; 11-12-2018, 06:01 AM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by jjnc2006, Today, 07:36 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post jjnc2006  
                              Started by futurenick, Today, 06:26 AM
                              1 response
                              11 views
                              0 likes
                              Last Post nkhoi
                              by nkhoi
                               
                              Started by NinjaCustomer, Today, 12:29 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_ShawnB  
                              Started by Steve L, Today, 11:32 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post Steve L
                              by Steve L
                               
                              Started by prabbala, Today, 10:41 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post prabbala  
                              Working...
                              X