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

AddLine()

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

    AddLine()

    I have the following code. I am not seeing a plot for the highlighted lines.
    No matter what value I change "Threshold" to in properties the line value doesn't change, it remains at the value in "default settings".

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {

    Calculate = Calculate.OnBarClose;
    IsOverlay = false;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    Threshold = 100;
    #endregion
    AddLine(Brushes.DarkGray, Threshold, "Threshold");
    AddLine(Brushes.DarkGray, -Threshold, "Threshold");


    }
    }
    #region Properties
    [Range(0, int.MaxValue), NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Threshold", GroupName = "NinjaScriptParameters", Order = 1)]
    public int Threshold
    { get; set; }
    #endregion

    #2
    Hello EthanHunt,

    Thanks for your post.

    Please note that the lines will need a unique tagname, currently both have the name of "Threshold". As is the code would only show 1 line at the -100 level.

    The script, as is, would create a new panel and as there is not plotted value you would have to change the scale manually to see the line at -100.

    Please change the name of the second line or both, to be unique names. Once done you will see both lines, one at 100 and the other at -100.

    In state SetDefaults, the line will be set to their default value of 100 (and -100). To have the ability to change the line values, in State.Configure add:

    Lines[0].Value = Threshold;
    Lines[1].Value = -Threshold;

    Where Lines[0] is the first line listed and Line[1] is the second line listed.

    Reference: https://ninjatrader.com/support/help...-us/?lines.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank you!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by PaulMohn, Today, 05:00 AM
      0 responses
      7 views
      0 likes
      Last Post PaulMohn  
      Started by ZenCortexAuCost, Today, 04:24 AM
      0 responses
      6 views
      0 likes
      Last Post ZenCortexAuCost  
      Started by ZenCortexAuCost, Today, 04:22 AM
      0 responses
      3 views
      0 likes
      Last Post ZenCortexAuCost  
      Started by SantoshXX, Today, 03:09 AM
      0 responses
      16 views
      0 likes
      Last Post SantoshXX  
      Started by DanielTynera, Today, 01:14 AM
      0 responses
      5 views
      0 likes
      Last Post DanielTynera  
      Working...
      X