Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

if-else not giving expected results?

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

    if-else not giving expected results?

    the if-else shown below is not giving expected results.

    1] is the form/syntax correct?
    2] RedLine is an indicator, am I using it correctly?

    I want to clear those two questions before getting more detailed.

    if(Open[0]>=RedLine[0])
    OpenAboveRedLine=
    true;
    else
    OpenAboveRedLine=false;





    #2
    Originally posted by joemiller View Post
    the if-else shown below is not giving expected results.

    1] is the form/syntax correct?
    2] RedLine is an indicator, am I using it correctly?

    I want to clear those two questions before getting more detailed.

    if(Open[0]>=RedLine[0])
    OpenAboveRedLine=
    true;
    else
    OpenAboveRedLine=false;




    No, your syntax is incorrect. You must supply the required parameters for RedLine(). The way you have written RedLine is not even a reference to an indicator.

    Comment


      #3
      Hello joemiller,

      Thank you for your post.

      Koganam is correct, you need to use the Indicator methods parameters as well. You can find information on calling indicators at the following link: http://www.ninjatrader.com/support/h..._indicator.htm

      Comment


        #4
        thanks to both for your response.

        I tried if(Open[0]>=RedLine[0][0]). it didn't work with the error message ''cannot apply indexing with [] to an expression of type double''.I don't understand why RedLine is type double.

        some of the associated RedLine code is...

        Add(new Plot(new Pen(Color.Red, 2), PlotStyle.Line, "RedLine")); //#0

        RedLine.Set(HAOpen[0]);//jm
        DrawDiamond("tag5"+CurrentBars[0], true, 0,RedLine[0], Color.Black);//mark redline hit yest

        //---
        [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 RedLine
        {
        get { return Values[0]; }
        }

        the indicator was written for me by lance several months ago. I am trying to modify it.

        Comment


          #5
          Originally posted by joemiller View Post
          thanks to both for your response.

          I tried if(Open[0]>=RedLine[0][0]). it didn't work with the error message ''cannot apply indexing with [] to an expression of type double''.I don't understand why RedLine is type double.

          some of the associated RedLine code is...

          Add(new Plot(new Pen(Color.Red, 2), PlotStyle.Line, "RedLine")); //#0

          RedLine.Set(HAOpen[0]);//jm
          DrawDiamond("tag5"+CurrentBars[0], true, 0,RedLine[0], Color.Black);//mark redline hit yest

          //---
          [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 RedLine
          {
          get { return Values[0]; }
          }

          the indicator was written for me by lance several months ago. I am trying to modify it.
          What other properties are publicly exposed?

          Comment


            #6
            a '''find'' search on ''RedLine'' with the only ''find'' option checked being ''search hidden text'' found no other significant references as far as I can tell


            Comment


              #7
              Hello joemiller,

              Thank you for your response.

              The syntax still needs to be RedLine()[0] not RedLine[0][0].

              Comment


                #8
                Originally posted by joemiller View Post
                a '''find'' search on ''RedLine'' with the only ''find'' option checked being ''search hidden text'' found no other significant references as far as I can tell


                Not quite what I asked. IN your properties listing, your RedLine DataSeries is declared as public. What else is declared as public in that region of your code?

                Comment


                  #9
                  if(Open[0]>=RedLine()[0])
                  OpenAboveRedLine=true;
                  else
                  OpenAboveRedLine=false;
                  resulted in error ''the name 'RedLine' does not exist in the current context.''
                  ///////////////////////////////////////////////////////////////////////
                  below are all entries in the properties listing.
                  //---
                  [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 RedLine
                  {
                  get { return Values[0]; }
                  }
                  //---
                  [Browsable(false)] // do not remove
                  [XmlIgnore()] // do not remove
                  public DataSeries GreenLineUpper
                  {
                  get { return Values[1]; }
                  }
                  //---
                  [Browsable(false)] // do not remove
                  [XmlIgnore()] // do not remove
                  public DataSeries GreenLineLower
                  {
                  get { return Values[2]; }
                  }
                  //---
                  [Browsable(false)] // do not remove
                  [XmlIgnore()] // do not remove
                  public DataSeries RedStopUpper
                  {
                  get { return Values[5]; }
                  }
                  //---
                  [Browsable(false)] // do not remove
                  [XmlIgnore()] // do not remove
                  public DataSeries RedStopLower
                  {
                  get { return Values[6]; }
                  }

                  Comment


                    #10
                    Originally posted by joemiller View Post
                    if(Open[0]>=RedLine()[0])
                    OpenAboveRedLine=true;
                    else
                    OpenAboveRedLine=false;
                    resulted in error ''the name 'RedLine' does not exist in the current context.''
                    ///////////////////////////////////////////////////////////////////////
                    below are all entries in the properties listing.
                    //---
                    [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 RedLine
                    {
                    get { return Values[0]; }
                    }
                    //---
                    [Browsable(false)] // do not remove
                    [XmlIgnore()] // do not remove
                    public DataSeries GreenLineUpper
                    {
                    get { return Values[1]; }
                    }
                    //---
                    [Browsable(false)] // do not remove
                    [XmlIgnore()] // do not remove
                    public DataSeries GreenLineLower
                    {
                    get { return Values[2]; }
                    }
                    //---
                    [Browsable(false)] // do not remove
                    [XmlIgnore()] // do not remove
                    public DataSeries RedStopUpper
                    {
                    get { return Values[5]; }
                    }
                    //---
                    [Browsable(false)] // do not remove
                    [XmlIgnore()] // do not remove
                    public DataSeries RedStopLower
                    {
                    get { return Values[6]; }
                    }
                    This shows RedLine as a Plot. Do you mean that you have an indicator called RedLine, that has a Plot called Redline? From where are you calling what you are calling? Another different indicator?

                    Comment


                      #11
                      issue is closed


                      I fixed it by re-creating my code modifications, so the issue is closed. However, I can't explain for the record what the problem was because I don't know.

                      Thanks to all for the help.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Jonker, Today, 01:19 PM
                      0 responses
                      1 view
                      0 likes
                      Last Post Jonker
                      by Jonker
                       
                      Started by futtrader, Today, 01:16 PM
                      0 responses
                      5 views
                      0 likes
                      Last Post futtrader  
                      Started by Segwin, 05-07-2018, 02:15 PM
                      14 responses
                      1,791 views
                      0 likes
                      Last Post aligator  
                      Started by Jimmyk, 01-26-2018, 05:19 AM
                      6 responses
                      844 views
                      0 likes
                      Last Post emuns
                      by emuns
                       
                      Started by jxs_xrj, 01-12-2020, 09:49 AM
                      6 responses
                      3,296 views
                      1 like
                      Last Post jgualdronc  
                      Working...
                      X