• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

mathemat. calculation

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

    mathemat. calculation

    hi,

    i'd like to calculate the value of ((high - low) * 20%) and additionally overwork this value with other figures.

    Using:
    int MyInteger =0
    MyInteger = ((High [0] - Low [0]) * 20%)

    result: error on "CS1525" and others.....

    perhaps you can point me in the right way - what's wrong?
    thank you very much!

    #2
    Hello,

    If your code looks exactly like the snippet that you posted, then the error is most likely coming from the "20%." You will need to represent 20% numerically in your code (.20).

    If the issue persists after making this change, please send me a screenshot of the complete error message, and I will investigate further.
    Dave I.NinjaTrader Product Management

    Comment


      #3
      hi Dave,
      thank you very much - the %-problem is solved.
      i've send you a priv message with the other problems, that do not belong to this topic.
      perhaps you can have a look at it ? thx!!

      Comment


        #4
        Originally posted by Tradexxx View Post
        hi,

        i'd like to calculate the value of ((high - low) * 20%) and additionally overwork this value with other figures.

        Using:
        int MyInteger =0
        MyInteger = ((High [0] - Low [0]) * 20%)

        result: error on "CS1525" and others.....

        perhaps you can point me in the right way - what's wrong?
        thank you very much!
        declare in variable region

        private DataSeries PRICE;

        then use it as follows:

        PRICE =new DataSeries(this);
        PRICE.Set((High[0]+Low[0])/2);

        then plot

        Comment


          #5
          hi sumana.m,

          thank's for your assistance.
          Well, indicator is compilling, but finally not drawing. i'm using:
          DrawLine ("MyLine" + CurrentBar, 0 "PRICE" [0], -5, "PRICE" [0], Color.Black
          any ideas ?

          Comment


            #6
            Hello,

            Are you using that exact syntax in your code? If so, the syntax is most likely the cause. I believe what you are looking for is:

            Code:
            DrawLine ("MyLine" + CurrentBar, 0, Close[0] -5, 0, Close[0], Color.Black)
            Please see the link below for more information on DrawLine():

            http://www.ninjatrader.com/support/h...l?drawline.htm

            Please let me know if I can assist further.
            Dave I.NinjaTrader Product Management

            Comment


              #7
              Hi Dave,
              thank you very much.
              i'm using the drawline expression in another context (tested with strategy wizzard) and it's working there. i just replaced the "Low" expression by using the "price" i wanted to be calculated....
              so i guesss it's the syntax that's wrong
              attached is the indicator, perhaps someone of you can assist me? thx
              Attached Files
              Last edited by Tradexxx; 04-03-2015, 12:22 AM.

              Comment


                #8
                sounds like it may work:
                Code:
                DrawLine ("MyLine" + CurrentBar, 0, "Low" [0], -1, "Low" [0], Color.Blue);

                Comment


                  #9
                  ??
                  no, it's not working

                  Comment


                    #10
                    Originally posted by Tradexxx View Post
                    ??
                    no, it's not working
                    Hi Trade

                    I think I've seen a couple of mistakes from your indicator:

                    PRICE = new DataSeries (this); needs to be in Initialize and not OnBarUpdate.

                    In OnBarUpdate, you should code the values as follows, dropping the quotation marks:

                    DrawLine ("MyLine" + CurrentBar, 0, PRICE[0], -1, PRICE[0], Color.Blue);

                    Also, your formula may be wrong: do you really mean:

                    PRICE.Set ((High [0] - Low [0])/2) ???

                    Being the difference, this would be a figure less than 1 and would be nowhere near the price.

                    It seems more likely you'd need the average:

                    PRICE.Set ((High [0] + Low [0])/2);

                    Comment


                      #11
                      someone here having a good idea why the indicator isn't working?
                      attached a overworked version
                      Attached Files

                      Comment


                        #12
                        Hello Tradexxx,

                        Thank you for your response.


                        You had if(CurrentBar > 3)return; at the beginning of OnBarUpdate(). If that was not intentional please set it to if(CurrentBar < 3)return; instead.
                        Patrick H.NinjaTrader Customer Service

                        Comment


                          #13
                          PatrickH,

                          thank you very much!
                          now it's working.
                          additional question: is there a description for the startcondition (when to use, how to use)?

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by seagraph, Yesterday, 03:27 PM
                          1 response
                          23 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by NinjaCustomer, Today, 09:37 AM
                          0 responses
                          6 views
                          0 likes
                          Last Post NinjaCustomer  
                          Started by stalt, Today, 07:52 AM
                          5 responses
                          16 views
                          0 likes
                          Last Post NinjaTrader_PatrickG  
                          Started by im197, 07-30-2019, 12:29 PM
                          2 responses
                          10 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by 7robert, Today, 08:20 AM
                          1 response
                          8 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Working...
                          X