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 kinfxhk, 07-14-2026, 09:39 AM
    0 responses
    91 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 10:18 AM
    0 responses
    92 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 09:50 AM
    0 responses
    70 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 07:21 AM
    0 responses
    87 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-11-2026, 02:11 AM
    0 responses
    65 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X