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

DrawHorizontalLine+CurrentBar(0)

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

    DrawHorizontalLine+CurrentBar(0)

    trying to make an indicator that will draw a horizontal line at the current price.

    the attached indicator works but does not allow me to choose any colors for the line...currently it's set for "Yellow" directly in the code.

    i am looking for the option to choose any color when opening the indicator window
    Attached Files

    #2
    enum

    I think you will have to add code for a enum. I think there is an example of that in the code examples.

    Here is a link to the page

    Last edited by clfield; 03-26-2009, 06:04 PM. Reason: add link

    Comment


      #3
      Hi duck_CA, you can check this link to add a user defined color input to the indicator - http://www.ninjatrader-support2.com/...ead.php?t=4977
      BertrandNinjaTrader Customer Service

      Comment


        #4
        DrawHorizontalLine("Current_price",Close[0],LineColor,DashStyle.Dot,1);

        Thank Josh for the link...

        I'm trying to create a name...which is currently "LineColor".

        I noticed that you used "BorderColor" and "FillColor" for drawing the Rectangle in your SampleColorInput Indicator.

        Is there a certain name that is needed for my case?
        Code:
        [FONT=Courier New][SIZE=2][COLOR=#0000ff]#region[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Variables[/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][COLOR=#008000]// Wizard generated variables[/COLOR][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Color LineColor = Color.Cyan;[/SIZE][/FONT]
        Code:
        [SIZE=2][FONT=Courier New]DrawHorizontalLine([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"Current_price"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],Close[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]],[SIZE=4][COLOR=blue]LineColor[/COLOR][/SIZE],DashStyle.Dot,[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT]
        Code:
        [FONT=Courier New][SIZE=2][COLOR=#0000ff]#region[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Properties[/SIZE][/FONT]
         
        [SIZE=2][FONT=Courier New][XmlIgnore()][/FONT][/SIZE]
        [SIZE=2][FONT=Courier New][Description([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"PriceLine Color"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])][/SIZE][/FONT]
        [SIZE=2][FONT=Courier New][Category([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"Parameters"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] Color Price_Line_Color[/SIZE][/FONT]
        [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
        [FONT=Courier New][SIZE=2][COLOR=#0000ff]get[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] { [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] lineColor; }[/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] { lineColor = value; }[/SIZE][/FONT]
        [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
         
        [FONT=Courier New][SIZE=2][COLOR=#008000]// Serialize our Color object[/COLOR][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][Browsable([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] priceColorSerialize[/SIZE][/FONT]
        [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
        [FONT=Courier New][SIZE=2][COLOR=#0000ff]get[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] { [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] NinjaTrader.Gui.Design.SerializableColor.ToString(lineColor); }[/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][COLOR=#0000ff]set[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] { lineColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }[/SIZE][/FONT]
        [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]

        Comment


          #5
          You need to use lower case L for your variable in the Variables section to match your variable in the Properties section.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Current PriceLine Indicator with Color Options

            Thanks Josh,

            Here is a cool indicator that draws a horizontal line at the current market price level. This can help to see where S/R levels are in comparsion to current price.

            The really cool feature is the ability to change the line color to any color desired via the indicator window.

            Attached is the Indicator and a vid showing how to change colors.
            Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.


            Glad I can contribute to my fellow Ninja Users.
            Attached Files

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by zstheorist, Today, 07:52 PM
            0 responses
            3 views
            0 likes
            Last Post zstheorist  
            Started by pmachiraju, 11-01-2023, 04:46 AM
            8 responses
            149 views
            0 likes
            Last Post rehmans
            by rehmans
             
            Started by mattbsea, Today, 05:44 PM
            0 responses
            5 views
            0 likes
            Last Post mattbsea  
            Started by RideMe, 04-07-2024, 04:54 PM
            6 responses
            33 views
            0 likes
            Last Post RideMe
            by RideMe
             
            Started by tkaboris, Today, 05:13 PM
            0 responses
            5 views
            0 likes
            Last Post tkaboris  
            Working...
            X