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

Edit Code

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

    Edit Code

    Hey all,

    Could some one please edit the below code to have 15 lines, lines 1-7 Red, 8-14 yellow and 15 gold. its the NT8 constant line indicator.


    This namespace holds indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
    /// <summary>
    /// Plots lines at user defined values.
    /// </summary>
    public class ConstantLines : Indicator
    {
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDe scriptionConstantLines;
    Name = NinjaTrader.Custom.Resource.NinjaScriptIndicatorNa meConstantLines;
    IsSuspendedWhileInactive = true;
    Line1Value = 0;
    Line2Value = 0;
    Line3Value = 0;
    Line4Value = 0;
    IsAutoScale = false;
    IsOverlay = true;

    IsChartOnly = true;
    DisplayInDataBox = false;

    AddPlot(new Stroke(Brushes.DodgerBlue), PlotStyle.HLine, NinjaTrader.Custom.Resource.ConstantLines1);
    AddPlot(new Stroke(Brushes.DarkCyan), PlotStyle.HLine, NinjaTrader.Custom.Resource.ConstantLines2);
    AddPlot(new Stroke(Brushes.SlateBlue), PlotStyle.HLine, NinjaTrader.Custom.Resource.ConstantLines3);
    AddPlot(new Stroke(Brushes.Goldenrod), PlotStyle.HLine, NinjaTrader.Custom.Resource.ConstantLines4);
    }
    }

    protected override void OnBarUpdate()
    {
    if (Line1Value != 0) Line1[0] = Line1Value;
    if (Line2Value != 0) Line2[0] = Line2Value;
    if (Line3Value != 0) Line3[0] = Line3Value;
    if (Line4Value != 0) Line4[0] = Line4Value;
    }

    region Properties
    [Browsable(false)] // This line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // This line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public Series<double> Line1
    {
    get { return Values[0]; }
    }

    [Browsable(false)]
    [XmlIgnore()]
    public Series<double> Line2
    {
    get { return Values[1]; }
    }

    [Browsable(false)]
    [XmlIgnore()]
    public Series<double> Line3
    {
    get { return Values[2]; }
    }

    [Browsable(false)]
    [XmlIgnore()]
    public Series<double> Line4
    {
    get { return Values[3]; }
    }

    [NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Line1Value", GroupName = "NinjaScriptParameters", Order = 0)]
    public double Line1Value
    { get; set; }

    [NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Line2Value", GroupName = "NinjaScriptParameters", Order = 1)]
    public double Line2Value
    { get; set; }

    [NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Line3Value", GroupName = "NinjaScriptParameters", Order = 2)]
    public double Line3Value
    { get; set; }

    [NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Line4Value", GroupName = "NinjaScriptParameters", Order = 3)]
    public double Line4Value
    { get; set; }
    #endregion
    }
    }

    region NinjaScript generated code. Neither change nor remove.

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    {
    private ConstantLines[] cacheConstantLines;
    public ConstantLines ConstantLines(double line1Value, double line2Value, double line3Value, double line4Value)
    {
    return ConstantLines(Input, line1Value, line2Value, line3Value, line4Value);
    }

    public ConstantLines ConstantLines(ISeries<double> input, double line1Value, double line2Value, double line3Value, double line4Value)
    {
    if (cacheConstantLines != null)
    for (int idx = 0; idx < cacheConstantLines.Length; idx++)
    if (cacheConstantLines[idx] != null && cacheConstantLines[idx].Line1Value == line1Value && cacheConstantLines[idx].Line2Value == line2Value && cacheConstantLines[idx].Line3Value == line3Value && cacheConstantLines[idx].Line4Value == line4Value && cacheConstantLines[idx].EqualsInput(input))
    return cacheConstantLines[idx];
    return CacheIndicator<ConstantLines>(new ConstantLines(){ Line1Value = line1Value, Line2Value = line2Value, Line3Value = line3Value, Line4Value = line4Value }, input, ref cacheConstantLines);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
    {
    public Indicators.ConstantLines ConstantLines(double line1Value, double line2Value, double line3Value, double line4Value)
    {
    return indicator.ConstantLines(Input, line1Value, line2Value, line3Value, line4Value);
    }

    public Indicators.ConstantLines ConstantLines(ISeries<double> input , double line1Value, double line2Value, double line3Value, double line4Value)
    {
    return indicator.ConstantLines(input, line1Value, line2Value, line3Value, line4Value);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
    {
    public Indicators.ConstantLines ConstantLines(double line1Value, double line2Value, double line3Value, double line4Value)
    {
    return indicator.ConstantLines(Input, line1Value, line2Value, line3Value, line4Value);
    }

    public Indicators.ConstantLines ConstantLines(ISeries<double> input , double line1Value, double line2Value, double line3Value, double line4Value)
    {
    return indicator.ConstantLines(input, line1Value, line2Value, line3Value, line4Value);
    }
    }
    }

    #endregion

    #2
    Hello, thanks for your post and welcome in. The support team will not be able to make code edits or customizations but other members of the forum might be willing to help out. Looking at the indicator it looks like it is drawing static lines with Plots which is likely to have an unneeded performance impact. You can use AddLine instead:

    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by ZeroKuhl, Today, 04:31 PM
    0 responses
    7 views
    0 likes
    Last Post ZeroKuhl  
    Started by Vulgoth_t_Destroyer, 05-09-2022, 04:45 PM
    54 responses
    5,336 views
    0 likes
    Last Post Gaterz
    by Gaterz
     
    Started by ETFVoyageur, 05-07-2024, 07:05 PM
    11 responses
    73 views
    0 likes
    Last Post -=Edge=-  
    Started by _Zero_, 04-10-2020, 03:21 PM
    145 responses
    7,899 views
    6 likes
    Last Post johng2
    by johng2
     
    Started by TheTradingMantis, 01-19-2023, 02:05 AM
    43 responses
    920 views
    0 likes
    Last Post jmagaia
    by jmagaia
     
    Working...
    X