Announcement

Collapse
No announcement yet.

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.

    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

        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,

            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));

                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.

                    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.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Hwop38, 05-04-2026, 07:02 PM
                          0 responses
                          175 views
                          0 likes
                          Last Post Hwop38
                          by Hwop38
                           
                          Started by CaptainJack, 04-24-2026, 11:07 PM
                          0 responses
                          331 views
                          0 likes
                          Last Post CaptainJack  
                          Started by Mindset, 04-21-2026, 06:46 AM
                          0 responses
                          253 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by M4ndoo, 04-20-2026, 05:21 PM
                          0 responses
                          356 views
                          0 likes
                          Last Post M4ndoo
                          by M4ndoo
                           
                          Started by M4ndoo, 04-19-2026, 05:54 PM
                          0 responses
                          183 views
                          0 likes
                          Last Post M4ndoo
                          by M4ndoo
                           
                          Working...
                          X