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 Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          600 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          347 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          103 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          558 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          558 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X