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

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 traderzoso, 12-27-2020, 05:19 PM
              6 responses
              229 views
              0 likes
              Last Post lekor
              by lekor
               
              Started by ETFVoyageur, 05-18-2024, 12:45 AM
              4 responses
              26 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by Skifree, Today, 11:47 AM
              4 responses
              19 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by molecool, Today, 01:48 PM
              1 response
              4 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by ETFVoyageur, Today, 12:26 PM
              3 responses
              11 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X