Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plotting 2 indicators

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

    Plotting 2 indicators

    Hello,

    I want to add 2 indicators to a chart with plot for addtional conditions but there is an issue I cant find out. What is wrong in my coding, as there is always plotted only one:
    protected override void Initialize()
    protected override void Initialize()
    {Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "HMAPlot"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "SMAPlot"));
    Plots[0].Pen.Width = 2; Plots[0].Pen.DashStyle = DashStyle.Dash;
    Plots[1].Pen.Width = 2; //Plots[1].Pen.DashStyle = DashStyle.Dash;
    Overlay = true;

    Add(hmAPeriodType,hmAPeriodInterval);
    Add(smAPeriodType,smAPeriodInterval); }

    protected override void OnStartUp()
    {hma=HMA(hmALength);
    sma=SMA(smALength);}

    protected override void OnBarUpdate()
    {
    if (CurrentBars[1]>0 && CurrentBars[0]>0)
    {HMAPlot[0] = hma[0];
    PlotColors[0][0] = Rising(hma) ? hrisingColor : Falling(hma) ? hfallingColor : hneutralColor;

    SMAPlot[1] = sma[1];
    PlotColors[0][0] = Rising(sma) ? srisingColor : Falling(sma) ? sfallingColor : sneutralColor;}

    THANK YOU!
    Tony

    #2
    Hi Tony, this would be in an indicator, correct? Then the Add() method to add an indicator in for display would not be valid, only strategies could do that part.

    That taken out, you also change the PlotColors only on the first 0 index plot, while the SMA would be at index 1.

    So this would give you the result of color changes only being applied to one, the primary one.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    25 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    115 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    69 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    226 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    411 views
    0 likes
    Last Post CaptainJack  
    Working...
    X