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

Accessing pip value

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

    Accessing pip value

    Hi all!

    I'm programming an indicator for Forex Trading, but think my question is more about general programming.

    Is there any way to access the pip value to use when programming? I want to round my indicator to a tenth of pip, so I need to get the pip value from the instrument (0,0001 for normal pairs and 0,01 Yen related pairs). or know at least the last decimal provided by KINETICK.

    Thanks in advance,

    Sergio

    #2
    Hi Sergio, thanks for the post - you should be able to check TickSize.ToString().Length for this task and then format as needed.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks. Another problem arise:

      I use

      Code:
      a=-Math.Log(TickSize)
      b=Math.Round(number,a)
      a is double and need to be integer. Floor and ceiling functions can give errors because they are affected by the precision of the floating point and don't know if the return an integer value.

      What can I do?

      Sergio

      Comment


        #4
        Have you tried casting it first to an Int? (int)a
        BertrandNinjaTrader Customer Service

        Comment


          #5
          I've tried it but when compiling:

          Code:
          Cannot implicitly convert type 'double' to 'int'. An explicit conversion exists (are you missing a cast?)

          Comment


            #6
            Sergio, what snippet / codeline did you try compiling, could you please post it so I can check into?

            Thanks,
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Code:
              {
                          // Use this method for calculating your indicator values. Assign a value to each
                          // plot below by replacing 'Close[0]' with your own formula.
              			if (CurrentBar < 40)
              			return;
              			a=SercavaMA1(1,true,40)[0]-SercavaMA1(1,true,40)[lookBack];
              			if (a >lI && a<lS)
              			{
              			a =0.0;
              			DrawDot(CurrentBar.ToString(),true,0,0,Color.Red);
              			}
              			b = -Math.Log(TickSize);
                          PendienteMA1.Set(Math.Round(a,b));
                      }

              Comment


                #8
                Would this compile for you?

                PendienteMA1.Set(Math.Round(a, (int)b));
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Yes, that worked but....

                  PendienteMA1.Set((int)b));


                  Returns 11!!!!! for $EURUSD instead 5.

                  Comment


                    #10
                    I would then suggest debugging your calcs leading to this value to understand better where they return unexpected values.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Is easy:

                      First: b = -Math.Log(TickSize);

                      Second: (int)b

                      Log(0.00001) should give -5. Instead of that NT gives 11.


                      I have tested :

                      PendienteMA1.Set(TickSize);--------> gives 0.00001
                      PendienteMA1.Set((int)b)); ------> gives 11

                      Comment


                        #12
                        Sorry, Math.Log gives the natural log.

                        b = -Math.Log(TickSize,10); This works as expected.

                        Comment


                          #13
                          Thanks for the update, we're glad to hear.
                          BertrandNinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by maybeimnotrader, Today, 05:46 PM
                          0 responses
                          6 views
                          0 likes
                          Last Post maybeimnotrader  
                          Started by quantismo, Today, 05:13 PM
                          0 responses
                          6 views
                          0 likes
                          Last Post quantismo  
                          Started by AttiM, 02-14-2024, 05:20 PM
                          8 responses
                          167 views
                          0 likes
                          Last Post jeronymite  
                          Started by cre8able, Today, 04:22 PM
                          0 responses
                          8 views
                          0 likes
                          Last Post cre8able  
                          Started by RichStudent, Today, 04:21 PM
                          0 responses
                          5 views
                          0 likes
                          Last Post RichStudent  
                          Working...
                          X