Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simple change to a working indicator won't compile. What am I doing wrong?

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

    Simple change to a working indicator won't compile. What am I doing wrong?

    The user contributed indicator BarTimes plots the time it took to complete a bar as a bar chart in its own panel. All bars appear in orange.red. I want it to plot bars in green if C > O, else red. After that, I would like to plot a moving average of the bar times. Then I would like it to sound an alert if a bar time is N percent larger or smaller than the average, but I will deal with those future blunders another day.

    FWIW, I do not intend to remain incompetent. I have begun studying C# and hope eventually to be capable of offering advice, rather than asking for it.

    Here is what I have bungled so far.

    The original section of code reads:

    AddPlot(new Stroke(Brushes.OrangeRed, 2), PlotStyle.Bar, "BarTime");
    AddLine(new Stroke(Brushes.Gray, 1f), 0.0,"zeroLine");​

    I have replaced it with this:

    {
    if (Close > Open)
    {
    AddPlot(new Stroke(Brushes.Green, 2), PlotStyle.Bar, "BarTime");
    }
    else
    {
    AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Bar, "BarTime");
    }
    }​

    This throws the following compiler error:

    "operator '>' cannot be applied to operands of type '|Series <double>' and |Series <double>'

    What am I doing wrong, please, and how do I fix it? Oh, and are there any other obvious errors in my attempt at coding?

    Many thanks for any help.

    #2
    Never mind. One of my brain neurons fired at last. It compiles fine now.

    FWIW, the last time I tried to code something it was in QBasic. (If anyone else here is old enough to remember it, they are probably wondering what was the first thing to go.)

    Thanks for your patience.

    Comment


      #3
      Many thanks, Brandon. It's a big step forward in my education. I think even I can get there from here.

      owen5819

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      649 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      370 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      109 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      574 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      576 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X