Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing Dot at Avg Price

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

    Drawing Dot at Avg Price

    In the OnBarUpdate() section, I have this code:

    if (Position.MarketPosition != MarketPosition.Flat)
    DrawDot("", true, 0, Position.AvgPrice, Color.Red);

    Since I'm calculating on bar close, shouldn't this place a series of dots at my average price on my chart (1 dot per bar) anytime I'm in a position? I scale in several times so I want to visually see where my net price is.

    Currently I get 1 red dot on my chart for the very last position but nothing on the previous positions. Any advice please? Is there a better way to accomplish this?

    Thanks.

    #2
    MBAGearhead,

    You need to change the string you have at the beginning to something like CurrentBar. The reason you aren't getting more dots is because you that string is the "Tag" which identifies the drawing object uniquely.

    DrawDot(CurrentBar, true, 0, Position.AvgPrice, Color.Red);

    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Adam but that line, DrawDot(CurrentBar, true, 0, Position.AvgPrice, Color.Red);
      now produces compile errors which says I have some invalid arguments. Arg. 1 cannot convert from 'int' to 'string' and Arg. 3 cannot convert from 'int' to 'System.DateTime'

      Comment


        #4
        MBA,

        Try,

        DrawDot(CurrentBar.ToString(), true, 0, Position.AvgPrice, Color.Red)
        Last edited by NinjaTrader_AdamP; 03-11-2012, 12:32 PM.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Same Arg.3 error but Arg.1 error now says cannot convert from 'method group' to 'string'

          Comment


            #6
            MBAGearHead

            Please make sure the () are at the end of the ToString().

            Please familiarize yourself with this help guide entry.



            The datetime should not be an issue if you are passing it an integer as the third input as there is an override that exists for taking integers.
            Adam P.NinjaTrader Customer Service

            Comment


              #7
              CANCEL THAT - I forgot the () after ToString! It works now!! Thanks so much Adam!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              648 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              369 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              108 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              572 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              573 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X