Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

coding question

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

    coding question

    This may seem silly but I am trying to place a value of 1 when true and 0 when false. this is what I have, but it does not provide the right data. Where am I going wrong? I know the answer must be simple.

    public class MyCustomIndicator : Indicator
    {
    #region Variables

    #endregion
    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Bar, "Plot0"));
    CalculateOnBarClose = true;
    Overlay = false;
    }
    protected override void OnBarUpdate()
    {
    if(Open[0] - Low[0] >= (0.75))
    {
    Plot0.Set(1.0); // sets value to #1 if true
    }
    else Plot0.Set(0.0);
    }
    #region Properties
    [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
    [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
    public DataSeries Plot0
    {
    get { return Values[0]; }
    }
    #endregion
    }

    #2
    Hello,

    Start over and create a new indicator, then delete everything that is in OnBarUpdate and replace it with this:

    if(Open[0] - Low[0] >= (0.75))
    {
    Plot0.Set(
    1.0); // sets value to #1 if true
    }
    else
    {
    Plot0.Set(
    0.0);
    }

    It looks like you were missing an "}" after "else". This worked for me on the ES.
    DenNinjaTrader Customer Service

    Comment


      #3
      Vel,

      First, check the LOG tab for any errors.

      Then, I would take the Open[0] - Low[0] code, define a variable, and print the result to ensure the value is scaled as you think it is.

      So
      Code:
      double somevalue = Math.Abs(Open[0] - Low[0])
      Print("somevalue = " + somevalue.ToString());
      let us know.
      mrlogik
      NinjaTrader Ecosystem Vendor - Purelogik Trading

      Comment


        #4
        thanks guys

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        656 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        371 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
        579 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X