Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 WHICKED, Today, 12:45 PM
        2 responses
        16 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Started by GussJ, 03-04-2020, 03:11 PM
        15 responses
        3,271 views
        0 likes
        Last Post xiinteractive  
        Started by Tim-c, Today, 02:10 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Taddypole, Today, 02:47 PM
        0 responses
        2 views
        0 likes
        Last Post Taddypole  
        Started by chbruno, 04-24-2024, 04:10 PM
        4 responses
        51 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Working...
        X