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.
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by bortz, 11-06-2023, 08:04 AM
    47 responses
    1,611 views
    0 likes
    Last Post aligator  
    Started by jaybedreamin, Today, 05:56 PM
    0 responses
    9 views
    0 likes
    Last Post jaybedreamin  
    Started by DJ888, 04-16-2024, 06:09 PM
    6 responses
    19 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by Jon17, Today, 04:33 PM
    0 responses
    6 views
    0 likes
    Last Post Jon17
    by Jon17
     
    Started by Javierw.ok, Today, 04:12 PM
    0 responses
    22 views
    0 likes
    Last Post Javierw.ok  
    Working...
    X