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

Looking for basic script to add arrows and signals to graph

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

    Looking for basic script to add arrows and signals to graph

    I am looking to identify candle stick patterns when certain conditions are met, but i can't seem to figure out the logic needed to apply these to my graph. Would i need to use onbarupdate method?

    #2
    Below is add arrow up and down :


    Comment


      #3
      Hello hdshev,

      Thank you for your post.

      The built in Candle Stick Pattern indicator may be of use to you:



      If you're defining your own conditions to identify a candlestick pattern and want to draw something on the chart when this occurs, you could use a drawing tool like cincai suggested. Calling the tool within OnBarUpdate would be recommended. To ensure you're drawing the tool on each bar for which the conditions are met you'd want to use a unique tag name for each. For example:

      protected override void OnBarUpdate()
      {
      if(your conditions for entry)
      {
      Draw.Text(this, "myText" + CurrentBar, "My Pattern found", 0, High[0] + (2 * TickSize));
      }
      }

      This would print "My Pattern found" 2 ticks above the high of the bar the conditions were true for. You could do something similar if you instead wanted to draw an arrow above the bar.

      Please let us know if we may be of further assistance to you.
      Kate W.NinjaTrader Customer Service

      Comment


        #4
        thank you! this is great!

        Comment


          #5
          Based on certain criteria, I have added the following code:

          Draw.ArrowDown(this, "tag1", true, 0, High[0] + 1, Brushes.Red);

          The arrow appears for the latest condition but removes prior arrows. How do I get all the arrows for the conditions to stay on the chart without removing them?

          I want the arrows under or on top of the bar to stay on for all conditions met historically.

          Thanks.
          Last edited by givemefood; 03-18-2024, 01:54 PM.

          Comment


            #6
            Hello givemefood,

            Thanks for your notes.

            To have arrows remain drawn on the chart historically you would need to use a unique tag name in your Draw.ArrowDown() method. See the notes below from the Draw.ArrowDown() help guide documentation.

            "tag: A user defined unique id used to reference the draw object.

            For example, if you pass in a value of "myTag", each time this tag is used, the same draw object is modified. If unique tags are used each time, a new draw object will be created each time."


            This is typically done by using CurrentBar for the tag parameter in the Draw.ArrowDown() method since the CurrentBar value will be different on each bar.

            For example, the code might look something like this:

            Draw.ArrowDown(this, "tag1" + CurrentBar, true, 0, High[0] + 1, Brushes.Red);

            CurrentBar: https://ninjatrader.com/support/help...currentbar.htm

            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Thank you. That worked.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by GussJ, 03-04-2020, 03:11 PM
              11 responses
              3,223 views
              0 likes
              Last Post xiinteractive  
              Started by andrewtrades, Today, 04:57 PM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by chbruno, Today, 04:10 PM
              0 responses
              7 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Started by josh18955, 03-25-2023, 11:16 AM
              6 responses
              438 views
              0 likes
              Last Post Delerium  
              Started by FAQtrader, Today, 03:35 PM
              0 responses
              10 views
              0 likes
              Last Post FAQtrader  
              Working...
              X