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

Draw.Arrow with simple candlestick pattern - HELP! Am I going insane?!

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

    Draw.Arrow with simple candlestick pattern - HELP! Am I going insane?!

    Hi

    I'm new to NT8, just starting to find my feet & loving the platform.

    I'm trying to draw an arrow on the chart based on some simple candlestick patterns which is not working, however if I use another type of argument it does appear to work, what I am I doing wrong?

    Code:
    protected override void OnBarUpdate()
    		{
    			//Add your custom indicator logic here.
    			
    			
    			//this is not drawing any arrows - I would expect an arrow above all 
                            //bullish candles?
                            //--
    			//if (Close[1]>Open[1])
    			
    			//this code will draw the arrow
    			//--
                            if (CrossAbove(Close, SMA(20), 1))
    			{
    				Draw.ArrowDown(this, "tag1"+ CurrentBar, true, 1, High[1], 
                                    Brushes.White);
    			}
    		}
    I would be really grateful if you could help.

    Also when I try to do something similar in my own indicator based on the candlestick pattern indi I'm also not getting the results I would expect, I must be missing something simple here?

    #2
    Hello Gav_G,

    Thanks for the post and welcome to the NinjaTrader forum.

    The evaluation if (Close[1]>Open[1]) works for me.

    Please import the attached script and let me know if you see the same.

    See here for instructions on importing:


    We provide in-depth help documentation on developing NinjaScripts for NinjaTrader 8. We also provide samples and a complete reference of the language. More in-depth educational resources can be found elsewhere throughout the internet.
    You can find the educational resources here:



    Please let me know if I may be of any further assistance.
    Attached Files
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Cheers Chris & thanks for the welcome!

      I will run through the import now.

      I have been through some of the examples you guys provide in this area so I am bamboozled as to why this isn't working

      I will keep you posted thanks matey

      Comment


        #4
        Hi Chris

        I've imported the script & added my chart & I still can't see an arrows!

        The only thing I updated (from the chart indicator window, not in code) was that the display is on the same as input series as the overlay was set to false in the code

        Any ideas of what could be going on?

        I've only had Ninja installed for a day, I think this was actually working last night, please can you import the attached & confirm if you are getting some blue candle based on the simple engulfing pattern rules, might be some stuff commented out so just ignore that, you will get the idea

        It seems the simple High[1] / Low[1] bits are not working for some reason if that makes sense
        Attached Files

        Comment


          #5
          Hello Gav_G,

          Thanks for the reply.

          Please export your script again and do not check "Export as compiled assembly". This will export the script as source code.

          When you run the script I provided, make sure you are connected and check the log tab of your Control Center for errors.

          Here are the steps I took to make the DrawTest script work:
          1. Connect to the data feed.
          2. Right click the chart select Indicators.
          3. Add the indicator "DrawTest" to the "Configured" list.
          4. Click OK


          I look forward to assisting further.
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            Hi

            I've done everything as you suggest Chris.

            Something is going on I think, I've added a screen shot, where you can see that I have the indi added to the simple chart, there are no arrows on there. Am I right in saying that you can see an arrow on top of each of the bullish candles?

            I've also added the script as you asked for, this is one where the candle colour should be painted, but based on the same kind of logic

            As you can see I am connected
            Attached Files

            Comment


              #7
              Hello Gav_G.

              Thanks for the reply.

              Please check the log tab of your Control Center for errors. I did not add a "bars ago" check. For some reason, it worked for me a couple of times. If you are getting a "bars ago" error like I am now, add a check above the indicator logic for the current bar so that you don't access a bar that is not there like so:

              Code:
              if(CurrentBar < 1)
                  	return;
              			
              if (Close[1]>Open[1])
              {
              	Draw.ArrowDown(this, "tag1"+ CurrentBar, true, 1, High[1], Brushes.White);
              }
              After you add this, remove the script and add it to your chart again.

              Here is more information on CurrentBar:



              Please let us know if you have any questions.
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                We are in business thank ever so much Chris, I'll be mindful of that going forward & read through the material to try & understand.

                Main thing is that I can see the errors in the log & that has resolved the issue so I know what to do going forward.

                Thanks & thanks again for the kind welcome & fantastic support

                Comment


                  #9
                  Hi Chris

                  I've started using the

                  Code:
                  if (CurrentBar < 5)
                  				return;
                  statement at the start if the indicator logic now, I'm not sure this is giving the desired results though sorry & I need some more help, I've been through the help text & it makes sense, well kind of.

                  I've created a simple indicator where I plot a triangle at the top of the high, based on some logic as per the below.

                  The problem is that it doesn't calculate over the last 5 bars on the chart, so it won't actually show.

                  Please see the code below, if you run this over the current USDJPY chart you will see what I mean.

                  Code:
                  if (CurrentBar < 5)
                  				return;
                  			
                  			if (High[5]<High[3] & High[4]<High[3] & High[2]<High[3] & High[1]<High[3])
                  			{
                  				Down[3] = High[3]+TickSize*10;
                  			}
                  I've also included the full file for you

                  I've also attached a screen shot of the code & the chart, you can see on the right hand side on the chart, based on the indi logic, it should have plotted a shape where I've drawn the blue arrow

                  I do understand the CurrentBar & why it's needed or the logic will fall down at the left most extreme of the chart, but don't understand why this is affecting the last few bars on the right?

                  Thanks in advance
                  Attached Files
                  Last edited by Gav_G; 07-15-2018, 01:33 AM.

                  Comment


                    #10
                    Hello Gav_G,

                    Thanks for the reply.

                    Right now, you are evaluating bar 1 through 5 on the close of bar 0. The attached screenshot shows the condition becoming true on the close of the rightmost bar. If you want to include the high of the most current bar, evaluate bars 0 through 4.

                    Please let us know if we may be of any further assistance.
                    Attached Files
                    Chris L.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by funk10101, Today, 09:43 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post funk10101  
                    Started by pkefal, 04-11-2024, 07:39 AM
                    11 responses
                    36 views
                    0 likes
                    Last Post jeronymite  
                    Started by bill2023, Yesterday, 08:51 AM
                    8 responses
                    44 views
                    0 likes
                    Last Post bill2023  
                    Started by yertle, Today, 08:38 AM
                    6 responses
                    26 views
                    0 likes
                    Last Post ryjoga
                    by ryjoga
                     
                    Started by algospoke, Yesterday, 06:40 PM
                    2 responses
                    24 views
                    0 likes
                    Last Post algospoke  
                    Working...
                    X