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

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.

                        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 love2code2trade, Yesterday, 01:45 PM
                          3 responses
                          22 views
                          0 likes
                          Last Post NinjaTrader_BrandonH  
                          Started by trilliantrader, Today, 08:16 AM
                          2 responses
                          6 views
                          0 likes
                          Last Post trilliantrader  
                          Started by samish18, Today, 08:31 AM
                          1 response
                          1 view
                          0 likes
                          Last Post NinjaTrader_Clayton  
                          Started by Creamers, 09-08-2023, 10:26 AM
                          6 responses
                          157 views
                          0 likes
                          Last Post JonyGurt  
                          Started by funk10101, Today, 08:14 AM
                          1 response
                          2 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Working...
                          X