Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Build ATR Channel. Draw Multiple Lines

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

    Build ATR Channel. Draw Multiple Lines

    Hallo everone,

    I watn to build an ATR Channel Indicator. I am currently facing the problem that my script does not draw all the lines. My guess is currently that I am setting the resources incorrectly. With the settings of the "Values" (marked yellow) I am not quite sure which values ​​are expected here. Can you help me with this? As Basic I used the MA Envelopes indicator.

    Thanks in advance

    The Code:

    protected override void OnBarUpdate()
    {
    double maValue = 0;
    double ATRMultiplikator = ATR(ATRPeriode) [0];
    double ATRChannel4 = 0;
    double ATRChannel3 = 0;
    double ATRChannel2 = 0;
    double ATRChannel1 = 0;


    switch (MAType)
    {
    case 1:
    {
    Middle[0] = maValue = ema[0];
    break;
    }
    case 2:
    {
    Middle[0] = maValue = hma[0];
    break;
    }
    case 3:
    {
    Middle[0] = maValue = sma[0];
    break;
    }
    case 4:
    {
    Middle[0] = maValue = tma[0];
    break;
    }
    case 5:
    {
    Middle[0] = maValue = tema[0];
    break;
    }
    case 6:
    {
    Middle[0] = maValue = wma[0];
    break;
    }
    }





    ATRChannel3 = maValue * (1 + ATRMultiplikator / Close[0]);
    Upper[0] = ATRChannel3;

    ATRChannel4 = ATRChannel3 * (1 + ATRMultiplikator / Close[0]);
    UpperUp[0] = ATRChannel4;

    ATRChannel2 = maValue * (1 - ATRMultiplikator / Close[0]);
    Lower[0] = ATRChannel2;

    ATRChannel1 = ATRChannel2 * (1 - ATRMultiplikator / Close[0]);
    LowerLow[0] = ATRChannel1;
    }

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

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

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

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

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

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

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

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

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

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



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



    [Range(1, int.MaxValue), NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Period", GroupName = "NinjaScriptParameters", Order = 2)]
    public int Period
    { get; set; }


    #endregion





    #2
    Hello Lopat,

    Thanks for your question.

    It looks like Middle is using Values[0] (the first plot,) and Values[1], (the second plot.)

    To get the plotting sorted, I suggest having a look at our AddPlot documentation, and then to create a new indicator that has 5 plots generated using a New Indicator wizard. This will associate each friendly Series<double> with a Values[X] series so you can see how each plot gets a separate Values[X] to hold their plot values. You could then simply assign the Open[0], High[0], Low[0], Close[0], and Volume[0] data to these plots so you can see and test plotting data to your different plot lines.

    After this, you can compare the Properties region to see how the Wizard generated plots have been set up, and you can make similar changes into the current script. Alternatively, you can implement the calculation logic in the script that has the working plot lines so they show the data you want to present.

    AddPlot - https://ninjatrader.com/support/help...8/?addplot.htm

    New NinjaScript Wizards - https://ninjatrader.com/support/help.../ns_wizard.htm

    We look forward to assisting.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    563 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    329 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    547 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    548 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X