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

arrow issues

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

    #46
    Please send me your log and trace files so that I may look into what occurred.
    You can do this by going to the Control Center-> Help-> Mail to Platform Support.
    Ensuring 'Log and Trace Files' is checked will include these files. This is checked by default.
    Please reference the following ticket number in the body of the email: 1597771
    Jessica P.NinjaTrader Customer Service

    Comment


      #47
      I also sent the log and trace files but forgot to include the reference number.
      The error referenced the onstatechange as being the problem because "added plots or lines must have a unique name".
      I attached the cs file.
      All I did was take the Ninja EMA indicator and repeat the Period 11 more times to provide 12 total EMAs and to add 11 more AddPlot lnes to give all 12 colors.
      I also tried adding the period number (3, 5, 8...) after .NinjaScriptIndicatorNameEMA); so they would be unique making it read NinjaScriptIndicatorNameEMA3); etc... but then it didn't even compile.
      Attached Files
      Last edited by simpletrades; 11-25-2016, 11:07 AM.

      Comment


        #48
        Hello simpletrades,

        Thanks for your post.

        This seems like a lot of work to just add 12 emas to a chart as you can add them to chart manually then create a template of the chart.

        Period is a public variable that can be set by the user. Each variable must be unique so if you want the user to be able to set each period then you would need 11 more and different period variables, such as Period1, Period2, Period3, etc. and 11 more inputs in the regions variables.

        If you did not want the user to be able to set each one then you would make them private variables similar to how the constant1 and 2 are private. Also you will need 11 more pairs of constants, ech uniquely named as well, perhaps constant1a, constant2a, etc.

        Each of the added plots need a unique name, for example:

        AddPlot(Brushes.LightBlue, "myEMA3");
        AddPlot(Brushes.Cyan, "myEMA5");
        AddPlot(Brushes.Blue, "myEMA8");
        etc.etc.

        You will need to modify the Value[0] line to:

        myEMA3[0] = (CurrentBar == 0 ? Input[0] : Input[0] * constant1 + constant2 * myEMA3[1]);

        and then add that 11 times and change as follows:

        myEMA5[0] = (CurrentBar == 0 ? Input[0] : Input[0] * constant1a + constant2a * myEMA5[1]);
        myEMA8[0] = (CurrentBar == 0 ? Input[0] : Input[0] * constant1b + constant2b * myEMA8[0]);
        etc.etc.
        Finally in the regions properties you will need to add the outputs, for example:

        [Browsable(false)]
        [XmlIgnore]
        public Series<double> MyEMA3
        {
        get { return Values[0]; }
        }

        [Browsable(false)]
        [XmlIgnore]
        public Series<double> MyEMA5
        {
        get { return Values[1]; }
        }

        [Browsable(false)]
        [XmlIgnore]
        public Series<double> MyEMA8
        {
        get { return Values[2]; }
        }
        etc.
        etc.

        Alternatively, it might actually be easier for you to create a new indicator using the indicator wizard and entering in the 12 plots there as it will create all the structure for you. Just remember each plot needs a unique name. Instead of recreating the EMA code you could then just call it like

        myEMA3[0] = EMA(3)[0];
        myEMA5[0] = EMA(5)[0];
        etc.
        etc.
        Paul H.NinjaTrader Customer Service

        Comment


          #49
          Thanks for your help in Nov about getting my arrows and dots to print.
          I'm trying to take it further and write indicators to paint the bar after an up arrow blue if it moved up 5 or more ticks but go back to normal if it slips under 5 and another for red on Short for the candle after an arrow down if price moves 5 or more ticks down.
          (I use lime for up candles and violet for down so red will stand out).

          I cant make it work.
          I have it working for the dots indicator but not the arrows.
          I'm attaching my code for the dots and the red paintbar after a dot (I call them Type 1
          THEY WORK, I don't need help on them but thought you'd understand better what I want.
          I'm also attaching the code for a down arrow I'm calling type 2 Short....) which you helped me with when it wasn't always plotting consistently and also how to keep from getting multiple arrows.
          In the paintbar case I only want it to plot on the first post arrow bar.
          Some of my tries had it painting after any bar following a bar that met the arrow conditions even if it was a bar that didn't plot one because you showed me how to prevent multiples in a row.
          Other times bars that should be lime were violet intabar but if I went to my Indicators list and hit Apply it would go to lime.
          I've tried so many different changes I don't even have that version anymore.
          Attached Files

          Comment


            #50
            I Had 2 programs that color dojis yellow.
            To day I replaced one for the other and now that paintbar works--sort of.
            I'm attaching the paintbar code this time and a screenshot.
            The problem is that since lots of bars can meet this Close[1]< Open[1] && Close[1]<Low[2] without that prior bar being an arrow too because I use the line you provided to eliminate that... if ( Close[0]< Open[0] && Close[0]<Low[1] && CurrentBar- saveBar > 2)...
            it still paints red at 5 ticks.
            When I had it read like this, it didn't paint at all and Variables had this...private int saveBar = 0;
            and onbar update read...
            if ( ((Close[1]< Open[1] && Close[1]<Low[2]) == true)
            && ( Open[0]-Close[0] >=(TickSize*dist) ) && CurrentBar- saveBar > 2)
            BarColor = Color.Red; saveBar = CurrentBar;
            Can you fix that part?
            Because this happened today I don't know if it removes red if it falls under 4 ticks or colors what should be a green next bar violet and cant find out until Tuesday unless you can tell by looking.
            Attached Files
            Last edited by simpletrades; 02-18-2017, 02:49 PM.

            Comment


              #51
              Hello simpletrades, and thank you for your questions. Would it be possible to let us know

              • a brief description of every difference between your V1 dots and your V2 arrows we can help with
              • if your dots and arrows draw correctly on your chart without any of your conditional trade logic you mentioned in your most recent post
              • if you add Print statements immediately before your draw statements, are these reached with your conditional logic at appropriate times

              We will be happy to assist further
              Jessica P.NinjaTrader Customer Service

              Comment


                #52
                Its not a question of v1 vs v2 on the same indicator that I uploaded.
                There were 2 separate indicators I was calling type 1 for dots and type 2 for arrows but they did have versions I was tracking but you don't care.,
                Each has the same situation with my wanting a paintbar on the very next bar that paints and unpaints depending on which side of 5 ticks its moved intrabar.
                Its the paintbar only for the bar immediately and more importantly only after an arrow that I have problems writing,
                The dots and its related paintbar works just fine and because for shorts its coded to require a downbar to close below its prior up bar's open it always has to follow a green up bar so since 2 dots in a row won't happen 2 paintbars in a row won't happen either so there is no need to code to prevent it. I'm satisfied with the type 1 short and the type 1 paintbar following that dot short signal.

                The arrows having paintbars follow them are a problem because to signal the arrow they only require that a short close below the prior bar's low and doesn't require an opposite color bar so everytime that close lower than prior low sets up it sets up for the paintbar for the next bar too. Since the red paintbar is only meant to tell me when price is 5 or more ticks below open on the 'entry' bar I don't want lots of later bars painting.
                You showed me how to prevent multiple arrows using CurrentBar- saveBar > 2, but I cant figure out how to prevent multiple painting.
                These 2 sets of code were my attempt to tell it to stay violet or green on the second successive close below prior low--
                if ((( Close[2]< Open[2] && Close[2]<Low[3])==true)
                && ( Open[0]-Close[0] <= (TickSize*dist)) && Close[0]<Open[0])
                BarColor = Color.Violet;
                if (((Close[2]< Open[2] && Close[2]<Low[3]) == true)
                && ( Open[0]-Close[0] <= (TickSize*dist) )&& Close[0]>Open[0] )
                BarColor = Color.LimeGreen;
                Last edited by simpletrades; 02-20-2017, 12:21 PM.

                Comment


                  #53
                  Thank you for this additional information simpletrades. The easiest way to prevent something from duplicating multiple bars in a row would be with a boolean flag. I have added such a switch as an educational aid to your arrows indicator. While I do not believe this will do exactly what you had in mind, if you study the code near my initials (JDP) you should be able to see how you can have more control over what happens in two consecutive bars. I will be happy to answer any questions I can.
                  Attached Files
                  Jessica P.NinjaTrader Customer Service

                  Comment


                    #54
                    I don't need help on the arrows. Paul fixed that in November for me.
                    I need help not showing paintbars multiple times in a row meaning I am currently geting them but not wanting them on bars that follow down bars that met the close lower than prior low terms but don't have arrows because I already had an arrow bar during that downward run and didn't want repeats. I have code to prevent repeat arrows but I couldn't figure out how to use that CurrentBar- saveBar > 2 to not repeatedly color bars red at the 5 ticks bar after bar.
                    Last edited by simpletrades; 02-20-2017, 01:31 PM.

                    Comment


                      #55
                      I just loaded your indicator and realized it actually was about the paintbar not the arrow. The .cs name was deceiving, sorry.
                      At first it wasn't working but I removed a doji program that colors them yellow and replaced it with a different file and now the paintbar works.
                      I guess I'll find out tomorrow if it removes the paint whenever price retraces intrabar below the 5 ticks.
                      Last edited by simpletrades; 02-20-2017, 05:13 PM.

                      Comment


                        #56
                        It paints at 5 and unpaints at under 5 but it paints the bar following any bar that met the condition to generate an arrow even though saveBar = CurrentBar; was being used to prevent multiple arrows. In the screenshot the bar after the arrow painted and unpainted. The next bar which is also blue should not have painted at all.
                        I added your code to an up indicator painting blue but its identical.
                        Code:
                        // This flag will prevent repeat paints
                                bool didPaint = false;
                                /// <summary>
                                /// Called on each bar update event (incoming tick)
                                /// </summary>
                               protected override void OnBarUpdate()
                                {
                                      if (CurrentBar < 2) return; // do not process until first n  bars loaded. 
                        			 // We just painted the last bar
                                    if (didPaint)
                                    {
                                        didPaint = false;
                                        return;
                                    }
                        
                        	
                        			// Condition set 1   
                                   if ( Close[0]> Open[0] &&Close[1]> Open[1] && Close[1]>High[2]    //prior green closed above its prior red or green high
                        			 &&    Close[0]-Open[0] >=(TickSize*dist))  
                        		{
                        			BarColor = Color.Blue;   saveBar = CurrentBar;
                        		// This is an example showing how you can prevent something from
                                      // repeating
                                      didPaint = true;
                        		}
                        				
                        							
                        	 	 if (( ((Close[1]> Open[1] && Close[1]>High[2]) == true)// && ((Close[2]>Open[2] && Close[2]>=High[3] 
                        			&& Close[1]> Open[1]) ==true  &&  ( Close[0]-Open[0] < (TickSize*dist) )&& Close[0]<Open[0] )                    
                        		   BarColor = Color.Violet; 
                        		
                        		 if (( ((Close[1]> Open[1] && Close[1]>High[2]) == true)// && ((Close[2]>Open[2] && Close[2]>=High[3] 
                        			&& Close[1]> Open[1]) ==true &&  ( Close[0]-Open[0] < (TickSize*dist) )&& Close[0]>Open[0] )                    
                        		   BarColor = Color.LimeGreen; 
                        		
                        		 
                        		}
                        Attached Files
                        Last edited by simpletrades; 02-21-2017, 08:25 AM.

                        Comment


                          #57
                          I am glad you were able to add the code I was using successfully. It was intended more as an educational aid. If you could help me understand what our goal is by preparing something in the following format, I can help you turn this into C# code.

                          Format
                          • At time 1, I start my car
                          • At time 2, I turn on my headlights
                          • At time 3, I back out onto the street

                          I look forward to assisting further
                          Jessica P.NinjaTrader Customer Service

                          Comment


                            #58
                            Also even if the bar after the arrow paints and then unpaints by the bar close I still do not want the next bar to paint since there was no second arrow in a row allowed.

                            Comment


                              #59
                              As full development is ordinarily beyond the scope of the support we provide, and because I have reviewed with my colleagues and it seems you have a vendor relationship with NinjaTrader, please contact us at platformsupport[at]ninjatrader[dot]com with Attn:NinjaTrader_JessicaP and 1664455 in the subject line so we can assist further.
                              Jessica P.NinjaTrader Customer Service

                              Comment


                                #60
                                You have been very helpful so far and Paul was great in November.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by arvidvanstaey, Today, 02:19 PM
                                0 responses
                                2 views
                                0 likes
                                Last Post arvidvanstaey  
                                Started by mmckinnm, Today, 01:34 PM
                                3 responses
                                5 views
                                0 likes
                                Last Post NinjaTrader_ChelseaB  
                                Started by f.saeidi, Today, 01:32 PM
                                2 responses
                                6 views
                                0 likes
                                Last Post f.saeidi  
                                Started by alifarahani, 04-19-2024, 09:40 AM
                                9 responses
                                55 views
                                0 likes
                                Last Post NinjaTrader_Jesse  
                                Started by Conceptzx, 10-11-2022, 06:38 AM
                                3 responses
                                60 views
                                0 likes
                                Last Post NinjaTrader_SeanH  
                                Working...
                                X