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

DrawArrowUp/Down only displays one set

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

    DrawArrowUp/Down only displays one set

    Hi:

    I would like to see the Up and Down arrows each time there is a change in direction. Yet, only the last set displays on the Chart (see attached pic).

    The print statement shows the logic is working; just the drawing does not.

    I've attached the program.

    Also, how can I make the Arrows larger (fatter)?

    Thanks in advance.
    Attached Files
    Last edited by ronhb107; 04-06-2016, 04:07 AM.

    #2
    Hello ronhb107,

    Thanks for your post and welcome to the forums!

    All draw objects (like DrawArrowUp and DrawArrowDown) use a tag name to identify the object. When you use a non changing tag name only the most current object is drawn. What happens is that if the new arrow tag name matches an existing one on the chart, the existing one is removed because each tag name must be unique (otherwise there would be no way for Ninjascript to know which is which).

    If you check the helpuide in any draw method, take a note of the description of the parameter 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."

    To be able to show all arrows drawn you would need to create a unique tag name for each arrow drawn. A common way to do this is to modify the tag name with the value of the current bar (assuming you only have 1 arrow per bar). For example "Up"+CurrentBar would yield a tag unique tag name like Up2167. Here is one of your statements: DrawArrowUp("Up"+CurrentBar, false, 0, Low[0] - (2 * TickSize), colorUp);
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      DrawArrowUp/Down only displays one set

      Thank you, Paul. That works!

      Is there any way to enlarge the arrow (to really make it stand out)?
      Last edited by ronhb107; 04-06-2016, 07:48 AM.

      Comment


        #4
        How can you keep each new DrawText per bar that occurs? When I use +CurrentBar it resets to the latest location on that current bar when the new condition is met. I need it to draw text as many times as the condition is met for that bar..

        DrawText("block1"+CurrentBar, true, "" +e.Volume,0,e.Price,0,Color.White, ChartControl.Font, StringAlignment.Center, Color.Black, Color.Black,7);

        Thanks.

        Comment


          #5
          Originally posted by brucelevy View Post
          How can you keep each new DrawText per bar that occurs? When I use +CurrentBar it resets to the latest location on that current bar when the new condition is met. I need it to draw text as many times as the condition is met for that bar..

          DrawText("block1"+CurrentBar, true, "" +e.Volume,0,e.Price,0,Color.White, ChartControl.Font, StringAlignment.Center, Color.Black, Color.Black,7);

          Thanks.
          Use an incrementing counter as a suffix to the tag.

          Comment


            #6
            Hello brucelevy,

            Thanks for your post.

            If you are using CalculateOnBarClose = false and you wish to see each arrow drawn intrabar then as member koganam has advised you would need an additional way of ensuring that you have unique tag names intrabar. Certainly using a counter will provide that. You would want to reset the counter on the first tick of each bar. For example (variable "counter" would be declared as an integer):

            if (FirstTickOfBar)
            {
            counter = 0; // set/reset counter to 0 on first tick of the new bar
            }


            In your draw text code:

            if (some condition)
            {
            DrawText("block1"+CurrentBar+counter, true, "" +e.Volume,0,e.Price,0,Color.White, ChartControl.Font, StringAlignment.Center, Color.Black, Color.Black,7);
            counter++;
            // increment counter
            }
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Kaledus, Today, 01:29 PM
            5 responses
            12 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by Waxavi, Today, 02:00 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by alifarahani, Today, 09:40 AM
            5 responses
            23 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by gentlebenthebear, Today, 01:30 AM
            3 responses
            16 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by PhillT, Today, 02:16 PM
            2 responses
            7 views
            0 likes
            Last Post PhillT
            by PhillT
             
            Working...
            X