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

Color Candles

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

    Color Candles

    Hi,

    I'm converting NT 7 strategy to NT 8 and want the candles colored when parameters are met.
    I have the following:

    Code:
    public class  MyStrategy    :  Strategy
    {
         private bool     colorBars  = true;
    .
    .
    .
    #region Properties
            [Description("Color price bars mirrored from histogram data.")]
            [Category("Sound and Display")]
            [Gui.Design.DisplayName("Color Price Bars?")]
            public bool ColorBars
            {
                get { return colorBars; }
                set { colorBars = value; }
            }
    #endregion
    }
    Then I'm getting the error: "The type or namespace name 'Design" does not exist in the namespace "NinjaTrader.Gui' (are you missing an assembly reference?)

    What is the proper syntax for NT 8 for the candles to be colored?
    Thanks

    #2
    Hello,

    Thank you for the post.

    To create a public property I would suggest looking at how the SMA is currently formatted for the Period property. You can then just change it to a bool:

    Code:
    [Range(1, int.MaxValue), NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Period", GroupName = "NinjaScriptParameters", Order = 0)]
    public int Period
    { get; set; }
    This is the general format used for properties in NT8, you could modify it to be the following:

    Code:
    [NinjaScriptProperty]
    [Name = "ColorBars", GroupName = "NinjaScriptParameters", Order = 0)]
    public bool ColorBars
    { get; set; }
    Then you can set a default in State.SetDefaults:

    Code:
    if (State == State.SetDefaults)
    {
        ColorBars = true;


    In your logic, you could then use

    Code:
    if(ColorBars)
    {
    
    }
    To actually Color the bars, Brushes are used in NT8:

    Code:
    BarBrush = Brushes.Yellow;



    This guide is also helpful: http://ninjatrader.com/support/helpG...ng_changes.htm

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      On the other hand, instead of creating a public property to color the candles, I have the following that colors the candles as an indicator, but it doesn't work as I apply it as a strategy. Why is that?

      Code:
      if(Close[0]>SMA(10)[0] && SMA(10)[0]>SMA(20)[0])
                  {
                      BarBrush = Brushes.Blue;
                  }
                  else if(Close[0]<SMA(10)[0] && SMA(10)[0]<SMA(20)[0])
                  {
                      BarBrush = Brushes.Yellow;
                  }
      Thanks

      Comment


        #4
        Hello 2Look4me,

        Thanks for your post.

        The code works in a strategy (see attached).

        Do you see any errors in the control centers "log" Tab?

        If not, has the strategy been "enabled"?
        Attached Files
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          You are correct, the enabled box in strategies was not check marked. On the other hand I had coded
          Code:
          IsEnabled = true;
          why that didn't apply and I have to manually do it again?

          Comment


            #6
            Hello,

            Thank you for the reply.

            Automatically enabling a strategy is currently not available. You can specify IsEnabled = true, but it is not guaranteed to enable the script as this is not a documented property. This was also not a supported property in NT7 but did enable strategies when applied.

            I will add you to the feature request to support autostarting strategies.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by ghoul, Today, 06:02 PM
            2 responses
            12 views
            0 likes
            Last Post ghoul
            by ghoul
             
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            44 views
            0 likes
            Last Post jeronymite  
            Started by Barry Milan, Yesterday, 10:35 PM
            7 responses
            20 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by AttiM, 02-14-2024, 05:20 PM
            10 responses
            180 views
            0 likes
            Last Post jeronymite  
            Started by DanielSanMartin, Yesterday, 02:37 PM
            2 responses
            13 views
            0 likes
            Last Post DanielSanMartin  
            Working...
            X