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 argusthome, 03-08-2026, 10:06 AM
    0 responses
    61 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    39 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    21 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    23 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    51 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X