• 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

    #16
    Hello guidoisot,

    The issue is,

    Code:
    if(CurrentBars[0]<2 || CurrentBars[1]<1 || CurrentBars[2]<1) return;


    You have your primary data series, the series the indicator is applied to, then you have the secondary tick series. So you need a current bar check to prevent NT from processing if statements which will try to pull data further back than is available. For example if you try to reference the low of 10 bars ago, on the first bar update, you'll get a index error.

    The problem is referencing CurrentBars[2], because no 3rd series is added to the script.

    I suggest reading more about current bar checks,
    https://ninjatrader.com/support/foru...cessing?t=3170

    I was able to get your indicator to plot when I removed the CurrentBars[2] part. I also required the 2nd series to have at least 10 bars, which may not be necessary.

    Please let us know if you need further assistance.






    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #17
      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

      ...
      thank you for your last post.

      regarding this quoted step, I just copied and pasted the example on my script and it worked. However when I want to calculate the difference price less "another indicator" I do not understand how I should replace WVAP with the other indicator in this part of the code:

      Code:
          protected override void OnBarUpdate()
              {
                  if(CurrentBars[0]<2 || CurrentBars[1]<10) return;
      
                  double VWAPValue = OrderFlowVWAP(VWAPResolution.Standard, TradingHours.String2TradingHours("CME US Index Futures ETH"), VWAPStandardDeviations.Three, 1, 2, 3).VWAP[0];
      
                        Values[0][0] =     Close[0] - VWAPValue;
      - how can I find out, for other indicators, either NT8 default ones or 3rd party ones, what to input inside these ex-VWAP rounded parenthesis
      Code:
      (VWAPResolution.Standard, TradingHours.String2TradingHours("CME US Index Futures ETH"), VWAPStandardDeviations.Three, 1, 2, 3)  ?
      - how can I apply different drawing properties to the plot of "value", such as whether line, bar, dot, as well as thickness, and color? I was able to find (ie: copy and paste) the zero line instruction, but not how to add properties to the plot.

      - this indicator does take a long time to calculate, I replaced the additional serie from tick to minute, but calculation time did not improve noticeably; is there any way to speed it up? For other indicators do I always need to add a tick series? for example for the 3rd party indicator amaCurrentWeekVWAP could a one minute additional data series be ok ?

      Thank you.

      Click image for larger version  Name:	ES 12-18 (5 Minute) 2018_11_15 (12_43_37).png Views:	1 Size:	119.1 KB ID:	1039954
      Attached Files
      Last edited by guidoisot; 11-15-2018, 05:47 AM.

      Comment


        #18
        I like this difference because it appears that when vwap breaks a level 1 or 2 bars before price breaks the corresponding level, that can be a signal with some good probabilities

        Click image for larger version

Name:	ES 12-18 (5 Minute) 2018_11_15 (15_30_19).png
Views:	1
Size:	114.6 KB
ID:	1039983
        Last edited by guidoisot; 11-15-2018, 08:31 AM.

        Comment


          #19
          Hello guidoisot,

          Below would be how you could replace that part of the code with the SMA indicator for example.

          Code:
          Values[0][0] =     Close[0] - SMA(10)[0];
          What goes in the parenthesis would be called the indicators parameters or overloads, you can find these in the helpguide under each indicator. For example, the VWAP has many different syntax options, so you could use any of them listed at the following link,
          https://ninjatrader.com/support/help...flow_vwap2.htm

          If you wanted to change the plot style, ie line bar dot, you could see the following link in the helpguide which demonstrates using a bar plotstyle.
          https://ninjatrader.com/support/help...s/?addplot.htm

          When you add a plot to a script like the SMA default indicator, it gives you the ability in the UI to modify the plotstyle etc. Is this what you’re referring to?

          The VWAP indicator is complex with a lot of calculations based off data more than just tick or minute series, so it would be expected that you experience a bit of a lag when loading the indicator regardless or tick vs minute, especially compared to something like the SMA. I see this on my end as well.

          I do not have the third party addon so I’m not sure, but you can test on your end to determine if it would be okay, or you could reach out to the vendor.

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

          Comment


            #20
            thank you for your reply.
            after various attempts I ended up with the following

            Code:
                else if (State == State.Configure)
                        {
                            AddDataSeries(Data.BarsPeriodType.Tick, 1);
                            AddPlot(new Stroke(Brushes.Magenta),PlotStyle.Line,"Difference");
                        }
            it is not clear what is the difference between your

            Code:
                            AddPlot(Brushes.Blue, " ");
            and my

            Code:
                            AddPlot(new Stroke(Brushes.Magenta),PlotStyle.Line,"Difference");
            this compiles but it does not show the indicator parameters on the indicator setting window.
            if I add this to State.Defaults the parameters show up, but they do not have any impact on the plot.

            The help is just not clear to me, maybe it just a language issue, or perhaps it is due to programming terminology, because I suppose it shouldn’'t be too difficult for anyone to figure out how to format a line on the chart.

            Maybe NT could post some videos on these “"how to format"“ issues, with some examples on how and where to add a plot, how to change its features, color, line , bar, thickness, ….. or depending on different conditions (for ex SMAs crossovers) how to change the chart background color, or other common and basic formatting feature.

            Or "else" maybe NT could integrate within the editor an right-click-drop-down menu which upon request can suggest all the different selections one may want to write while developing his/her script. Actually if possible I would like to ask a feature request about this "embedded scripting advisor within the ninjascript editor"".

            ... in the meantime any help is welcome. thx.
            Last edited by guidoisot; 11-16-2018, 12:27 PM.

            Comment


              #21
              Hello guidoisot,

              The first note at the following section of the helpguide details the advantage of adding plots in State.SetDefaults, see,
              https://ninjatrader.com/support/help...s/?addplot.htm

              If you look at the syntax’s listed at the link above, you could see in the case where only 2 parameters are passed to the add plot method, the 2nd parameter must then be the name of the plot. So “ “, means the plot name is empty or blank space.

              I will submit a feature request for videos.

              Regarding the scripting adviser, the strategy builder could be used for the same. I.e. you want to add a plot, strategy builder will place it in the correct place. You could also use the builder to change the chart background color too.

              Strategy Builder NT8:
              https://ninjatrader.com/support/help...on_builder.htm

              Please let us know if you need further assistance.


              Alan P.NinjaTrader Customer Service

              Comment


                #22
                Hello
                thank you for your reply.

                Originally posted by NinjaTrader_AlanP View Post
                Hello guidoisot,

                The first note at the following section of the helpguide details the advantage of adding plots in State.SetDefaults, see,
                https://ninjatrader.com/support/help...s/?addplot.htm
                ok for the first part,

                however this 2nd part ... " Alternatively, you may use custom public Brush, Stroke, or PlotStyle properties which are accessible in State.SetDefaults and pass those values to AddPlot() during State.Configure. Calling AddPlot() in this manner should be reserved for special cases." it is already not so easy for me to guess what it should mean. However I am not interested in special cases, it is enough for me just to find out how to plot a line or a bar thickness 1 or 3 , yellow or red, that's it. Special ninjascript cases, I leave them to maybe my next life, if any.

                Originally posted by NinjaTrader_AlanP View Post
                If you look at the syntax’s listed at the link above, you could see in the case where only 2 parameters are passed to the add plot method, the 2nd parameter must then be the name of the plot. So “" "“, means the plot name is empty or blank space.
                I think I got that, but what I need to know is how can I set in the syntax parameters or the properties of the plot?


                Originally posted by NinjaTrader_AlanP View Post
                Regarding the scripting adviser, the strategy builder could be used for the same. I.e. you want to add a plot, strategy builder will place it in the correct place. You could also use the builder to change the chart background color too.

                Strategy Builder NT8:
                https://ninjatrader.com/support/help...on_builder.htm
                I was asking to add a scripting adviser in the editor, I understand that the builder has many limitations and also, (supposed that Ninjatrader really wants to help all its users with little programming background to get rid of these little but numerous and neverending wastes of time due to simple scripting issues like formatting a line, or calculating a difference between two plots, or make a reference to a given swing high or low, ond so on ...), the adviser would teach and help a lot in learning how to write in the script what one wants to get.

                In the strategy builder I do not see a way it can set a variable as the difference of price minus an indicator (or viceversa).
                I wish I could send to your NT support mail a link with the video screenshot of my attempts with the strategy builder.

                Unfortunately the number of "how to" examples shown here https://ninjatrader.com/support/help...on_builder.htm is just 12
                Click image for larger version

Name:	12 how to examples for the Strategy Builder.JPG
Views:	1
Size:	257.6 KB
ID:	1040275 !

                In my opinion, based also on the many hundreds Strategy Builder support requests here on this forum, there should be hundreds of these "how to" examples about the Strategy Builder, many of them possibly also based on users' requests.

                Best.
                Last edited by guidoisot; 11-19-2018, 05:00 AM.

                Comment


                  #23
                  Hello guidoisot,

                  You could see the following link in the helpguide for an example of creating a plot with a thickness of 2 and a color of blue.
                  https://ninjatrader.com/support/help...-us/?plots.htm

                  If you are going to work outside the builder it is expected you have a basic understanding of C#. The helpguide makes the assumption you understand how to pass a method its parameters. The link above demonstrates how you can set these parameters which seems sufficient for what you’re looking to do.

                  You can not set a variable to the difference of two prices however I will submit a feature request for this.

                  I will pass on your suggest regarding the videos.

                  If you’d like I can have someone reach out with a list of third parties that would be interested in giving you the basics of C#, or I highly suggest enrolling in a basic C# online class if you’re interested in coding outside the builder.

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

                  Comment


                    #24
                    I can't find how to solve the compiling error, .... it should be just a sintax issue (?)

                    any help would be much appreciated, thx


                    Code:
                    //This namespace holds Indicators in this folder and is required. Do not change it.
                    namespace NinjaTrader.NinjaScript.Indicators.AlanIndicators
                    {
                                    public class DifferenceWeekly : Indicator
                                    {
                                                   protected override void OnStateChange()
                                                   {
                                                                   if (State == State.SetDefaults)
                                                                   {
                                                                                   Description                                                                                                                                          = @"Plot equals  Difference between any two plots on chart";
                                                                                   Name                                                                                                                                                   = "DifferenceWeekly";
                                                                                   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;
                                                                                   AddLine(Brushes.DarkGray, 0,                            NinjaTrader.Custom.Resource.NinjaScriptIndicatorZeroLine);
                                                                                   AddPlot(Brushes.Red, "");
                    
                                                                   }
                                                                   else if (State == State.Configure)
                                                                   {
                                                                                   AddDataSeries(Data.BarsPeriodType.Tick, 1);                                                   
                                                                   }
                    
                                                                   }
                    
                                                   protected override void OnBarUpdate()
                                                   {
                                                                   if(CurrentBars[0]<2 || CurrentBars[1]<10) return;
                    
                                                                   double amaCurrentWeekVWAPValue = amaCurrentWeekVWAP((Closes[1]), amaSessionTypeVWAPW.Full_Session, amaBandTypeVWAPW.Standard_Deviation, amaTimeZonesVWAPW.Exchange_Time, @"08:30", @"15:15", 1, 2, 3, 1, 2, 3);VWAP[0];
                    
                                                                                   Values[0][0] =        Close[0] - amaCurrentWeekVWAPValue; 
                    
                                                   }
                    
                    
                                    }
                    }
                    the error msg are the following:
                    NinjaScript File Error Code Line Column
                    DifferenceWeekly.cs Impossibile convertire implicitamente il tipo 'NinjaTrader.NinjaScript.Indicators.LizardIndicato rs.amaCurrentWeekVWAP' in 'double'. CS0029 61 37
                    DifferenceWeekly.cs Solo le assegnazioni, le chiamate, gli incrementi, i decrementi, le attese e le nuove espressioni dell'oggetto possono essere usate come istruzioni CS0201 61 211
                    DifferenceWeekly.cs Il nome 'VWAP' non esiste nel contesto corrente. CS0103 61 211
                    Click image for larger version

Name:	error on weekly VWAP difference.JPG
Views:	1
Size:	238.3 KB
ID:	1040699

                    Comment


                      #25
                      Hello guidoisot,

                      In the support department at NinjaTrader we do not create, debug, or modify code for our clients. This is so that we can maintain a high level of service for all of our clients.

                      You can contact a professional NinjaScript Consultants who would be eager to create or modify a script at your request or assist you with your script. Please let me know if you would like our business development follow up with you with a list of professional NinjaScript Consultants who would be happy to create this script or any others at your request.

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

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by psquare, Today, 03:11 PM
                      4 responses
                      12 views
                      0 likes
                      Last Post psquare
                      by psquare
                       
                      Started by ballboy11, Today, 03:20 PM
                      1 response
                      11 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by tonynt, Today, 02:18 PM
                      1 response
                      10 views
                      0 likes
                      Last Post NinjaTrader_JoshG  
                      Started by denalek2419, Today, 01:46 PM
                      3 responses
                      12 views
                      0 likes
                      Last Post NinjaTrader_ChristopherJ  
                      Started by REI140205, Today, 12:58 PM
                      1 response
                      10 views
                      0 likes
                      Last Post NinjaTrader_Jim  
                      Working...
                      X