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

Another Beginner's Question

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

    Another Beginner's Question

    Hello:
    I'm curious why "two" data series are required for viewing a new chart.

    Also in coding, if bars of the first series are referred to as [0], [1], [2] ... [n-1], how are the bars of the second series referenced?

    Thank you.
    Last edited by tradenj; 02-09-2013, 03:27 PM.

    #2
    Two data series are not required. What makes you think two are required?

    Comment


      #3
      Hello tradenj,

      In a multiseries script, they will be referenced the same way as the normal series would be but you would add the BarsInProgress or BarsArray. You may view the following link to our Help Guide for more detailed information on how bars are referenced inside of multiseries script.

      JCNinjaTrader Customer Service

      Comment


        #4
        Hi:
        Thanks so much for your prompt replies.

        I look forward to reading about BarsInProgress and BarsArray in the supplied link.
        Concerning the requirement of 2 series per chart, upon selecting
        Control Center => File => New => Chart => SomeDataSeriesName => New => OK
        the following Error window pops up:
        "The chart template 'Default' requires '2' Data Series. Please add '1' more Data Series
        to the lower left section of the Format Data Series window before applying the chart
        template
        ."
        Last edited by tradenj; 02-08-2013, 05:30 PM.

        Comment


          #5
          Originally posted by tradenj View Post
          Hi:
          Thanks so much for your prompt replies.

          I look forward to reading about BarsInProgress and BarsArray in the supplied link.
          Concerning the requirement of 2 series per chart, upon selecting
          Control Center => File => New => Chart => SomeDataSeriesName => New => OK
          the following Error window pops up:
          "The chart template 'Default' requires '2' Data Series. Please add '1' more Data Series
          to the lower left section of the Format Data Series window before applying the chart
          template
          ."
          You must have added a template as the default for a series with 2 data series. *GULP*.

          Do you have any other templates you can choose for a single series?

          Choose that, load that chart up, and then set that as the default template....
          Last edited by sledge; 02-08-2013, 10:39 PM. Reason: charts->data series

          Comment


            #6
            OK, 2-Data-Series requirement problem solved!

            -Much appreciate these supportive bits of information which ease the struggles of this Ninja newbie.
            Last edited by tradenj; 02-10-2013, 03:57 PM.

            Comment


              #7
              BarsArray Referencing Problem

              Hello again:
              I've studied the BarsArray/ BarsInProgress documentation but am still having a problem with referencing.

              Code Objective: Color background green if both primary and secondary Data Series display an up bar.

              Compiler Error:: Argument 1: Cannot convert from 'double' to 'int'. (Occurs at each call to BarType; see /*ERROR*/ below)

              Am I sending an address to BarType by mistake instead of the bar number? If so, how do I dereference BarsArray[x][y] to get the contents at the address? (Additional note: If its NOT OK to send an array reference as a parameter I can change program structure to comply.)

              Thanks in advance for any ideas.

              Code:
              /*Using */
              namespace NinjaTrader.Strategy
              {
                  public class v1d02092013 : Strategy
                  {
                      /* Variables */
                      /** *************************************************************************** */ 
              	public bool BarType (int ThisBar, string Which)
              	{
              		bool fnResult = false;
              		switch (Which) 
              		{
              			case "Up": 
              				if (Close[ThisBar]>Open[ThisBar]) 
              					fnResult = true; 
              				break;
              			case "Down": 
              				if (Close[ThisBar]<Open[ThisBar]) 
              					fnResult = true; 
              				break;
              			default: 
              				break;
              		}
              		return fnResult;
              	}
              	/** *************************************************************************** */ 	
              	protected override void Initialize()
                      {
                          Add("MSFT", PeriodType.Minute, 2);
              			CalculateOnBarClose = true;
                      }	
                      protected override void OnBarUpdate(     )
                      {
              	        if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
              			return;
              		if (BarType (BarsArray[0][0],"Up"))                   /*ERROR*/
              			if (BarType (BarsArray[1][0],"Up"))	       /*ERROR*/
              				BackColorAll = Color.PaleGreen;		
              	}
                     /* Properties*/    
                  } /*class*/
              } /*namespace*/

              Comment


                #8
                Hello,

                As is you're sending the double value of the closing price to your BarType function.

                Instead of over complicating your script

                You could use Closes[][] and Opens[][] to see if the bars were up



                Code:
                if(Closes[0][0] > Opens[0][0] && Closes[1][0] > Opens[1][0])
                {
                  //set bar color
                }
                Let me know if I can be of further assistance.
                LanceNinjaTrader Customer Service

                Comment


                  #9
                  -Just now returning...

                  Hello:
                  -Just now returning after some days away.

                  Thank you for your reply -- it really gets to the crux of my problem. As a Wealth Lab programmer I'm used to viewing and referencing everything in terms of "bar number". Here in Ninja that level of reference doesn't seem to be present. -Great simplification!!

                  I also have the following question. Various small experimental programs (with compiler errors) have accumulated in my directory since I started at Ninja a few weeks ago. When compiling any new piece of code the system now says "Error on generating strategy" but then lists descriptions for errors in programs other than the one just compiled. I don't understand what's going on here or what to do about it. I could simply pitch all of the alternate pieces of test code but feel some hesitation about doing that.

                  Thanks again for the help.
                  Last edited by tradenj; 02-15-2013, 02:58 PM.

                  Comment


                    #10
                    Originally posted by tradenj View Post
                    Hello:
                    -Just now returning after some days away.

                    Thank you for your reply -- it really gets to the crux of my problem. As a Wealth Lab programmer I'm used to viewing and referencing everything in terms of "bar number". Here in Ninja that level of reference doesn't seem to be present. -Great simplification!!

                    I also have the following question. Various small experimental programs (with compiler errors) have accumulated in my directory since I started at Ninja a few weeks ago. When compiling any new piece of code the system now says "Error on generating strategy" but then lists descriptions for errors in programs other than the one just compiled. I don't understand what's going on here or what to do about it. I could simply pitch all of the alternate pieces of test code but feel some hesitation about doing that.

                    Thanks again for the help.
                    All your .cs files are compiled into one dll so that at runtime all code runs as native executable code. (Think: "speed of execution"). Therefore, all your .cs files must be error-free and compilable before you can compile. Correct all errors or remove the defective files.

                    Comment


                      #11
                      Ninja vs Wealth Lab Continued

                      OK, thanks for the insight.

                      This concerns another major difference between Ninja and Wealth Lab where all scripts are saved to a directory/ folder on the PC's hard drive. These programs, which are loaded into Wealth Lab and compiled individually by the user upon request, need not be error free. They can also be deleted upon navigation (via Start Menu "Explore") to the appropriate hard drive folder.
                      Last edited by tradenj; 02-18-2013, 11:37 AM.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by ScottWalsh, Today, 06:52 PM
                      4 responses
                      32 views
                      0 likes
                      Last Post ScottWalsh  
                      Started by olisav57, Today, 07:39 PM
                      0 responses
                      4 views
                      0 likes
                      Last Post olisav57  
                      Started by trilliantrader, Today, 03:01 PM
                      2 responses
                      19 views
                      0 likes
                      Last Post helpwanted  
                      Started by cre8able, Today, 07:24 PM
                      0 responses
                      6 views
                      0 likes
                      Last Post cre8able  
                      Started by Haiasi, Today, 06:53 PM
                      1 response
                      5 views
                      0 likes
                      Last Post NinjaTrader_Manfred  
                      Working...
                      X